July 31, 20223 yr Trying to figure out script for using my MIDI controller (Circuit Rhythm) knobs to control heading/altitude etc. I can detect TURN_LEFT and TURN_RIGHT events correctly, but the range only goes from 0 to 127. I want to use the script to reset the controller value when it reaches the end (so if the knob got to 0 send 125·(>MIDI:3:CC:1:23) which will reset it back (and leave room to start turning it another way). My question is how to I read the MIDI value into the variable, and if I have another script for checking the knob turning the other way, how do I ignore the event when I reset knob value from 0 to 125 (in the example above). Alternatively if there is an easier way to do it I would love to know it!
July 31, 20223 yr Commercial Member 33 minutes ago, TimaFly said: Alternatively if there is an easier way to do it I would love to know it! That depends on how the hardware works. The note velocity goes from 0 to 127, that is correct. But that doesn't matter for AAO when you assign it to a button, it just wants to see the turn - you can't get to the actual value that was sent, sorry. Some devices (like the Behringer x-Touch) continue to send 127 on every "click" when you turn them further than their maximum value, and 0 when turning the other way. AAO knows this and will detect it, so those rotary encoders are "endless" anyway. But there are other devices that have physical stops, or they don't send any information at all when you go beyond the end of the range. Then you are stuck because AAO doesn't receive any more messages from the encoder. Then you may have to use the Rocker option, preferably when you can set your device into "Mackie" mode. I'm not sure that your plan will even work, I doubt that you can write a value back to the rotary encoder. The axis value can be read with the script variable, but only with an axis assignment, not for buttons. So you would have to create an additional axis assignment and bind your rotary encoder and the script to that. Axis value can be read from an LVar "(L:groupname-scriptname)" in that configuration. Edited July 31, 20223 yr by Lorby_SI LORBY-SI
July 31, 20223 yr Author Unfortunately the Knobs/encoders don't send values when they reach 0/127, after messing with MIDI controls, I figured out how to reset the knob value by sending VAL·(>MIDI:3:CC:1:23) After I set that value can keep rotating the knob because the physical knobs themselves allow infinite turning. The issue is that I only want to set the value when it reaches the end, and ideally I want to prevent the jump other way when the value is set, although I can live with it as it only happens once per 127 values. So my pseudo code is something like: Detect encoder 1 TURN_LEFT On keydown decrement ALT On key up execute script below: Read the axis value into CUR_VALUE if CUR_VALUE == 0 send 126 (>MIDI:3:CC:1:23) // this will reset the encoder so you can keep rotating it if CUR_VALUE == 127 send 1 (>MIDI:3:CC:1:23) // reset turning other way, leave 1 as the value so the encoder can be turned both ways without triggering the reset twice. optional: Somehow prevent TURN_RIGHT from triggering when the script changes CUR_VALUE Does that make sense?
July 31, 20223 yr Commercial Member 24 minutes ago, TimaFly said: figured out how to reset the knob value by sending VAL·(>MIDI:3:CC:1:23) If that is the case, I'd suggest using a single axis assignment instead of buttons. Bind your script and encoder to an AAO axis, handle the value with the script variable (L:groupname-scriptname) and an additional Lvar (L:OldHdgVal) (or any name you want) to determine turning direction and do the reset, then, in the same script, trigger the INC or DEC events accordingly. Edited July 31, 20223 yr by Lorby_SI LORBY-SI
August 1, 20223 yr Author Thanks for the quick responses, here is the version which ended up working in case anyone runs into something similar: (L:Scripts-KNOB_1_ALT)·(L:PrevAlt)·>·if{100·(>K:AP_ALT_VAR_INC)·}·els{100·(>K:AP_ALT_VAR_DEC)·} (L:Scripts-KNOB_1_ALT)·(>L:PrevAlt) (L:Scripts-KNOB_1_ALT)·3·<·if{124·(>MIDI:3:CC:1:21)} (L:Scripts-KNOB_1_ALT)·125·>·if{4·(>MIDI:3:CC:1:21)}
August 1, 20223 yr Commercial Member Good job! A few additional suggestions: Please make sure that you have the correct number of space characters in RPN scripts. The brackets do not stand on their own, if{ is an entire operator, as is els{ There should be a space after the bracket, and before the closing bracket too. And to shorten things you could use Registers, like this: (L:Scripts-KNOB_1_ALT)·s0·(L:PrevAlt)·>·if{·100·(>K:AP_ALT_VAR_INC)·}·els{·100·(>K:AP_ALT_VAR_DEC)·}· l0·(>L:PrevAlt)· l0·3·<·if{·124·(>MIDI:3:CC:1:21)·}· l0·125·>·if{·4·(>MIDI:3:CC:1:21)·} (that is "ell - zero", not "ten") I wonder what happens at the "borders" - doesn't this send the opposite event when you reach the borders at the next click? Shouldn't you adjust PrevAlt too when you send the value back to the encoder, so the next comparison has the expected result? Edited August 1, 20223 yr by Lorby_SI LORBY-SI
August 1, 20223 yr Author 6 hours ago, Lorby_SI said: I wonder what happens at the "borders" - doesn't this send the opposite event when you reach the borders at the next click? Shouldn't you adjust PrevAlt too when you send the value back to the encoder, so the next comparison has the expected result? Was getting used to the RPN syntax so kept it simple in my first version, to fix the jump you should also reset PrevAlt when you are resetting the MIDI Position: l0·3·<·if{·124·(>MIDI:3:CC:1:21)·125·(>L:PrevAlt)·}· l0·125·>·if{·4·(>MIDI:3:CC:1:21)·3·(>L:PrevAlt)·} Thanks again for all your work on the app!
Archived
This topic is now archived and is closed to further replies.