it may be a basic problem but I can’t figure it out. I am trying to use a single oscillator as a modulator to modulate multiple parameters simultaneously. The problem I have at the moment is the range of different parameters and operators for the modulation (i.e. should I add or multiply?). I want the modulator to have controllable modulating frequency and the index. Below is the simplified code sketch
Ndef(\multiparameterModulation, {| carFreq = 1, modFrequency = 1, modIndex = 0, pan = 0, amp = 0.5 |
var modulator = modIndex * modFrequency * SinOsc.ar(modFrequency);
var carrier = SinOsc.ar(carFreq + modulator);
//following mapping isn't right (pan and amp expect different ranges)
//How can I use the same modulator to modulate multiple parameters simultaneously
var panning = Pan2.ar(carrier, pan + modulator, amp + modulator);
panning;
});
Ndef(\multiparameterModulation).play;
Sometimes it is easier to use .range for these things.
If you have some signal that describes the shape you want and it has a range from -1 to 1 ,
var mod = SinOsc.ar(...);
you can change the range where you need it by using .range (note .range only works if the signal has a range from -1 to 1).
var carrierModRange = modFreq * modIndex;
var carrier = SinOsc.ar(carFreq + mod.range(carrierModRange.neg, carrierModRange));
This way you can easily reuse the signal, however you need to be careful when you add signals as they can easily exceed the -1 to 1 range. In that case, I like to use some type of clipping (e.g.,.clip, .tanh, .softclip…).
You panning line might look like this then.
Sure, but I read the question as getting confused as to what the ranges currently are, and if you keep the source between -1 and 1, you can avoid this difficultly.
You wouldn’t use .range at all with this approach. The modulator signal is assumed to be normalized (-1.0 to 1.0 for bipolar, 0.0 to 1.0 for unipolar) – you don’t want to .range that and apply a depth.
Yes, I think you’d just accumulate them like this.