1 title:: Server Architecture
2 summary:: SuperCollider 3 Synth Server Architecture
3 categories:: Server>Architecture
5 copyright © 2002 James McCartney
6 note:: Converted to new help system 2010 by Jonatan Liljedahl. Some stuff in this doc are outdated. ::
10 The SuperCollider 3 Synth Server is a simple but powerful synthesis engine. While synthesis is running, new modules can be created, destroyed and repatched, sample buffers can be created and reallocated. Effects processes can be created and patched into a signal flow dynamically at scheduled times. All running modules are ordered in a tree of nodes that define an order of execution. Patching between modules is done through global audio and control buses.
12 All commands are received via TCP or UDP using a simplified version of link::Browse#OpenSoundControl#Open Sound Control:: (OSC). The synth server and its client(s) may be on the same machine or across a network. The synth server does not send or receive MIDI. It is expected that the client will send all control commands. If MIDI is desired, it is up to the client to receive it and convert it to appropriate OSC commands for the synth engine.
14 Synth definitions are stored in files generated by the SuperCollider language application. Unit generator definitions are Mach-O bundles (not to be confused with CFBundles). The Unit generator API is a simple C interface.
16 section:: Main Design Concepts
19 A Node is an addressable node in a tree of nodes run by the synth engine. There are two types, Synths and Groups. The tree defines the order of execution of all Synths. All nodes have an integer ID.
22 A Group is a collection of Nodes represented as a linked list. A new Node may be added to the head or tail of the group. The Nodes within a Group may be controlled together. The Nodes in a Group may be both Synths and other Groups. At startup there is a top level group with an ID of zero that defines the root of the tree. If the server was booted from within SCLang (as opposed to from the command line) there will also be a 'default group' with an ID of 1 which is the default target for all new Nodes. See link::Classes/RootNode:: and link::Reference/default_group:: for more info.
25 A Synth is a collection of unit generators that run together. They can be addressed and controlled by commands to the synthesis engine. They read input and write output to global audio and control buses. Synths can have their own local controls that are set via commands to the server.
27 subsection:: Synth Definition
28 Synths are created from Synth Definitions. Synth Definition files are created by the SuperCollider language application and are loaded into the synth server. Synth Definitions are referred to by name.
30 subsection:: Audio Buses
31 Synths send audio signals to each other via a single global array of audio buses. Audio buses are indexed by integers beginning with zero. Using buses rather than connecting synths to each other directly allows synths to connect themselves to the community of other synths without having to know anything about them specifically. The lowest numbered buses get written to the audio hardware outputs. Immediately following the output buses are the input buses, read from the audio hardware inputs. The number of bus channels defined as inputs and outputs do not have to match that of the hardware.
33 subsection:: Control Buses
34 Synths can send control signals to each other via a single global array of control buses. Buses are indexed by integers beginning with zero.
36 subsection:: Shared Control Buses
37 The internal server (which runs within the same address space as the client app) also has a number of shared control buses to which the client app has synchronous read/write access. These buses are indexed by integers beginning with zero.
40 Buffers are arrays of 32 bit floating point values with a small descriptive header. Buffers are stored in a single global array indexed by integers beginning with zero. Buffers may be safely allocated, loaded and freed while synthesis is running, even while unit generators are using them. Buffers are used for wave tables, sample buffers, delay lines, envelopes, or for any other need which can use an array of floating point values. Sound files may be loaded into or written from buffers.
42 subsection:: Unit Generator Definitions
43 Unit Generator Definitions are plug-ins loaded automatically when the program starts. They are binary code libraries that are used as building blocks by Synths to build synthesis algorithms. Unit Generator Definitions have names that match the names of SuperCollider language classes used in building Synth Definitions.
46 section:: Command Line Arguments
48 One of -u or -t must be supplied. Both may be supplied.
51 || a port number 0-65535.
54 || a port number 0-65535
57 || Controls the verbosity of server messages. A value of 0 is normal behaviour, -1 suppresses informational messages, and -2 suppresses informational and many error messages.
59 ## -a num-audio-bus-channels
60 || number of audio bus channels (default = 128). The space allocated for audio buses is: (numchannels * (blocksize + 1) * 4)
62 ## -i num-input-bus-channels
63 || number of audio input bus channels (default = 8)
65 ## -o num-output-bus-channels
66 || number of audio output bus channels (default = 8)
68 ## -c num-control-bus-channels
69 || number of control bus channels (default = 4096). The space allocated for control buses is: (numchannels * 8)
72 || number of sample buffers (default = 1024)
75 || maximum number of nodes (default = 1024)
78 || maximum number of synth definitions (default = 1024)
81 || if zero, then synth definitions will not be loaded on start up. (default = 1)
84 || The number of samples in one control period. (default = 64)
86 ## -Z preferred-hardware-buffer-size
87 || If non-zero, it will attempt to set the hardware buffer frame size. (default = 0)
89 ## -S preferred-sample-rate
90 || If non-zero, it will attempt to set the hardware sample rate. (default = 0)
92 ## -m real-time-memory-size
93 || The number of kilobytes of real time memory. This memory is used to allocate synths and any memory that unit generators themselves allocate. (default = 8192)
95 ## -r random-number-generators
96 || The number of seedable random number generators. (default = 64)
98 ## -w max-interconnect-buffers
99 || The maximum number of buffers that are allocated for buffers to interconnect unit generators. Sets the limit of complexity of synth defs that can be loaded at runtime. This value will be increased if a more complex synth-def is loaded at start up time, but it cannot be increased once synthesis has begun. (default = 64)
102 || maximum number of named return addresses stored (default = 64). also maximum number of tcp connections accepted
104 ## -p session-password
105 || When using TCP, the session password must be the first command sent. The default is no password. UDP ports never require passwords, so if password protection is desired, use TCP.
108 || name of the hardware I/O device. If not provided, the default device is used.
110 ## -I input-streams-enable-string
111 || Allows turning off input streams that you are not interested in on the device. If the string is 01100, for example, then only the second and third input streams on the device will be enabled. Turning off streams can reduce CPU load.
113 ## -O output-streams-enable-string
114 || Allows turning off output streams that you are not interested in on the device. If the string is 11000, for example, then only the first two output streams on the device will be enabled. Turning off streams can reduce CPU load.
116 ## -N cmd-filename input-filename output-filename sample-rate header-format sample-format
117 || Run in non-real-time mode.
119 The cmd-filename should be a file that contains OSC bundles sorted in ascending time order. If cmd-filename is the underscore character _, then OSC will be streamed from standard input.
121 The audio input will taken from input-filename. If input-filename is the underscore character _, then no input file will be read.
123 Output will be written to output-filename.
125 The output file's sample rate is specified by sample-rate. The output file header-format should be one of: AIFF, WAVE, NeXT. The output file sample-format should be one of: int16, int24, int32, float, double. The number of channels in the output file is specified with the -o argument.
130 scscynth -u 57117 >synth_log &
132 Accept commands via UDP on port 57117.
133 Send output to file "synth_log"
134 Run asynchronously: &.
136 scsynth -N score.osc _ out.aiff 48000 AIFF int24
138 Run in non real time mode with command file score.osc,
139 no input file, and output file named out.aiff.
140 Sample rate is 48000. Output file header format is aiff,
141 sample format is 24 bit integer.
144 section:: Binary Format of Messages
146 Messages are similar in format to Open Sound Control messages, except that OSC #bundles may not be nested, and pattern matching of the command name is not performed. When streamed via TCP, Messages are each preceeded by a 32 bit integer giving the length in bytes of the message. UDP datagrams contain this length information already.
149 All values are in network byte order.
151 ## long || a 64 bit integer. Used for time stamps only.
152 ## int || a 32 bit integer.
153 ## float || a 32 bit single precision floating point number.
154 ## double || a 64 bit double precision floating point number.
155 ## string || a string of 8 bit ASCII characters, zero padded to a multiple of 4 bytes.
156 ## bytes || a buffer of data preceeded by a 32 bit length field and padded to a multiple of 4 bytes.
160 Command arguments have single character tags which occur in a tag string to identify their types.
169 a Command consists of:
171 ## string || the command name. See the Command Reference below.
172 ## string || a string with tags defined by the types of the arguments to follow. The tag string begins with a comma ',' character.
173 ## ... || any combination of arguments of types: int, float, string or bytes.
177 a Bundle consists of:
179 ## time stamp || long. Time stamps are in the same format as defined by Open Sound Control : The top 32 bits are seconds since 1900 and the lower 32 bits represent the 32 bit fraction of one second.
180 ## ... || a series of Commands each preceded by a 32-bit integer byte length.
184 a Message consists of:
189 ## one Bundle or one Command.
193 ## int - the length in bytes of the following message.
194 ## one Bundle or one Command.
200 ## buffer || a header and array of floating point sample data. Buffers are used for sound files, delay lines, arrays of global controls, and arrays of inter-synth patch points.
202 ## group || a linked list of nodes. groups provide ways to control execution of many nodes at once. a group is a kind of node.
204 ## MIDI || a protocol for sending music control data between synthesizers.
206 ## node || an object in a tree of objects executed in a depth first traversal order by the synth engine. There are two types of nodes, synths and groups.
208 ## Open Sound Control || a protocol defined by CNMAT at UCBerkeley for controlling synthesizers. See http://cnmat.cnmat.berkeley.edu/OSC/ .
210 ## OSC || see Open Sound Control.
212 ## synth || a sound processing module. Similar to "voice " in other systems. Synths are referred to by a number.
214 ## synth definition || a definition for creating new synths. similar to "instrument" in other systems.
216 ## TCP || a protocol for streaming data over a network.
218 ## UDP || a protocol for sending datagrams over a network.