Skip to content

Instantly share code, notes, and snippets.

@hsitz
Last active March 13, 2020 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsitz/2823309c45bc435350abc47ca9dbcda1 to your computer and use it in GitHub Desktop.
Save hsitz/2823309c45bc435350abc47ca9dbcda1 to your computer and use it in GitHub Desktop.
fly stem from Free Bass
// v. 0.1
// fixed several remaining note pairs that
// were sounding an octave too high,
// revised logging
@OnMidiNote
  note = MIDIByte2
  // notes in row 3 thru 5 have values
  // ranging from 40 to 99
  // first we will determine what row and column
  // of button we're dealing with, for FLY system
  // this will give us 1 - 20, left to right
  button_col =  1 + ( div (59-(note-40)), 3)
  //note = note + 1  // Free Bass to FLY adjustment
  // gives us 0 to 2, which correspond to 3 to 5 on actual bank
  temp = note % 3
  // adjust b/c only middle row of
  // the three has correct FLY note right now
  if temp = 0
     row = 0
     dec note
  elseif temp=2
     row=1
  elseif temp=1
     row=2
     inc note
  endif
  // now all 3 notes in same column have same FLY note
  // let's get the base FLY note
  note = 4 + ((button_col-1) * 7)
  note = note % 12
  // and now we need to adjust octave register
  // to be what FLY system wants
  // based on what row and column it's in
  // current note value is 0 - 11, we want to
  // add 12 to get it up to the octave 0 register
  note = note + 12
  c = button_col    // just to save typing
  if row = 1       // row 4 on actual bank
     if (c < 9) or (c = 12) or (c = 14) or (c = 20) or ( c = 10)
       note = note + ( 3 * 12 )
     else
       note = note + ( 4 * 12 )
     endif
  elseif row = 0    // row 3 on actual bank
     note = note + 4   // base FLY chord note is up major 3rd
     // now adjust register
     // start with default of 3rd octave and adjust from there
     note = note + (3 * 12)
     if (c = 1) or (c = 3) or (c = 2) or (c = 5) or (c = 7)
        note = note - 12    // adjust down
     elseif (c = 16) or (c = 18)
        note = note + 12    // adjust up
     endif
  elseif row = 2     //  row 5 on an actual bank
     // start with default of 3rd octave and adjust from there
     note = note + (3 * 12)
     if (c < 4) or (c = 5) or (c = 7)
        note = note - 12    // adjust down
     elseif (c = 16) or (c = 18)
        note = note + 12    // adjust up
     endif
  endif
  // at this point the incoming note from Free Bass system
  // has been converted to a base note for FLY system
  // which we will voice according to the rules
  // for its button row
  chordnote1 = note
  if row = 0       // row 3 on actual bank
    chordnote2 = note + 3
  elseif row = 1   // row 4 ...
    chordnote2 = note + 3
  elseif row = 2   // row 5 ...
    chordnote2 = note + 4
  endif
if MIDICommand = 144
  log {row: }, row, { column: }, c, { turning on base note: }, chordnote1, { and note 2: }, chordnote2
endif
  // now we send the midi for the note pair
  // if note on cmd was received this will turn on
  // if note off cmd was received this will turn off
  SendMIDIOut MIDIByte1, chordnote1, MIDIByte3
  SendMIDIOut MIDIByte1, chordnote2, MIDIByte3
@END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment