One multichannel Ndef to various controls

Hi all,

I’m just wondering why the following code doesn’t work, trying to map a multichannel proxy by index…

Ndef(\var, {VarSaw.ar(\freq.kr(100), 0, \wth.kr(0.5), \mul.kr(0.2))}).play;
Ndef(\sins)[0…2] = {SinOsc.kr([2, 3, 5], 0, [300, 1, 0.5], [200, 0, 0.5])};
Ndef(‘var’).map(\freq, Ndef(‘sins’)[0], \wth, Ndef(‘sins’)[1], \mul, Ndef(‘sins’)[2])

Causes the server to crash…

Many thanks,
C.

.map calls .set, which must convert the args to control inputs so they can be sent as an "/n_set" OSC message. Ndef(\sins)[0] is a function, and converting a function to a control input just returns the value of the function, which in this case is a Ugen. You can’t put a Ugen in an OSC message. So I think there is just no good way to do this with Ndef slots directly. You can, however, convert each individual slot to its own Ndef and then .map them. This works because Ndefs can be converted to control inputs via the BusPlug.asControlInput method. So you might do something like this:

Ndef(\var, {VarSaw.ar(\freq.kr(100), 0, \wth.kr(0.5), \mul.kr(0.2))}).play;
~params = (freq: [2, 0, 200, 300], wth: [3, 0, 0, 0.5], mul: [5, 0, 0.3, 0.3]);
~params.keysValuesDo {|key, val| Ndef(key, {SinOsc.kr(*val)}) };
Ndef(\var).map(\freq, Ndef(\freq), \wth, Ndef(\wth), \mul, Ndef(\mul));

Got it! Many thanks for your reply PT!