Last active
April 13, 2020 01:52
-
-
Save hsitz/ca9c80f1093b39d134a308c638524e28 to your computer and use it in GitHub Desktop.
bassnoteruns
This file contains 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) | |
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) | |
if note < 100 | |
inc offset | |
else | |
direction = down | |
endif | |
elseif (direction = down) and (note > lastnote) | |
if note > 25 | |
inc offset | |
else | |
direction = up | |
endif | |
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