;@ ins k k k
opcode NoteSend, 0, kkkkkkk
  kVel, kNote, kChnl, kgate,kvel,knote xin

  kGate zkr kgate
  kVelin zkr kvel
  kNotein zkr knote

  kVel limit kVel + kVelin * 127, 0, 127
  kNote limit kNote + kVNotein * 127, 0, 127

  kOn init 0
  kOFF init 0

  kOn trigger kGate, 0, 0
  kOFF trigger kGate, 0, 1

  if kOn == 0 goto Next
    midiout 144, kChnl, kNote, kVel  ;  NOTEON
Next:
  if kOn == 0 goto Out
    midiout 128, kChnl, kNote, kVel ; NOTEOFF
Out:
endop
