#!r6rs (library (rsc3 supercollider synthdef) (export synthdef send-synth ugen->graphdef/out) (import (rnrs) (only (rsc3 server command) /d_recv) (only (rsc3 server server) -><) (only (rsc3 graphdef graphdef) encode-graphdef) (only (rsc3 graphdef letc) letc) (only (rsc3 graphdef mce) mce?) (only (rsc3 graphdef rate) kr) (only (rsc3 graphdef ugen) ugen? ugen-outputs) (only (rsc3 ugen graph) graph->graphdef) (only (rsc3 ugen filter) Out)) ;; Transform a into a . (define synthdef graph->graphdef) ;; If ugen has output ports encapsulate it. (define (with-out u) (if (or (mce? u) (and (ugen? u) (not (null? (ugen-outputs u))))) (letc ((bus 0.0)) (Out bus u)) u)) (define (send-synth s n u) (->< s (/d_recv (encode-graphdef (synthdef n (with-out u)))))) (define (ugen->graphdef/out u) (synthdef "Anonymous" (with-out u))) ;; A large positive integer that can be used as an argument to ;; synthdefs. (define inf.sc 9.0e8) )