|
Post by normen on Mar 2, 2024 13:58:34 GMT
Hi,
first of all thanks for MidiFire, it's fire!
I have a MIDI pedal with two momentary buttons and I want to create 4 different output signals based on if the pedal buttons were tapped shortly or if it was held for long. Somehow my code doesn't work though, I think the timers get reset in some funny way, not sure what I am doing wrong.
# Enter rules here # Press 'Install Rules' when done
IF LOAD ALIAS $96 BUTTON_DOWN ALIAS $97 BUTTON_UP ALIAS $98 BUTTON_DOWN_LONG ALIAS $99 BUTTON_UP_LONG ALIAS $00 STATE_OFF ALIAS $127 STATE_ON ALIAS $1000 TIMEOUT END
IF M1 == BUTTON_DOWN IF M2 == STATE_ON ASS P0 = T0 ELSE CALC P0 = T0 + P0 IF P0 > TIMEOUT SND M0 BUTTON_DOWN_LONG STATE_ON ELSE SND M0 BUTTON_DOWN STATE_ON END END END
IF M1 == BUTTON_UP IF M2 == STATE_ON ASS P1 = T1 ELSE CALC P1 = T1 + P1 IF P1 > TIMEOUT SND M0 BUTTON_UP_LONG STATE_ON ELSE SND M0 BUTTON_UP STATE_ON END END END
SET LB0 P0 SET LB1 P1
BLOCK
The above code is supposed to receive two controllers with values of 127 when pressed and 0 when depressed and then send out controllers with value 127, different ones if the button was held longer than one second.
The display of the Stream Byter also shows funny values, mostly "0" though..
What am I missing?
Cheers, Normen
|
|
|
Post by normen on Mar 2, 2024 14:07:32 GMT
Wow, just as I post this I find some kind of "solution" although the fact that it works tells me I still don't get the timers. When I switch the position of the "ASS" and "CALC" it seems to work.. So the "CALC" seems to reset and start the timer and the "ASS" retrieves it, is that right?
Edit: Scratch that, now its even funnier, its always 3 seconds, no matter what, I really don't get the timers..
|
|
abadam
Developer
Rotten Apple
Posts: 60
|
Post by abadam on Mar 2, 2024 19:11:53 GMT
Each time you read a timer it returns the time passed since you last read it.
Remove the Calc entirely and change your if to if T0 > TIMEOUT (same for t1/p1). Leave the assign where it is - that starts the timer.
|
|
|
Post by normen on Mar 2, 2024 19:30:58 GMT
Each time you read a timer it returns the time passed since you last read it. Remove the Calc entirely and change your if to if T0 > TIMEOUT (same for t1/p1). Leave the assign where it is - that starts the timer. Yeah, first I only had "ASS" statements, I'd think that should work too, but it doesn't.. Just like your solution doesn't, T0 is never reporting less than about 3000 for some reason.. This doesn't work: # Enter rules here # Press 'Install Rules' when done
IF LOAD ALIAS $97 INPUT_DOWN ALIAS $96 INPUT_UP ALIAS B1 CHANNEL_DOWN ALIAS $02 BUTTON_DOWN ALIAS B1 CHANNEL_DOWN_LONG ALIAS $01 BUTTON_DOWN_LONG ALIAS B0 CHANNEL_UP ALIAS $98 BUTTON_UP ALIAS B0 CHANNEL_UP_LONG ALIAS $99 BUTTON_UP_LONG ALIAS $00 STATE_OFF ALIAS $127 STATE_ON ALIAS $1000 TIME_OUT END
IF M0 != B0 EXIT END
IF M1 == INPUT_DOWN IF M2 == STATE_ON ASS P0 = T0 #SET LB0 P0 ELSE #ASS P0 = T0 #SET LB0 P0 IF T0 > TIME_OUT SND CHANNEL_DOWN_LONG BUTTON_DOWN_LONG STATE_ON ELSE SND CHANNEL_DOWN BUTTON_DOWN STATE_ON END END END
IF M1 == INPUT_UP IF M2 == STATE_ON ASS P1 = T1 #SET LB1 P1 ELSE #ASS P1 = T1 #SET LB1 P1 IF T1 > TIME_OUT SND CHANNEL_UP_LONG BUTTON_UP_LONG STATE_ON ELSE SND CHANNEL_UP BUTTON_UP STATE_ON END END END
BLOCK #EXIT
|
|
abadam
Developer
Rotten Apple
Posts: 60
|
Post by abadam on Mar 2, 2024 19:42:30 GMT
Tried simple test like this.
If load Set lb0 t0 +d End
Each time you install rules should show milliseconds since las time pressed.
|
|
|
Post by normen on Mar 2, 2024 19:48:16 GMT
Tried simple test like this. If load Set lb0 t0 +d End Each time you install rules should show milliseconds since las time pressed. When I add that to my script it just shows a frozen value of 33000something. Edit: Ah, I get what you mean now. Yeah that works when "re-installing" but it doesn't in the loop.
|
|
|
Post by normen on Mar 2, 2024 19:56:42 GMT
I simplified the code down to this, which should work IMO, but it doesn't: # Enter rules here # Press 'Install Rules' when done
IF LOAD ALIAS $97 INPUT_DOWN ALIAS $96 INPUT_UP ALIAS B1 CHANNEL_DOWN ALIAS $02 BUTTON_DOWN ALIAS B1 CHANNEL_DOWN_LONG ALIAS $01 BUTTON_DOWN_LONG ALIAS B0 CHANNEL_UP ALIAS $98 BUTTON_UP ALIAS B0 CHANNEL_UP_LONG ALIAS $99 BUTTON_UP_LONG ALIAS $00 STATE_OFF ALIAS $127 STATE_ON ALIAS $1000 TIME_OUT END
IF M0 != B0 EXIT END
IF M1 == INPUT_DOWN ASS P0 = T0 SET LB0 P0 IF M2 == STATE_OFF IF P0 > TIME_OUT SND CHANNEL_DOWN_LONG BUTTON_DOWN_LONG STATE_ON ELSE SND CHANNEL_DOWN BUTTON_DOWN STATE_ON END END END
IF M1 == INPUT_UP ASS P1 = T1 SET LB1 P1 IF M2 == STATE_OFF IF P1 > TIME_OUT SND CHANNEL_UP_LONG BUTTON_UP_LONG STATE_ON ELSE SND CHANNEL_UP BUTTON_UP STATE_ON END END END
BLOCK #EXIT
|
|
abadam
Developer
Rotten Apple
Posts: 60
|
Post by abadam on Mar 2, 2024 20:04:37 GMT
Is cc cntnuous? Timer is reset on every cc whether 0 or 127
|
|
|
Post by normen on Mar 2, 2024 20:05:33 GMT
Is cc cntnuous? Timer is reset on every cc whether 0 or 127 Good idea but no, its toggles either 127 or 0 Edit: And again it works when I hold longer than 5s 😵💫
|
|
abadam
Developer
Rotten Apple
Posts: 60
|
Post by abadam on Mar 2, 2024 20:07:16 GMT
Multiple messages? What does monitor say?
|
|
abadam
Developer
Rotten Apple
Posts: 60
|
Post by abadam on Mar 2, 2024 20:07:49 GMT
iOS? Mac? Au? Not au?
|
|
|
Post by normen on Mar 2, 2024 20:18:41 GMT
Running on a M1 iPad Pro, Standalone. Heres an image of my setup: ImageFrom what I see it all works as expected except I never see small values.
|
|
abadam
Developer
Rotten Apple
Posts: 60
|
Post by abadam on Mar 2, 2024 20:31:22 GMT
Log timer p0 +d
After ass p0 = t0
See each timer value in event monitor
|
|
|
Post by normen on Mar 2, 2024 20:34:54 GMT
|
|
|
Post by normen on Mar 2, 2024 21:09:10 GMT
I just noticed something (see below screenshot) - the input notes have the exact same time stamp coming directly from the BLE midi input, down to the nanosecond. Is the timer based on MIDI time? cloud.bitwaves.de/s/GJQAmZg9KYysAFsEdit: The behavior is quite funny. When I keep pressing buttons the timer doesn't advance at all. Only when I don't do anything for a while the timer will increase with the next press.
|
|