Hi all,
I recently stumbled onto some code that produces a very loud, gross pop, and I’m struggling to understand why. I’m using LFSaw to modulate the curve parameter of a lincurve, which is applied to LFTri. The code is included here, but please, don’t run it without muting your system volume first!
s.boot;
//dangerous code, use caution:
(
{
var sig, mod;
mod = LFSaw.kr(1).bipolar(7);
sig = LFTri.ar(250);
sig = sig.lincurve(-1, 1, -1, 1, mod);
sig = sig * 0.2!2;
}.play(fadeTime:0);
)
I found that changing LFSaw.kr to LFSaw.ar makes the pop go away (there’s still a slight pop, but it’s to be expected because it naturally creates a discontinuity in the waveform as the curve value jumps from +7 to -7). Reducing the output range of LFSaw.kr lowers the intensity of the pop. Here is a waveform image of the pop::
I was even more confused by a related example. In the first example that follows, there’s no pop. But if I nudge the iphase of LFSaw by 0.0000001, then WHAM there’s a pop at the beginning. This might be dependent on sample rate and block size, so this code should also be considered dangerous.
(
{
//this example seems fine
var sig, mod;
mod = LFSaw.kr(1, 1.0328117).range(0,7);
sig = LFTri.ar(250);
sig = sig.lincurve(-1, 1, -1, 1, mod);
sig = sig * 0.2!2;
}.play(fadeTime:0);
)
(
{
//this one produces a large pop, but only once at the beginning
var sig, mod;
mod = LFSaw.kr(1, 1.0328118).range(0,7); // <- slightly different phase
sig = LFTri.ar(250);
sig = sig.lincurve(-1, 1, -1, 1, mod);
sig = sig * 0.2!2;
}.play(fadeTime:0);
)
I assumed modulating the curve value of lincurve in a signal processing context was a generally safe thing to do, and there is a similar example in the UGen help file. In fairness, it does say
// modulate the curve. Unlike with numbers and CurveSpec, the curve absolute value
// should not be much smaller than 0.5.
but it doesn’t explain why. What’s going on here?
Eli