Problem with mapping audio-rate Controls

Hey there,

I am having trouble with mapping audio-rate controls in Synths (and NodeProxies) to audio Busses. This mysteriously doesn’t work:

i = { Out.ar(128, SinOsc.ar(0.2)) }.play; 
u = { \test.ar.poll; 0 }.play(addAction: 'addToTail'); 
u.map(\test, 128);

// doesn't work either
s.sendMsg("/n_map", u.nodeID, \test, 128);

Just for comparison: The control-rate equivalent works:

i = { Out.kr(128, SinOsc.kr(0.2)) }.play; 
u = { \test.kr.poll; 0 }.play(addAction: 'addToTail'); 
u.map(\test, 128);

Do you know what i could be doing wrong?
I’m on SuperCollider 3.11.2 on Mac OS 10.14.

All the best,
moritz

try

u.set(\test,\a128)

when mapping an audio rate control you need to use the .asMap method

a=Bus.audio;
{SinOsc.ar(1).range(100,100)}.play(s,a.index);
b={Saw.ar(\freq.ar(300),0.1}.play;
b.set(\freq,a.asMap)

asMap just returns a symbol prepending the rate (a in this case) to the bus index number.
so in your case you can simply use \a128

On the other hand this works for me

a={Saw.ar(\freq.ar(300),0.1)}.play;
b=Bus.audio;
{SinOsc.ar(1).range(100,110)}.play(s,b.index);
a.map(\freq,b);

so maybe I’m mistaken!

Are you sure 128 was an audio bus?

The problem is that map doesn’t know whether 128 refers to a control or audio bus, so it just assumes a control bus. If you pass a Bus object instead of a number, it should work. This is mentioned in the documentation of Node.map:

Integer bus indices are assumed to refer to control buses. To map a control to an audio bus, you must use a Bus object.

1 Like

ahhhh, I had overlooked that… thank you so much!

hey,
I somehow still get in to trouble when I try to map NodeProxy inputs:

Ndef(\k, { K2A.ar([1, 2, 3, 4]) }); 
Ndef(\x, { \test.ar.poll; 0 });

Ndef(\x).set(\test, Bus(index: (Ndef(\k).bus.index))); // sets \test to the index  of the bus, is this expected behaviour?
Ndef(\x).set(\test, Ndef(\k).asMap[0]);

what could I be doing wrong? :slight_smile:

all the best,
moritz

you need to call .asMap on a Bus:

b=Bus.audio;
Ndef(\x).set(\test,b.asMap);
1 Like