home/ atoms/ sc-ugen-safety-plot-first

In SuperCollider, always plot an unfamiliar UGen before playing it to avoid dangerous amplitude spikes

SuperCollider gives direct low-level access to audio objects (UGens) without any safety clipping or limiting. Certain UGens produce catastrophic amplitude spikes when given out-of-range parameters: the BPF unit with a negative rq value drives amplitude to enormous levels. The primary safety rule is: for any new UGen or unfamiliar parameter, use .plot() before .play to inspect the signal range visually. A secondary hazard: when using MouseX.kr or MouseY.kr with dual monitors, the mouse can venture into negative-coordinate space, sending negative values to UGens that can’t handle them. Always check that the expected value range matches what the UGen can safely accept.

Examples

// DANGEROUS — NEVER PLAY THIS, only plot it:
{ BPF.ar(WhiteNoise.ar(0.4), rq: -1) }.plot(0.05);
// Safe pattern: plot first, play only if range is sane
{ SinOsc.ar(MouseX.kr(0, 1000)) !2 }.plot(0.01);
{ SinOsc.ar(MouseX.kr(0, 1000)) !2 }.play;

Assessment

Explain the dual-monitor problem with MouseX.kr(0, 1000): under what display configuration can the mouse produce values outside [0, 1000]? How would you guard against this in a live performance?

“SuperCollider gives you low-level access to sound objects (UGens). This means you have lots of power, you are playing with the nuts and bolts. It also means there are no safety systems to protect you from doing something crazy.”
corpus · welsh-s-synthesizer-cookbook-figures-in-supercollider-cookbo · chunk 9