;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; 3D SOUND
;;
;; This example moves a sound around a 3d space.
;; For this example we assume a multi-channel device
;; capable of quad output.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(au:clear-graph)
(define multi-channel-mixer (au:make-node "aumx" "mcmx" "appl" '(4 4) '(4 4))) ;; 4 out 4 in on each bus
(define inst0 (au:make-node "aumu" "dls " "appl" 2 0)) ;; 2 out 0 in
(define inst1 (au:make-node "aumu" "dls " "appl" 2 0)) ;; 2 out 0 in
(define panner0 (au:make-node "aupn" "ambi" "appl" 4 2)) ;; 4 out 2 in
(define panner1 (au:make-node "aupn" "ambi" "appl" 4 2)) ;; 4 out 2 in
(au:connect-node inst0 0 panner0 0)
(au:connect-node inst1 0 panner1 0)
(au:connect-node panner0 0 multi-channel-mixer 0)
(au:connect-node panner1 0 multi-channel-mixer 1)
(au:connect-node multi-channel-mixer 0 *au:output-node* 0)
(au:update-graph)
(au:print-graph)
;; make sure gain on mixer channels is up!
(au:set-param (now) multi-channel-mixer 0 *au:input-scope* 0 1.0)
(au:set-param (now) multi-channel-mixer 0 *au:input-scope* 1 1.0)
(au:set-param (now) multi-channel-mixer 0 *au:output-scope* 0 1.0)
;; open views
(au:open-view multi-channel-mixer #t)
(au:open-view panner0 #t)
(au:open-view panner1 #t)
(define ping
(lambda (inst pitch)
(play-note (now) inst pitch 80 4000)
(callback (+ (now) 5000) 'ping inst pitch)))
(define move
(lambda (panner azimath elevation distance)
(let ((a (if (< azimath -180) 180 azimath))
(e (if (< elevation -90) 90 elevation))
(d (if (< distance -20.0) 20.0 distance)))
(au:set-param (now) panner 0 *au:global-scope* 0 a)
(au:set-param (now) panner 1 *au:global-scope* 0 e)
(au:set-param (now) panner 2 *au:global-scope* 0 2)
(callback (+ (now) 2000) 'move panner (- a 1) (- e 1) (- d 0.05)))))
(move panner0 180 90 20)
(move panner1 0 0 5)
(ping inst0 78)
(ping inst1 60)