;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;

;; Audio Input exmaple

;;

;; NOTE: 

;;    The output device and input device must be the

;;    same.  Therefore impromptu automatically uses

;;    the default output device for input.

;;

;; NOTE:  You must have the impromptu audiounits installed

;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(au:clear-graph)


; define a channel map to accept any number of input channels 

; but output only 2 output channels

; later we set a map to route input channels to output channels

(define channel-map (au:make-node "aufx" "chan" "MOSO" 2))

; define a filter

(define filter (au:make-node "aufx" "filt" "appl")) ; 2 chan out 2 chan in

; connect input to channel-map (*au:input-node* always uses it's second output i.e. 1)

(au:connect-node *au:input-node* 1 channel-map 0)

; connect channel-map to filter

(au:connect-node channel-map 0 filter 0)

; connect filter to output

(au:connect-node filter 0 *au:output-node* 0)

(au:update-graph)

(au:print-graph)


; set channel maps - map 1-1 2-2

; channel-map works by setting an output channel for each input channel

; input channels are set using set-params element field (channels start from 0)

; output channels are the value that you want to map the input to

; 

; channel-map is slightly weird in that it maps input channels starting from 0 

; but output channels starting from 1.

(au:set-param (now) channel-map 0 *au:global-scope* 0 1) ; this maps input channel 1 (0) to output channel 1

(au:set-param (now) channel-map 0 *au:global-scope* 1 2) ; this maps input channel 2 (1) to output channel 2


; stuff with the filter

(au:open-view filter)