|
Post by darius on Dec 15, 2019 14:53:46 GMT
Hi Nick, considering a midi file: when it starts playing, it sends the time signature as part of the meta Events. I would like to trigger a change (ex: send a CC message) on the 2nd beat of each measure.
Example: time signature 4 beats measure = 4/4 on beat 2 of measure #1 StreamByter sends a CC message on beat 2 of measure #2 "" etc.
Can you please support me in programming this? Bes regards, Darius
|
|
nic
Soapbox Supremo
Troublemaker
Press any key to continue
Posts: 2,011
|
Post by nic on Dec 16, 2019 11:24:35 GMT
Hi darius , You need to keep track of the clock signal to do this. Obviously whatever is playing the events must either be generating the clock or be synced to a clock source that MidiFire also sees. Each measure happens in 4/4 every 96 ticks. If you need to operate with different time signatures then you need to trap time signature events and adjust accordingly, but here is some code for the second beat of each measure at 4/4 time: if load alias L80 tick_count alias L81 tick_mod assign tick_count = 0 end
if M0 == F8 calc tick_mod = tick_count % $96 if tick_mod == $24 # 2nd beat of measure # send CC here end calc tick_count = tick_count + 1 end if M0 == FC assign tick_count = 0 endRegards, Nic.
|
|
|
Post by darius on Dec 18, 2019 22:10:42 GMT
Thanks Nick, I had to look for the meaning of a modulo calculation (%), but now I get the idea. Very compact programming, I am impressed! Regards, Darius
|
|