home/ atoms/ sc-ugens-audio-rate-vs-control-rate

UGens run at audio rate (.ar) or control rate (.kr), trading CPU for update resolution; only .ar signals reach the speakers

Every UGen is instantiated by sending it .ar (audio rate) or .kr (control rate). An audio-rate UGen computes one value per output sample — typically 44,100 per second — and can be sent to audio output. A control-rate UGen computes a single value per control block (block size 64 samples by default), yielding about 689 values/sec at 1/64th the CPU cost. Control-rate output does not go to the loudspeaker; it modulates parameters of other UGens, and a .kr signal feeding an .ar input is smoothly interpolated by SC. The convention: use .ar for audible signals (oscillators, filters) and .kr for slow-moving controls (LFOs, envelopes), and mix them freely — a .kr LFO can modulate an .ar oscillator. Almost every UGen also takes mul and add (which scale then offset the output and may themselves be signals), making modulation connections concise. The .poll method samples any UGen’s output ~10 times/sec into the Post window for inspection. Choosing .kr where resolution is not needed can save large amounts of CPU across many voices; audio-rate signals are kept only where per-sample accuracy matters.

Examples

{SinOsc.ar(440)}.play;                 // audio → speaker
{SinOsc.kr(1).poll}.play;              // control → Post window only, no sound
{SinOsc.ar(freq: MouseX.kr(300,2500), mul:0.1)}.play; // .kr controlling .ar
{ SinOsc.ar(LFNoise1.kr(4).range(200,800), 0, 0.3) }.play; // kr LFO on ar osc

Assessment

Explain why {SinOsc.kr(440)}.play makes no audible sound and give the approximate sample rate of a control-rate UGen. For each case say .ar or .kr: an oscillator heard as a tone; a slow LFO on filter cutoff; mouse position controlling frequency. Then name one case where an LFO must run at .ar for correctness.

“Aunitgeneratoriscreatedbysendingthearorkrmessagetotheunitgen- erator'sclassob ject.Thearmessagecreatesaunitgeneratorthatrunsataudio rate.Thekrmessagecreatesaunitgeneratorthatrunsatcontrolrate.”
corpus · a-gentle-introduction-to-supercollider-bruno-ruviaro · chunk 10
“Thearmessage creates a unit generator that runs at audio rate. The krmessage creates a unit generator that runs at control rate.”
corpus · a-gentle-introduction-to-supercollider-ruviaro-archive-org-c · chunk 10
“Audio rate means that the UGen will calculate a value for each sample in the block. There's another method, 'kr', which means _control rate_. This means calculate a single value for each block of samples.”
“// 56% on my machine ( a = Group.new; 250.do({ Synth(\UGen_ex7a, [ req, 440.0.rrand(1760.0), mp, 0.001, ate, 0.2], a) }); )”
corpus · the-supercollider-book-official-code-examples-scbookcode-gpl · chunk 71