I’m working on a little square wave LFO that has the ability to round off toward a sine wave using one of the
lag methods/classes. When introducing more lag, however, the amplitude of the signal drops off, and I really struggled with finding an elegant makeup gain solution for this operation.
I was hoping to structure the makeup gain amount to be based on the rounding off (I’m using “
shape” as my arg name). So something like:
sig = sig.lag2(shape) * shape.lincurve(0, 1, 1, 7, 5.5).
The thing that’s giving the the hard time is that the additional gain required isn’t linear or along one continuous curve of values.
So basically, at certain
shape values, given a specific curve amount, the gain is correct, at others, it’s too little or too much. I think in this case two different conjoined curves could have done it. But I got to the point of either stacking additional methods onto the
lincurve (such as
softRound) or considering how to make the curve value itself, in
lincurve scale relative to the current value of my
shape argument, before deciding that seemed a bit over the top.
I was also thinking about making an array with correct gain values, and using
shape to index into it, but I was unable to use an
arg in place of an
Array's index inside of a SynthDef (I’m not looking to dynamically populate the array, nor set the amount of entries, simply get the right value based on the index). I haven’t spent time investigating making that work yet (is
Select the right way here, or can I just use a plain old Array?)
I’ve now currently settled on using the
Normalizer UGen, and that seems to be working for this module since the added delay for its lookahead isn’t a problem for a continually running LFO, but it’s not always going to be ideal.
I’m curious about other strategies or ways to finesse what I’ve tried might be using in this cases. What are ways that you scale values which don’t neatly conform to a curve?