SuperCollider 3 Synth Server Architecture


copyright © 2002 James McCartney


Introduction


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. 


All commands are received via TCP or UDP using a simplified version of 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.


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.




Main Design Concepts


Node

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.


Group

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 RootNode and default_group for more info.


Synth

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.


Synth Definition

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.


Audio Buses

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.


Control Buses

Synths can send control signals to each other via a single global array of control buses.  Buses are indexed by integers beginning with zero.


Shared Control Buses

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.


Buffers

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.


Unit Generator Definitions

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. 




Command Line Arguments


One of -u or -t must be supplied. Both may be supplied.

-u udp-port-number

a port number 0-65535. 

-t tcp-port-number

a port number 0-65535

-v verbosity

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.

-a num-audio-bus-channels

number of audio bus channels (default = 128).

The space allocated for audio buses is: (numchannels * (blocksize + 1) * 4)

-i num-input-bus-channels

number of audio input bus channels (default = 8)

-o num-output-bus-channels

number of audio output bus channels (default = 8)

-c num-control-bus-channels

number of control bus channels (default = 4096)

The space allocated for control buses is: (numchannels * 8)

-b num-buffers

number of sample buffers (default = 1024)

-n max-nodes

maximum number of nodes (default = 1024)

-d max-synth-defs

maximum number of synth definitions (default = 1024)

-D 1 or 0

if zero, then synth definitions will not be loaded on start up. (default = 1)

-z block-size

The number of samples in one control period. (default = 64)

-Z preferred-hardware-buffer-size

If non-zero, it will attempt to set the hardware buffer frame size. (default = 0)

-S preferred-sample-rate

If non-zero, it will attempt to set the hardware sample rate. (default = 0)

-m real-time-memory-size

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)

-r random-number-generators

The number of seedable random number generators. (default = 64)

-w max-interconnect-buffers

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)

-l max-logins

maximum number of named return addresses stored (default = 64)

also maximum number of tcp connections accepted

-p session-password

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.


-H device-name

name of the hardware I/O device. If not provided, the default device is used.

-I input-streams-enable-string

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.


-O output-streams-enable-string

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.

-N cmd-filename input-filename output-filename sample-rate header-format sample-format


Run in non-real-time mode. 

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.

The audio input will taken from input-filename. 

If input-filename is the underscore character _, then no input file will be read. 

Output will be written to output-filename.

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.



example:


scscynth -u 57117 >synth_log &

Accept commands via UDP on port 57117. 

Send output to file "synth_log"

Run asynchronously: &.


scsynth -N score.osc _ out.aiff 48000 AIFF int24 

Run in non real time mode with command file score.osc, no input file, and output file named out.aiff. Sample rate is 48000. Output file header format is aiff, sample format is 24 bit integer.


Binary Format of Messages


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.


Types:

All values are in network byte order.

long - a 64 bit integer. Used for time stamps only.

int - a 32 bit integer.

float - a 32 bit single precision floating point number.

double - a 64 bit double precision floating point number.

string - a string of 8 bit ASCII characters, zero padded to a multiple of 4 bytes.

bytes - a buffer of data preceeded by a 32 bit length field and padded to a multiple of 4 bytes. 


Tags:

Command arguments have single character tags which occur in a tag string to identify their types.

'i' - an int.

'f' - a float

's' - a string

'b' - bytes


a Command consists of:

string - the command name. See the Command Reference below.

string - a string with tags defined by the types of the arguments to follow. 

The tag string begins with a comma ',' character.

...any combination of arguments of types: int, float, string or bytes.


a Bundle consists of:

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.

...a series of Commands each preceded by a 32-bit integer byte length.

a Message consists of:

using UDP : 

one Bundle or one Command.

using TCP : 

int - the length in bytes of the following message.

one Bundle or one Command.




Glossary


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.


group - a linked list of nodes. groups provide ways to control execution of many nodes at once. a group is a kind of node.


MIDI - a protocol for sending music control data between synthesizers.


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.


Open Sound Control - a protocol defined by CNMAT at UCBerkeley for controlling synthesizers. See http://cnmat.cnmat.berkeley.edu/OSC/ .


OSC - see Open Sound Control.


synth - a sound processing module. Similar to "voice " in other systems. Synths are referred to by a number.


synth definition - a definition for creating new synths. similar to "instrument" in other systems.


TCP - a protocol for streaming data over a network.


UDP - a protocol for sending datagrams over a network.


copyright © 2002 James McCartney