Created
April 13, 2020 04:01
-
-
Save hsitz/628bd2a2a52eaea5b081f6b6b2f3b249 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 | |
// on_notes array will record the note | |
// that is actually played for | |
// any given note value. | |
// e.g., if note 60 is pressed | |
// but it is offset to 72 | |
// then on_notes[60] will be 72. | |
fillarray on_notes, 0, 129 | |
lastnote=0 | |
lnote = 0 | |
offset=0 | |
heldcount=0 | |
up = 1 | |
down = 2 | |
direction = 0 | |
@END | |
@onmidinoteoff | |
dec heldcount | |
sendmidinoteoff midibyte1, on_notes[midinote], midibyte3 | |
on_notes[midinote] = 0 | |
@end | |
@OnMidiNoteOn | |
inc heldcount | |
note=midibyte2 | |
nnote= midibyte2 % 12 | |
//interval=abs(nnote-lnote) | |
//if ((interval <=3) or (interval >= 9)) and (heldcount > 1) | |
interval = nnote - lnote | |
if (heldcount = 2) and (direction = 0) | |
// set direction if this is the start of a run | |
if note >= lastnote | |
direction = up | |
else | |
direction = down | |
endif | |
endif | |
if (direction = up) and (note < lastnote) | |
inc offset | |
elseif (direction = down) and (note > lastnote) | |
inc offset | |
endif | |
else | |
// reset | |
direction = 0 | |
offset=0 | |
endif | |
lastnote = note | |
lnote = note % 12 | |
if direction = up | |
note = note + (12 * offset) | |
else | |
note = note - (12 * offset) | |
endif | |
on_notes[midibyte2] = note | |
sendmidinoteon midibyte1, note, midibyte3 | |
@END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment