Topic
SuperColliderCommon Music supports the writing and rendering of non-realtime SuperCollider files. Support for running in real-time is currently in progress.
SuperCollider synth objects are defined similarly to clm or csound instruments.
To begin, let's look at a fairly simple synthdef in SuperCollider.
( SynthDef("simple", {arg dur=1.0,freq=440.0,amp=0.2,pan=0.0; var osc; osc = EnvGen.kr(Env.triangle(dur,amp), doneAction: 2) * SinOsc.ar(freq); Out.ar(0,Pan2.ar(osc,pan)); }).writeDefFile.load(s); )
Defining a CM scsynth object to generate data for
this instrument is straightforward:
(defobject simple (scsynth) ((freq :initform 440) (dur :initform 1) (amp :initform .2) (pan :initform 0)) (:parameters freq dur amp pan))
The object is a subclass of the abstract class scsynth which contains additional slots that will be introduced below.
All arguments to the synthdef are used in the object definition of simple. The name of the slots are always treated as lowercase strings when written to an .osc file. This is important because if you have defined arguments to your synthdef which are mixed case or uppercase (e.g. "Dur" "DUR") things will not work properly.
In addition to user defined slots, all scsynth objects inherit the following slot initargs:
:node number:add-action number:target number:time numberTo send an envelope to a scsynth, one must typically use node-setn. Instead it is also possible to
use an sc-env when creating a new instance of s scsynth. Here is a simple example in SC:
( SynthDef("simple-env", {arg dur=1.0,freq=440.0,amp=0.2,pan=0.0; var osc,ampenv; ampenv = Env.newClear(8); ampf = Control.names([\ampenv]).kr( ampenv.asArray ); osc = EnvGen.kr(ampf, levelScale: amp, doneAction: 2) * SinOsc.ar(freq); Out.ar(0,Pan2.ar(osc,pan)); }).writeDefFile.load(s); )
This is the corresponding defobject in cm.
(defobject simple-env (scsynth)
((freq :initform 440)
(dur :initform 1)
(amp :initform .2)
(ampenv :initform #f)
(pan :initform 0))
(:parameters freq dur amp ampenv pan))
Now a sc-env can be used in the creation of a new instance of simple-env.
(new simple-env :time (now) :freq (between 300 700) :dur (between 10 20) :node (+ i 1000) :amp .1 :ampenv (new sc-env :envelope '(0 0.0 10 1.0 80 .5 100 0.0) :duration 10) :pan 1.0)
Class
:envelope list:duration number:curve {keyword | list | number}:linear :lin :exp :exponential :step :sine :welch.:scale number:offset number:release-node number:loop-node number(new sc-env :envelope'(0 0.0 10 1.0 80 .5 100 0.0) :duration 10) (new sc-env :envelope'(0 0.0 10 1.0 80 .5 100 0.0):duration 10 :curve :exp) (new sc-env :envelope'(0 0.0 10 1.0 80 .5 100 0.0):duration 10 :curve '(:exp -1.4 :welch))
Class
Instead of using different commands for creating buffers, sc-buffer attempts to encapsulate some of the most commonly
used buffer creation/filling methods into one cm event.
:bufnum number:with-file string:with-values {function | list | number}:with-values. If a number, fills buffer with that value. If a list, will set buffer to those values.
If a function will call this function for as many frames as are in the buffer minus :starting-at.:with-gen list:starting-at number:frames number:with-file defaults to reading in the entire file:channels number:time number(new sc-buffer :with-gen'(:sine1 (1.0 .2 .1 .01)) :frames 512 :time (now)) (new sc-buffer :with-file "/Applications/SuperCollider3/sounds/a11wlk01.wav":time (now)) (new sc-buffer :with-values .2 :time (now)) (new sc-buffer :with-values (lambda () (ran :from -1.0 :below 1.0)) :time (now))
load-synthdefload-synthdef-dirnode-freenode-runnode-setnode-setnnode-fillnode-mapnode-mapnnode-beforenode-afternode-querysynth-getsynth-getngroup-newgroup-headgroup-tailgroup-free-allgroup-deep-freeugen-commandbuffer-allocbuffer-alloc-readbuffer-readbuffer-writebuffer-freebuffer-zerobuffer-setbuffer-setnbuffer-fillbuffer-closebuffer-getbuffer-getnbuffer-gencontrol-setcontrol-setncontrol-fillcontrol-getcontrol-getnAll SuperCollider command events contain the :time slot inherited
from event.
For a description of the following commands, refer to Help/Server-Command-Reference.rtf in the SuperCollider distribution
Most of these events work with in both realtime and non-realtime mode unless otherwise noted.
Class
:path stringClass
:path stringClass
:node {number | list}Class
:node {number | list}:flag {boolean | list}(new node-run :node 1000 :flag #t :time (now)) (new node-run :node '(1000 1001 1003) :flag '(#t #f #t) :time (now))
Class
:node number:controls-values listClass
:node number:controls-values listClass
:node number:control {keyword | list}:num-controls number:value number(new node-fill :node 1000 :control :freq :num-controls 2 :value 100.1 :time (now)) (new node-fill :node 1000 :control '(:freq01 :freq20) :num-controls '(2 4) :value '(100.1 20.22) :time (now))
Class
:node number:controls-buses listClass
:node number:control {keyword | list}:bus {number | list}:bus {number | list}(new node-mapn :node 1000 :control :freq :bus 100 :num-controls 2 :time (now)) (new node-mapn :node 1000 :control '(:freq1 :freq100) :bus '(100 200) :num-controls '(12 24) :time (now))
Class
:node number:before number(new node-before :node 1001 :before 1000 :time (now)) (new node-before :node '(1001 200) :before '(1000 500) :time (now))
Class
:node number:after number:node after.(new node-after :node 1000 :after 1001 :time (now)) (new node-after :node '(1001 200) :before '(1000 500) :time (now))
Class
:node {number | list}Class
:node number:controls {number | string | list}(new synth-get :node 1000 :controls "freq":time (now)) (new synth-get :node '(1000 1001) :controls '(("freq" "amp") ("freq" "duration")) :time (now))
Class
:node number:controls {number | string | list}:num-controls numberClass
:id number or list:add-action {number | list}:target {number | list}:add-action slot.; adds a new group with id 2 just before node 1000 (new group-new :id 2 :add-action 2 :target 1000) (new group-new :id '(2 3) :add-action '(2 1) :target '(1000 900))
Class
:group {number | list}:node to the head of.:node {number | list}(new group-head :group 2 :node 2000 :time (now)) (new group-head :group '(2 10) :node '(2000 3000) :time (now))
Class
:group {number | list}:node to the tail of.:node {number | list}:group.(new group-tail :group 2 :node 2000 :time (now)) (new group-tail :group '(2 10) :node '(2000 3000) :time (now))
Class
:group {number | list}Class
:group {number | list}Class
:node number:ugen-index number:command-name string:args listClass
:bufnum number:frames number:channels numberClass
:bufnum number:file string:start-frame number:frames number(new buffer-alloc-read :bufnum 10 :file "/Applications/SuperCollider3/sounds/a11wlk01.wav" :time (now))
Class
:bufnum number:file string:start-frame number:frames number:buffer-start-frame number:leave-open? {true | false}Class
:bufnum number:file string:header {:aiff | :next | :wav | :ircam | :raw}:format {:int8 | :int16 | :int24 | :int32 | :float | :double | :mulaw | :alaw}:frames number:start-frame number:leave-open? boolean(new buffer-write :bufnum 10 :file "/path/to/file.aiff" :header :aiff :format :float)
Class
:bufnum numberClass
:bufnum numberClass
:bufnum number:samples-values listClass
:bufnum number:samples-values listClass
:bufnum number:start-sample {number | list}:num-samples number or list :value{number | list}(new buffer-fill :bufnum 10 :start-sample 0 :num-samples 10 :value .8 :time (now)) (new buffer-fill :bufnum 10 :start-sample '(0 256) :num-samples '(10 20) :value '(.8 .2) :time (now))
Class
:bufnum numberClass
:bufnum number:command { :sine1 | :sine2 | :sine3 | :cheby }:flags keyword or list. possible values :normalize :wavetable :clear:args listClass
:bufnum number:samples {number | list}(new buffer-get :buffer 10 :samples 1 :time (now)) (new buffer-get :buffer 10 :samples '(1 3 5 7) :time (now))
Class
:bufnum number:samples {number | list}:num-samples number(new buffer-getn :bufnum 10 :samples 0 :num-samples 36 :time (now)) (new buffer-getn :bufnum 10 :samples '(0 128) :num-samples '(36 48) :time (now))
Class
:bus {number | list}:value {number | list}(new control-set :bus 2 :value 2.0 :time (now)) (new control-set :bus '(2 3 4) :value '(.4 .9 1.2) :time (now))
Class
:bus {number | list}:value {number | list}(new control-setn :bus 2 :value '(2.0 3.0 .2) :time (now)) (new control-setn :bus '(2 9) :value '((.1 .2 .3) (1.7 1.9 1.01)) :time (now))
Class
:bus number:num-buses number:value number(new control-fill :num-buses 2)
Class
:bus {number | list}Class
:bus {number | list}:num-buses {number | list}(new control-getn :bus 10 :num-buses 36 :time (now)) (new control-getn :bus '(1 20) :num-buses '(3 8) :time (now))
;; Using node-set to produce continuous changes in panning. ;;; define a scsynth object (defobject simple (scsynth) ((freq :initform 440) (dur :initform 1) (amp :initform .2) (pan :initform 0)) (:parameters freq dur amp pan time)) ;;; define a process to generate simples. (define (sc-simple-3 num) (process repeat num for i from 0 output (new simple :time (now) :freq (between 300 700) :dur (between 10 20) :node (+ i 1000) :amp .1 :pan 1.0) sprout (process repeat 100 for j from 0 with node = (+ i 1000) with pan-env = '(0 1.0 50 .4 100 -1.0) output (new node-set :node node :controls-values (list :pan (interpl j pan-env)) :time (now)) wait .1) wait (between 2 3))) (events (sc-simple-3 10) "sc-simple-3.osc" :pad 20) ⇒ "sc-simple-3.osc" (define *sc* (sc-open)) (rts (sc-simple-3 10) *sc* )
(sc-open [args] )Opens a sc-stream called "sc.udp" according to the keyword initialization args passed to the stream.
(sc-open?)Tests to see if "sc.udp" has already been opened.
(sc-close [args] )Closes the sc-stream called "sc.udp" if it is open, otherwise has no effect.
(sc-quit [sc-stream] )Sends a quit message to scsynth listening on "sc.udp" if opened or optional sc-stream.
(sc-dumposc boolean
[sc-stream] )Sends a dumpOSC message to scsynth listening on "sc.udp" if opened or optional sc-stream. If boolean is true turns on osc dumping. If false turns it off.
(sc-clearsched [sc-stream] )Sends a clearSched message to scsynth listening on "sc.udp" if opened or optional sc-stream.
(sc-notify
boolean [sc-stream] )
(sc-flush [sc-stream] )Sends a clearSched and a group-free-all message to scsynth listening on "sc.udp" if opened or optional sc-stream.
The file sc.cm contains numerous examples of Supercollider score generation. The file sc-rt.cm contain examples of generating Supercollider events in realtime.
done-replyfail-replystatus-replysynced-replysynth-get-replysynth-getn-replybuffer-get-replybuffer-getn-replybuffer-query-replycontrol-get-replycontrol-getn-replynode-go-replynode-end-replynode-off-replynode-on-replynode-move-replynode-info-replytrigger-replyClass
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class
Class