Menu

Language-process

Jan

SoundComp language: Process

The description of a process, i.e. a network of process elements, determines how a voice that employs this process for sound generation, sounds.

This description shows how a network of elements, each doing some mostly mathematical operation on a number of signals, is interconnected.
Each process element has a number of inputs and a number of outputs. In general, each input and output has its unique semantics and is
unambiguously identified by its name.

The general structure of a process definition is:

process <name> { inputs <inputassignments> variables <variableslist> processes { processlist } outputs <outputlist> }

where

  • <name> is the name with which a process can be referred to later on
  • inputassignments is a list of assignments that define data input connections from other processes. Each assignment is of the form <internalname> = <formula> where the formula consists of calculation operators, numeric constants and outputs from previously defined processes
  • variableslist is a list of terms that define variables, that is, holders of a numeric state for one sample (as a means to prevent having to do the same calculation multiple times). Each variable is defined in the form <name> = <formula>
  • processlist is a list of subprocesses (elementary or composed) that form this process. Each subprocess is written in one of these forms:
    • processref <name> as <name2> calls an external process under an internal name. The internal name makes it possible to identify multiple instances of the same kind of process
    • processref <name> as <name2> { inputassignments } the same for a subprocess that needs input connections
    • <inputlessprimitiveelement> as <name> the same for primitive elements that don't have input connections
    • <primitiveelement> as <name> { inputassignments } the same for a primitive element (like a generator or other primitive signal processor) instead of a user defined process, with data input for the primitives
    • in as <name> { "text1" , "text2" } for future reference when we allow real time hardware input
  • outputlist is a list of names that define outputs of this process (that can be used as input for other processes) and the formulas that create the output data, in the form <name> = <formula> where <formula> only references internal variables, subprocess outputs and inputs to this process

Process definitions is the part of the language with the largest - and still growing - number of terminal symbols, most of them representing a certain kind of mathematical operation:

Numbers can usually be floating point numbers with a period as decimal separator. No grouping symbol can be used.

Usual mathematical operators are:
+ - * / ^ = > < >= <= != <> ( )
in their usual meaning (^ being the "power" symbol).

generators:
sine, cosine, sawtooth, unitysawtooth, pwm, bwlpwm, bwlsawtooth, whitenoise, pinknoise:

These terminals denote signal generators. Signal generators create a certain basic "waveform" signal which the name aims to describe; there are inputs for
frequency (how fast does the generator oscillate)
phase offset (for popular effects like "FM synthesis" that in most cases are misnamed "phase distortion" effects)
synchronization (phase reset on a 0->1 transition; some generators fix the phase as long as synchronization stays active)
synchronization phase (the phase that the signal is set to when a synchronization occurs)
asymmetry/duty cycle: some generators allow to make the signal appear asymmetric, the input ranges from 0 to 1, 0.5 being the symmetric case. Note that the phase offset can influence the behaviour.
Not all signal generators support all inputs.
The generators create the following signals:
sine: a simple sine generator with a single output
cosine: a dual phase sine generator with an additional output phase shifted by pi/2.
sawtooth: A signal rising linearly from -1 to 1, then suddenly falling back to -1
unitysawtooth: a signal rising linearly from 0 to 1, then suddenly falling back to 0
pwm: a signal jumping back and forth between 0 and 1
whitenoise: a noise signal with a strong emphasis on high frequencies
pinknoise: a noise signal without a strong emphasis on high frequencies
bwlpwm, bwlsawtooth: bandwidth limited versions of pwm and sawtooth: Bandwidth limiting applies already within the signal generation, thereby avoiding a large portion of aliasing frequencies. These tend to sound "clearer" than the unlimited and thereby aliasing variants.
soundbank (not yet implemented): a generator that creates signals from input files, changing the pitch via tdhs or PSOLA

envelope:
An envelope generator (the well known ADSR generator). Inputs are:
attack (speed)
decay (speed)
sustain (level 0-1)
release (speed)
* gate (binary signal)
More complex envelopes can be generated by combining multiple ADSR signals through delay/addition/multiplication.
Envelopes are usually used to modulate the signal, either by simple multiplication (amplitude modification), or by using the envelope level to achieve some other kind of manipulation, for example a filter edge frequency.
A rather strange but valid way to use an envelope generator would be to take a PWM sound as a source (on the gate) and use the envelope generator (with unusally short attack, decay, release times) to distort the PWM signal.

Mathematical constants:
pi, e, NaN, samplerate
* sometimes in formulas you might need to refer to natural constants, create an invalid number or refer to the global sample rate.

Mathematical functions:

sin, asin, sinh, cos, acos, cosh, tan, atan, tanh, exp, log2, log10, log, sqrt, sign, int, round:
The set of trigonometric functions is a little redundant, to ease using them.
Note that "sin" is a mathematical function which takes exactly one nameless parameter, whereas "sine" is a signal generator with larger set of named parameters and an internal state. The same applies to other similar symbols as well, don't mess them up.
The decimal number after a logarithm indicates the base; log without a number means natural logarithm.

Signal shapers:
third, clip, (envelope as described above), aliaser, quantizer

  • third: the signal input is usually ranging from -1 to 1, the output is a third order function applied on the signal input. A control input can adjust the nonlinearity.
  • clip: has a signal input and two control inputs that supply upper and lower limits for the signal. The output is the input signal limited to being between the lower and hihger control input.
  • aliaser: has a signal and a frequency input. The output is the input, as if being sampled by approximately the sample rate given at the control input. This deliberately creates strong frequency aliasing components.
  • quantizer: has a signal and a "step" input. The output reflects the input, rounded to integer multiples of the control input, as if sampled with a much lower bit resolution.

Filters:
pinkfilter: A filter with a good approximation of a 3dB/octave low pass response over almost the whole audible range. Used in pinknoise to create pink from white noise, but can also be used separately.
svf: a state variable filter: has a signal input, an edge frequency control input, a Q factor input. Separate outputs for band pass, low pass, high pass.
parametricallpass: an all pass variant with signal, Q and edge frequency input. Can be used to create low pass, high pass, band pass, notch filters by different linear combinations with the input signal.
pseudohilbert: a filter with an almost constant amplitude response and a phase shift of 90 degreees. Usually used in kinds of "trigonometric trickery"

Other signal manipulators:
freqshift: shift all frequencies by a constant frequency offset
tdhs: shift all frequencies by a constant factor
PSOLA (not yet implemented): shift all frequencies by a constant factor (alternative algorithm)
flanger (not yet implemented)
phaser (not yet implemented)
chorus (not yet implemented)

Besides these terminals, the names of inputs can be used; in addition, the outputs of subprocesses can be referred to in the form
<subprocessname>.<outputname>


Related

Wiki: Language

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.