Chapter Four: Synthesis

14. A Digital Synthesis Language Sampler | Page 6

Audio Rate, Control Rate and Buffer Size

Many synthesis languages maximize their computational efficiency by providing two separate sampling rate resolutions, often called audio rate and control rate.  Certain signals, such as those we will hear as audio from an oscillator or a signal mixing function need to computed at the project’s maximum sampling rate, called audio rate, to avoid aliasing and noise.  However, many other signals, such as those used for envelopes, can be computed at much lower rates without cause serious degradation to the ultimate audio output.  That rate is usually called the control rate

Csound sets both the audio rate, called a-rate (sr) and the control rate, called k-rate (kr) in the first part of the orchestra definition, called the header. A csound typical header looks like this:

sr = 44100
kr = 4410
ksmps = 10
nchnls = 2

This header declares the audio sampling rate sr to be 44,100 cps, the control rate kr to be 4410.  Ksmps always struck me as a math test, because it needs to be sr/kr, and indicates the number of audio samples per control sample.  Nchnls indicates the number of audio channels of the project, so this one is stereo.  Users can choose which rate a particular parameter should use by beginning a variable name with an a for audio rate (such as afreq) or a k for control rate (such as kfreq), a particularly important choice for those variables that serve to store a signal rather than a constant. Typical control-rate statements like envelopes for amplitude will have a stairstep or zipper effect on an audio signal they may be multiplied with, but if the control rate is high enough, this normally is undetectable.

Below, the two csound statements both use the oscil oscillator opcode, but the top is computed at audio rate, the bottom at control rate. Perhaps the bottom oscil statement would be used for sub-audio rate amplitude modulation (tremolo) and not need audio-rate computation.

avar oscil 2000, 440, 1; compute this oscillator output at audio rate
kvar oscil 50, 20, 1; compute this oscillator output at control rate

Csound also uses i-rate variables for values computed only once at the beginning of each note event.

MAX has a related setting in its Options->Audio Status window [show image here], where the audio sampling rate is set, but one can also set the input/output block sizes of samples MAX uses, and the signal vector size, the number of samples MAX processes at one time.  These are called buffer sizes.

MAX vector control
MAX buffer control

MAX has a related setting in its Options->Audio Status window, where the audio sampling rate is set, but one can also set the input/output block sizes of samples MAX uses, and the signal vector size, the number of samples MAX processes at one time.  These are called buffer sizes. This gives the user the ability to balance I/O latency with audio performance should glitching occur.

While MAX non-audio-rate objects are normally processed at a 1 millisecond incremented control rate, the user can choose between those that need to be computed at audio rate vs. those that don’t by using objects whose names end in a tilde (~) for audio rate or non-tilde for control rate objects.  For example, use [line~] when audio rate is needed to read though a sampled function table like [buffer~] or use [line] to create an amplitude envelope when audio rate is not needed.  Back in the day, when the application was called MAX/MSP after the addition of audio, the MAX objects were calculated at the control rate and the MSP [Max signal processing] were computed at audio rate and distinguished by their tilde (~).