;; an xtlang function which will "pull" the next incoming midi message (if there
;; is one) and then change the pitch of an oscillator
(bind-func rtmidi_process_message
(let ((type:i8 0) (chan:i8 0) (a:i8 0) (b:i8 0)
(left:i8 1) (right:i8 2)
(message:i8* (alloc 1024))
(size:i64* (alloc)))
(lambda (dev:RtMidiInPtr)
(rtmidi_in_get_message dev message size)
(set! type (>> (pref message 0) 4))
(set! chan (& (pref message 0) 15))
(set! a (pref message 1))
(set! b (pref message 2))
(println type chan a b)
(if (= a left) (dsp.freql (+ 110. (pow (i8tof b) 1.25))))
(if (= a right) (dsp.freqr (+ 110. (pow (i8tof b) 1.25))))
void)))