Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Midi can only trigger script one time?

Featured Replies

I have an RPN Script that I have assigned to a button on my Akai LPD8 midi controller.

The first time I press the button the script works as expected, but subsequent presses do nothing.

If I assign the script to another device (such as a mouse button) the script fires on each press as it should.   It seems specific to the midi input.

If I assign other events to midi buttons everything works fine, its a thing with scripts exclusively... The button works fine with other events, but with the script it only fires one time.   And again, if the device button is not midi, it fires on every attempt as expected.

I wonder if it is to do with the button being velocity sensitive?   Sometimes mapping it says 'Click' other times it says 'turn right' or 'turn left' (even tho its a pad and not a rotary??)

It's a pretty frustrating snag, and I'm hoping you can help.   The script is a simple toggle.  It works fine on the test script button.   Script text is below.   Thanks for anything!
(L:SWS_LIGHTING_Switch_Light_Landing) 0 == if{
  2 (>L:SWS_LIGHTING_Switch_Light_Landing, enum)
} els{
  0 (>L:SWS_LIGHTING_Switch_Light_Landing, enum)
}

 

Edited by KurtV

  • Commercial Member
28 minutes ago, KurtV said:

I wonder if it is to do with the button being velocity sensitive? 

Probably. Can you turn that off?

The velocity is what AAO uses to determine if a button has been pressed (127 then 0) or if something has been turned (velocity goes up (right turn) or down (left turn) in the 0-127 range).

28 minutes ago, KurtV said:

(L:SWS_LIGHTING_Switch_Light_Landing) 0 == if{ 2 (>L:SWS_LIGHTING_Switch_Light_Landing, enum) } els{ 0 (>L:SWS_LIGHTING_Switch_Light_Landing, enum) }

This script should not work at all, or if it does, it should work only once.
The first LVar is missing the Unit, making it an AAO internal variable. It will always be 0. Please make sure to revisit the AAO manual, the part about LVars in Scripting. LVars without a Unit are internal only, they will not be synchronized with the simulator.
This would be correct code for a simulator LVar:

(L:SWS_LIGHTING_Switch_Light_Landing,·Number)·0·==·if{·2·(>L:SWS_LIGHTING_Switch_Light_Landing,·Number)·}·els{·0·(>L:SWS_LIGHTING_Switch_Light_Landing,·Number)·}
 

Edited by Lorby_SI

LORBY-SI

  • Author
1 hour ago, Lorby_SI said:

Probably. Can you turn that off?
 

It is always software controlled (in every other program I use...) Looks like there is a editor for the firmware, I'll mess with that and see if it can do it...  Is that something you could consider for a future version?   A check box?

All of this kind of scripting is new to me (obviously).   Is there a way I could script something that says if the velocity is between 1 and 127 then thats a press, and if it is 0, it is not a press?

In my example code, I copied an earlier version where I didn't have the Enum on that first Lvar... 

Thanks for your example code, but I have tried that and it behaves exactly the same.   I'm just thinking that I need a way to tell it that any press regardless of velocity is a press.   but whats weird is that all other event types work normally.. Strike that... It works the same in all types... what is happening is if it sets 'Click' as the trigger it doesn't work... If I press again it goes 'Turn Right' then 'Turn left' as I release.... So in most cases that works ok (and your script works)... So it is looking at that velocity.  

That returns me to the top of the message -- Would it be possible to get a check box to define velocity vs absolute on midi buttons?

Edited by KurtV

  • Author

The firmware editor doesn't allow you to disable velocity... So that has to be software.

  • Commercial Member
49 minutes ago, KurtV said:

The firmware editor doesn't allow you to disable velocity... So that has to be software.

Not sure, but such a distinction is most likely impossible to make. You cannot define exceptions for individual MIDI messages in AAO, that is not how the app works. When it reaches the point where the message triggers a button, it is already too late - the decision has already been made if the message is a click or a turn.

What about assigning the "right turn" in the first place, not the click? Or will AAO pick the buttons up as an axis? Maybe that would be an alternative, an axis with a trigger event assigned? A trigger only fires once when the axis goes beyond a certain point (can be configured on the dialog)

LORBY-SI

  • Author

Interesting ideas... So far I have better luck with it on 'left turn', as it triggers as I'm releasing.  Triggering on right turn (as pressure is applied) seemed less reliable.

I'm going to run it like this for a bit and see how it goes... Basically I have this little LPD8 laying around and was hoping to integrate it, but if it doesn't do what I want I can always build up a little arduino button box or something.   The other failure of the LPD8 is that the rotaries have stops, so you can't really use them for things like altitude where you might want to really crank on it for a while... 

Thanks again for the help on this.  At least I have it working for now, so I can tinker a bit and see how best to continue.

  • Commercial Member

I found a device that has velocity sensitive keys, my old Ableton Push. I can confirm that this doesn't really work as a button. I will check if that can be improved somehow.

My work-around is this though:
1. Create a new axis assignment
2. Hit the button on the MIDI device - it should register when it is really velocity sensitive
3. Select your script in the "Select simulator Event" box
4. Set Axis Min to 0, Axis Max to 127
5. Select "Trigger Direction" "Up Only".
6. Save

 

 

LORBY-SI

  • Author

Cool, I'll give that a try, seems like it would be more reliable than what I'm doing now.

Thanks!

 

  • Commercial Member

The problem with my Push is, that it doesn't just send the one MIDI message when I hit a pad, but a bunch of them. So even when I disregard the velocity in software, it doesn't work for a button, because I get multiple actuations for the same item. It seems that the axis is the only way, at least for this kind of hardware.

LORBY-SI

  • Author
23 minutes ago, Lorby_SI said:

My work-around is this though:
1. Create a new axis assignment
2. Hit the button on the MIDI device - it should register when it is really velocity sensitive
3. Select your script in the "Select simulator Event" box
4. Set Axis Min to 0, Axis Max to 127
5. Select "Trigger Direction" "Up Only".
6. Save

Oh yes, thats the magic, much better!  Thank you!

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.