metastatik
2008-08-20 02:30:46
I have an encoder that just sends a decimal value of 1 when turned to the right and 127 when turned to the left. I’d like to emulate acceleration so that turning the encoder quickly in either direction sends different values (like 5 and 122 for example).
I kind of have this working by using a short frequency timer, but it’s unreliable…it causes MT to crash intermittently. Here’s how I have it set up…these are just the translators for the right turn…the left turn is basically identical.
So turning the encoder increases a global variable and triggers a timer. If the encoder is spun quickly, the timer will never get a chance to execute and the global variable will just keep increasing. If it’s turned slowly, the timer will execute and reset the global back to 0. The value of the global determines which value gets sent out…either 1 or 5.
It does what I want it to just not reliably. I’m assuming the timer is the issue and I tried increasing the delay, but that causes the acceleration to not work properly.
Any ideas on how to solve the reliability issue or handle this in a different way?
Thanks in advance.
I kind of have this working by using a short frequency timer, but it’s unreliable…it causes MT to crash intermittently. Here’s how I have it set up…these are just the translators for the right turn…the left turn is basically identical.
Code: Select all
Translator 1: RightSetGlobal
Options: stop=false
Incoming: MIDI F0 42 40 6E 08 43 00 01 F7
Rules:
ga=ga+1
Outgoing: (none)
Translator 2: RightSetTimer
Options: stop=false
Incoming: MIDI F0 42 40 6E 08 43 00 01 F7
Outgoing: One-shot timer "t1": 25 ms delay
Translator 3: RightResetGlobal
Options: stop=false
Incoming: On timer "t1"
Rules:
ga=0
Outgoing: (none)
Translator 4: RightMIDIOut
Options: stop=false
Incoming: MIDI F0 42 40 6E 08 43 00 01 F7
Rules:
if ga<=3 then qq=1
if ga>=4 then qq=5
Outgoing: MIDI b0 3c qq
It does what I want it to just not reliably. I’m assuming the timer is the issue and I tried increasing the delay, but that causes the acceleration to not work properly.
Any ideas on how to solve the reliability issue or handle this in a different way?
Thanks in advance.