|
Post by klay2000 on Dec 6, 2020 16:49:55 GMT
Hi Nic. In the below script can you please explain how the modulus Mat I0 = G0 % 60
I believe this is the range of ticks from 0 to 96 but I don’t know how modulus is calculated
Also why do we need to increase tick counter by 1?
MAT G0 = G0 + 1
The full script is here ... thanks
# handle ticks IF M0 == F8 # 24 ticks == 1 beat, so determine # bar modulo into variable I0 which # will have a range of 0 to 95 MAT I0 = G0 % 60 # first beat of bar, I0 is 0 IF I0 == 0 # turn light on (note on) SND 9C 14 40 END # second beat of bar, I0 is 24 IF I0 == 18 # turn light on (note on) SND 9C 15 40 END # third beat of bar, I0 is 48 IF I0 == 30 # turn light off (note off) SND 9C 16 40 END # 4th beat of bar, I0 is 72 IF I0 == 48 # turn light off (note off) SND 9C 17 40 END # increase tick counter MAT G0 = G0 + 1 END
# reset tick count on start, continue or stop IF M0 >= FA IF M0 <= FC ASS G0 = 0 END END #
XX = XX +B
|
|
|
Post by uncledave on Dec 11, 2020 0:09:12 GMT
Hi. Not my script, but here's how I read it. The F8 message is the Time Clock message, sent 24 times per quarter note. The script counts these messages in G0, so it adds 1 for every message. The modulus operator, G0 % 60, gives the remainder after dividing by 60 ($96), so it's the position in the bar, range 0..$95.
|
|
|
Post by klay2000 on Dec 11, 2020 15:20:55 GMT
The script counts these messages in G0, so it adds 1 for every message.
Hi. Thanks for that. I’m wondering what you mean by ‘adds one for every message’?
|
|
|
Post by uncledave on Dec 11, 2020 18:22:02 GMT
Most of the script is inside the IF M0 == F8 ... END, so it runs every time it receives a MIDI clock message. The last step in that block is the MAT G0 = G0 + 1. So it adds 1 to G0 for every MIDI clock message.
Since this will count 96 for every bar, the value in G0 will get quite large. Now, it is reset to zero for start, continue, and stop from the host. But I'm not sure why you wouldn't reset it every time it reaches 96. However, G0 is a global variable in StreamByter, so another script may be relying on this value. Depends on what you're doing, obviously.
|
|