;@ outs k k k
opcode NoteRcv, 0, kkkkk
   kNote, kChnl, kgate,kvel,krelvel xin
   ; RELVEL seems to be unused
   kVel init 0
   kdata init 0
   kGate init 0

  if (gkstatus==144 && gkchan==kChnl && gkdata1==kNote) then
       kdata = gkdata2
       kGate = 1
  endif

  if (gkstatus==128 && gkchan==kChnl && gkdata1==kNote) then
       kGate = 0
  endif

  zkw kGate, kgate
  zkw kdata, kvel
endop
