Last active
April 9, 2020 05:19
-
-
Save hsitz/43311bc0d0759e10745b43f9de892199 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OnLoad | |
// counter will hold the | |
// humber of currently-held notes for each channel | |
fillarray counter, 0, 10 | |
// each channel's saved notes are put in noteoffs array | |
// starting at offset of 40 * [their channel #] | |
fillarray noteoffs, 0 | |
// save_cnt will count how many notes | |
// are being saved for each channel | |
fillarray save_cnt, 0, 10 | |
@END | |
@OnMidiNoteOn | |
inc counter[midichannel] | |
sendmidithru | |
@END | |
@OnMidiNoteOff | |
offset = 40 * midichannel | |
dec counter[midichannel] | |
if counter[midichannel] = 0 | |
if save_cnt[midichannel] > 0 | |
cnt = 0 | |
while noteoffs[cnt+offset] > 0 | |
note = noteoffs[cnt+offset] | |
sendmidinoteoff midichannel, note, 0 | |
inc cnt | |
endwhile | |
fillarray noteoffs[40*midichannel], 0, 40 | |
save_cnt[midichannel] = 0 | |
endif | |
sendmidithru | |
else | |
number_saved = save_cnt[midichannel] | |
log { notes saved for channel }, midichannel, {: }, number_saved | |
noteoffs[number_saved + offset] = midinote | |
inc save_cnt[midichannel] | |
endif | |
@END | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment