|
Post by mo13 on Oct 18, 2024 19:19:44 GMT
I'm trying to send out a message after an incoming M2 value has been inactive for some time, so far no output yet but would be glad to hear any suggestions:
IF LOAD # Initialize flags and timer tracking variables ASS K0 = 0 # Flag for detecting activity of B0 00 ASS K1 = 0 # Timer to track last activity END
# Main logic for detecting B0 00 IF M0 == B0 00 IF M2 != 00 # B0 00 detected: reset the timer and set the detection flag ASS K1 = T0 # Save the time when B0 00 is detected ASS K0 = 1 # Set flag to indicate that B0 00 is active ELSE # B0 00 release: mark as inactive ASS K0 = 0 # Clear the flag on release END END
# Calculate the time difference between now and the last detected activity IF K0 == 0 IF T0 >= 10 # Wait for 100 ms since the release of B0 00 # Send the timeout message B9 00 $64 (after inactivity) SND B9 00 $64
# Reset K1 to prevent multiple sends ASS K1 = T0 END END BLOCK
|
|
|
Post by redheronmusic on Oct 19, 2024 12:48:03 GMT
A user had a similar request recently over on the MIDI Designer forums, wanting to monitor MIDI active sense, and signal when active sense had stopped - www.facebook.com/groups/mididesigner/permalink/3925921567636158Same problem, watching a recurring signal, then alert when it has been inactive for a period. How are you triggering the test to see if the signal is inactive? Your timeout logic is not tied to any specific message, but it does require a message to trigger it. So you are relying on a random MIDI message arriving after the timeout period to trigger the logic - all MIDI messages will trigger your timeout test. Have you tried playing some notes, or otherwise generating some background MIDI traffic to see if the logic is triggered? You can remove the reliance on background traffic to trigger the logic by "setting a timer" to test for timeout. After each receipt of the message, send a delayed, injected internal message to trigger the timeout test. Here is the pseudo code for the active sense (FE) monitor from the FB post. On load - turn the light ON since a FE has not been received yet
When each FE is received - turn the light OFF - reset a timer - inject a dummy message with a delay longer than the sensing periodicity, such as 500 ms
When dummy message is received - read the timer - if greater than the 500 ms, turn the light on
|
|
|
Post by redheronmusic on Oct 19, 2024 15:22:56 GMT
Copied from the FB thread: So I got to thinking about the interrelationships of evaluating periodic messages on my morning walk today, and need to amplify my comments on selecting the timing values. We have: - Periodic message P, with periodicity of m - We inject message Q, with delay of n, after each P, to see if the message is still occurring. Evaluate two ways to test 1. timer is always reset on read 2. timer is reset on P, accumulated on Q From the diagram, when we read the timer - when the message is ongoing we return n-m - when the message has stopped, we return M (case 1), or N (case 2) The diagram also implies there is no advantage to the added complexity of accumulating values. So if we are monitoring a 1/3 sec message (333 msec between), a delay n of 450 should be good. During run, we expect to see 450-333 = 117 msec at evaluation points. The last read will be 333 msec, which tells us the message has stopped. There is variability in the values of m and n due to inherent variability, so for m of 333 msec, prolly set the evaluation value at 300.
|
|
|
Post by mo13 on Oct 20, 2024 17:10:32 GMT
That's been insightful and is fully functioning now thanks!
IF LOAD # Initialize flags and timer ASS K0 = 0 # Flag to track interaction ASS K1 = 0 # Timer to track the last interaction ASS K2 = 0 # Flag to track if the dummy message has been triggered END
# Main logic for detecting B0 $00 IF M0 == B0 IF M1 == $00 IF M2 != 00 IF K2 == 0 # B0 $00 detected: set flag and reset timer ASS K0 = 1 ASS K1 = T0 # Inject a dummy SysEx message SND F0 00 F7 +D1000 +I # Set the flag to prevent repeated dummy messages during active interaction ASS K2 = 1 END END END END
# Timer logic for inactivity timeout based on the dummy message IF M0 == F0 IF K0 == 1 # Compare the timer difference indirectly MAT I0 = T0 - K1 IF I0 >= 10 # Send the timeout message B9 00 $64 SND B9 00 $64 # Reset the flags after timeout ASS K0 = 0 ASS K2 = 0 # Allow dummy message to be sent again after next interaction END END END
BLOCK
|
|