;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; SEND and RECEIVE OSC MESSAGES
;;
;; Open Sound Control (OSC) is network protocol
;; used by many computer music software applications.
;; For more information see this site:
;; http://www.cnmat.berkeley.edu/OpenSoundControl/
;;
;; This is a simple demo that accepts "/buz/start" and
;; "/buz/stop" messages from external client.
;; The example also includes code for sending
;; from impromptu to itself - or change addy for an
;; external host.
;;
;; Impromptu listens for OSC messages on port 7009
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; clear any existing audio graph info
(au:clear-graph)
; setup simple au graph
(define buz (au:make-node "aumu" "dls " "appl"))
(au:connect-node buz 0 *au:output-node* 0)
(au:update-graph)
(au:midi-out (now) buz *io:midi-pc* 0 57 57)
; Register this process to receive OSC events
(io:osc-register-events)
; Receives "/buz/start" and "/buz/stop" messages
; Prints all other messages to the log
(define (io:osc-receive address . args)
(cond ((string=? address "/buz/start")
(start-note (now) buz (car args) (cadr args)))
((string=? address "/buz/stop")
(stop-note (now) buz (car args)))
(else (print address '-> args))))
; Some test messages to send
(define addy (cons "localhost" 7009))
(io:osc-send (now) addy "/buz/start" 60 80)
(io:osc-send (now) addy "/buz/stop" 60)
(io:osc-send (+ (now) (* *second* 4)) addy "/test/msg" "Hello" 500 6.6 "World")