home/ atoms/ sc-ugen-range-scaling

UGen output is scaled to useful ranges using .range, mul/add arguments, or linlin/linexp methods

Raw UGen output is typically -1 to +1 (bipolar) or 0 to 1 (unipolar) — not directly usable for frequency or other parameters. Three equivalent scaling approaches exist: (1) .range(lo, hi) rescales bipolar output to [lo,hi]; (2) mul and add arguments: a bipolar UGen at range [lo,hi] uses mul=(hi-lo)/2, add=(hi+lo)/2; (3) linlin/linexp for arbitrary linear or exponential rescaling. Use .range for readability. For exponential scales (frequencies, log-perceived parameters) linexp is appropriate — never use 0 as the low bound for an exponential range.

Examples

{SinOsc.ar(LFNoise0.kr(10).range(500,1500), mul:0.1)}.play // equivalent: {SinOsc.ar(LFNoise0.kr(10, mul:500, add:1000), mul:0.1)}.play

Assessment

A LFNoise2.kr produces values in -1 to +1. Write the .range call to scale it to 200–2000 Hz for a filter cutoff.

“simply rescales the output of a UGen. Remember,LFNoise0produces num- bers between -1 and +1 (it is a bipolar UGen). Those raw numbers would not be very useful to control frequency”
corpus · a-gentle-introduction-to-supercollider-ruviaro-archive-org-c · chunk 11