Hello,
I’m attempting to map a multichannel Bus to an argument in a SynthDef. My bus is allocated for 2 channels, and my SynthDef already has multichannel expansion, so I don’t believe that what I’m doing should be coercing an array after the definition has been added to the server, but perhaps that’s exactly what’s happening?
I have a simple two-channel effect, that allows for each channel’s amplitude to be controlled separately. My goal is to use a two-channel LFO (one LFO 180-degrees out of phase with the other) is to create a panning/sweep effect. This is a simplified version of what I’m working on.
When I use an In
UGen to read from the Bus, everything behaves as expected. But when I use map
or asMap
messages, it doesn’t work correctly- I believe that it’s only using the first channel’s data, because the stereo effect doesn’t work, and both channels oscillate at the same rate and phase.
I feel like I am missing something basic in my implementation. Any help would be greatly appreciated!
Notes:
There are three SynthDefs: \panNo, \pan, \mod.
\panNo is the one that isn’t working correctly, while \pan uses an In
UGen to achieve the correct results.
In \panNo, I’m using NamedControl to define my args, modIn = \modIn.kr...
is the arg of consequence here, and I tried to instantiate it both without setting any values and also by creating it as an array. The Synth behaves differently in both instances, but neither are correct… I either get a duplicated signal in both channels (when I don’t definite \modIn.kr as an array), or the first channel is modulated, and the second channel is not when I do define it as array.
Even using a.set(1, 0)
to set static values for the Bus doesn’t work, and I also tried calling it explicitly as an array, but that too didn’t work.
(
SynthDef(\panNo, { // this version does not multichannel expand
var out = \out.kr, amp = \amp.kr(0.1), depth = \depth.kr(1);
var modIn = \modIn.kr([0, 0]);
// var modIn = \modIn.kr; // <- I also tried it like this
var lfo, env, sig;
sig = LFPulse.ar(330) ! 2;
// lfo = In.kr(mod, 2).range(0, 1); // <- only difference from \pan
lfo = modIn; //.range(0, 1);
sig = (sig * lfo * depth) + (sig * (1 - depth));
Out.ar(out, sig);
}).add;
SynthDef(\pan, { // this version works as expected
var out = \out.kr, amp = \amp.kr(0.1), depth = \depth.kr(1);
var modIn = \modIn.kr;
var lfo, env, sig;
sig = LFPulse.ar(330) ! 2;
lfo = In.kr(modIn, 2).range(0, 1);
// lfo = modIn.range(0, 1); // <- only difference from \panNo
sig = (sig * lfo * depth) + (sig * (1 - depth));
Out.ar(out, sig);
}).add;
SynthDef(\mod, {
var out = \out.kr;
var sig = [SinOsc.kr(0.5), SinOsc.kr(0.5) * -1];
Out.kr(out, sig)
}).add;
a = Bus.control(s, 2);
)
a.numChannels; // returns 2, as expected
x = Synth.tail(s, \panNo, [\modIn, a.asMap]);
a.set(1, 0); // this doesn't work, nor does explicitly using an array: a.set([1, 0])
w = Synth.head(s, \mod, [\out, a]); // this doesn't work with \panNo, neither
x.free;
// don't free w yet:
y = Synth.tail(s, \pan, [\modIn, a]); // this functions correctly