View Source SuperCollider.SynthDef (SuperCollider v0.1.0)

The SynthDef is module and struct for SuperCollider Synthesis Definitions.

The SynthDef struct contains the:

  • the name of the synth definition
  • number of constants
  • list of constant values
  • number of parameters
  • [float32] * P - initial parameter values
  • number of parameter names
  • list of named parameters and their index
  • number of unit generators (UGens)
  • list of UGens (using the %SuperCollider.SynthDef.UGen{} struct)
  • number of variants
  • list of named varient specs (named key-value pairs with the value as a float.)

The module includes: *

  • parser code for synthgens.

Link to this section Summary

Functions

Encodes SynthDefs into SuperCollider's binary format.

Parses a SuperCollider .scynthdef binary file into an%ScFile{} struct.

Defines a new SynthDef.

Parses syndef binary data. This function is not usually called directly, but is automatically called as part of ScFile.parse(filename).

Encodes one or more %SynthDef{} into SuperCollider's binary file format.

Link to this section Functions

Encodes SynthDefs into SuperCollider's binary format.

It takes as its first parameter either a list of %SynthDef{} or an individual %SynthDef{}.

This function is not usually called directly, but is automatically called as part of SuperCollider.SynthDef.ScFile.encode(synthdef).

Parses a SuperCollider .scynthdef binary file into an%ScFile{} struct.

This function is similar to SuperCollider.SynthDef.ScFile.parse/1 except this function will only return the list of %SyntDef{}'s contained in the file, and not any of the other file metadata.

Defines a new SynthDef.

A SynthDef conisits of the following

  • name (of synthdef)
  • constants
  • parameters
  • parameter names
  • UGen specs
  • varient specs

example

Example

synthdef = SynthDef.new("example", fn (params) ->
     freq = params.named("name", 440.0); # index 0
     vol = params.named("vol", 1.0); # index 1
     ugen::Out::ar().channels(ugen::SinOsc::ar().freq(freq).mul(vol))
    end);

Parses syndef binary data. This function is not usually called directly, but is automatically called as part of ScFile.parse(filename).

Parsing of the SynthDef is in the follwoing order:

  • name (of synthdef)
  • constants
  • parameters
  • parameter names
  • UGen specs
  • varient specs.

Returns a tuple in the format {%SynthDef{}, binary_data}. binary_data should be empty if all data was successfully parsed.

Encodes one or more %SynthDef{} into SuperCollider's binary file format.

This function is the same as SuperCollider.SynthDef.ScFile.encode/1.