Skip to content

Instantly share code, notes, and snippets.

@hsitz
Created April 19, 2020 05:41
Show Gist options
  • Save hsitz/4d931e51791d94b7739f773447400230 to your computer and use it in GitHub Desktop.
Save hsitz/4d931e51791d94b7739f773447400230 to your computer and use it in GitHub Desktop.
// script that implements
// something like geoshred's
// autooctave.
// this will currently not
// do anything unless you're
// playing "legato", defined
// as pressing next key
// before previous key is
// released. If playing
// legato, the octave
// adjustment will be "ON"
// (would probably make more
// sense as a footswitch toggle)
@OnLoad
fillarray notes, 0, 128
lastnote = 0
counter = 0
@End
@OnMidiNoteOn
inc counter
if counter = 1
sendmidithru
exit
endif
if lastnote = 0
lastnote = midinote
endif
offset = 0
if midinote - lastnote > 6
offset = (midinote - lastnote) % 12
if offset = 0
offset = 12
endif
newnote = midinote - (12 - offset)
elseif lastnote - midinote > 6
offset = (lastnote - midinote) % 12
if offset = 0
offset = 12
endif
newnote = midinote + (12 - offset)
else
newnote = midinote
endif
sendmidinoteon midibyte1, newnote, midibyte3
lastnote = newnote
notes[midinote] = newnote
@END
@OnMidiNoteOff
dec counter
offnote = notes[midinote]
sendmidinoteoff midibyte1, offnote, midibyte3
@END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment