;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; ROUTE EXTERNAL MIDI SOURCE TO
;; EXTERNAL MIDI DESTINATION
;;
;; Listens for incoming midi-events on first available
;; source and plays those events back to the first
;; available destination.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; make sure that everything is disconnected
(au:clear-graph)
; setup simple au graph
; piano -> output
(define piano (au:make-node "aumu" "dls " "appl"))
(au:connect-node piano 0 *au:output-node* 0)
(au:update-graph)
; print available midi sources
(io:print-midi-sources)
; print available midi destinations
(io:print-midi-destinations)
; Connect the first available midi source.
;
; Note: you can connect to as many different
; sources as you have available. Make sure
; you retain a reference to each sources id.
; The id is the value returned by midi-source.
(define src (io:midi-source 0))
; Connect the first available midi destination.
;
; Note: you can connect to as many different
; destinations as you have available. Make sure
; you retain a reference to each destination device.
; The device is the value returned by midi-destination.
(define dest (io:midi-destination 0))
(play-note (now) piano 60 80 100000)
; recieve midi events from src
; and pass them through to dest
; If events are note-on or
; note-off send them to the audiounit
; before passing them on.
(define io:midi-in
(lambda (dev type channel a b)
(if (= dev src) ; check that the incoming event is from our src
(print dev type channel a b)
(begin (cond ((= type *io:midi-cc*)
(au:midi-out (now) piano type channel a b))
((= type *io:midi-cc*)
(au:midi-out (now) piano type channel a b)))
(io:midi-out (now) dest type channel a b)))))