(require rsc3/rsc3 rsc3-ctl/rsc3-ctl) ;; Make ctls. (define s (open-udp* "127.0.0.1" 57110)) (define c (make-ctls* s 64)) ;; Setup zero. (ctl-setup (c 0) "freq" (make-spec* 220 660 'exponential) 260 4) ;; Print status. (ctl-display (c 0)) ;; Note that modifying the state modifies the value. (begin (ctl-increment (c 0) 1) (ctl-display (c 0))) ;; Note that modifying the value modifies the state. (begin (edit-ctl-value (c 0) (randi 220 660)) (ctl-display (c 0))) ;; Register a printout receiver (begin (define (printer index spec value state) (display (list "recv" index spec value state)) (newline)) (ctl-recv-add (c 0) printer)) ;; Poke the receiver. (edit-ctl-value (c 0) 440) ;; Unregister the receiver. (ctl-recv-remove (c 0) printer) ;; It is possible to clear all receivers, but note that this will ;; clear the receiver used by the interface to track changes (if the ;; interface is in use). (ctl-recv-clear (c 0)) ;; The internal zero-one value of the can be modified. (begin (edit-ctl-internal (c 0) (rand 0.0 0.1)) (ctl-display (c 0))) ;; The value can be fetched from the SC3 server. The update is ;; not synchronous. (define c (make-ctls* s 64)) (begin (ctl-setup (c 0) "freq" (make-spec* 220 660 'exponential) 440 2) (display (list "before, after" (ctl-value (c 0)) (begin (-> s (/c_set 0 250)) (ctl-update (c 0)) (sleep 0.5) (ctl-value (c 0)))))) ;; Test instrument. (send-synth s "ping" (letc ((freq 440) (ampl 0.1)) (Pan2 (Mul (SinOsc ar freq 0) (EnvGen kr 1 ampl 0 1 2 (env/perc 0.1 0.1 1 4))) (Rand -1 1) (Rand 0.2 0.4)))) (-> s (/s_new "ping" -1 0 1)) ;; Use values to control node instatiation, the example uses the ;; scheduler, packaged as module rscT. (begin (ctl-setup (c 0) "delay" (make-spec* 0.05 0.75 'linear) 0.18 2) (ctl-setup (c 1) "freq" (make-spec* 0.5 2.0 'linear) 1.0 2) (ctl-setup (c 2) "ampl" (make-spec* 0.0 1.0 'linear) 0.1 2) (define Q (make-schedule*)) (at Q (utc) (lambda (t f) (-> s (bundle (+ t 0.25) (/s_new "ping" -1 1 1 "freq" (* (ctl-value (c 1)) (rand 220 440)) "ampl" (ctl-value (c 2))))) (f (ctl-value (c 0)))))) (schedule-clear Q) ;; Modify values using interface or REPL. (edit-ctl-value (c 0) (rand 0.05 0.15)) (edit-ctl-value (c 1) (rand 0.5 2.0)) (edit-ctl-value (c 2) (rand 0.1 0.9))