Pfunc + Bus + asMap operations

Hi guys,
I’ve noticed that if I use something like that inside my Pbindef

[...]
\amp, Pfunc({ myControlBus.asMap }) * Pgauss( 0.5, 0.125, inf),
[...]

It works but it seems the multiplication has not effect at all. Emblematic of this is the following exaggerated example;

[...]
\amp, Pfunc({ myControlBus.asMap }) * 0.0,
[...]

which is still producing sound.
Why?
is there a “correct way” to do that?

Thank you so much for your help

This is a case of client/server confusion. When you map a bus into a Synth argument (through Pbindef), since the server have both the bus and the synth node on its side, the client have no way to multiply the value, everything happen on the server.

The solution is to scale your value server side too, with a dedicated synthdef that read the bus, scale it and write it back to another bus that you can map inside your Pbindef

Another solution is to get the bus value from the server with bus.getSynchronous then you can scale it with a pattern. The drawback is it’s no longer a bus, the value will change only at the beginning of each event.

With Ndef, there is a way to quickly setup a scaling synth inside the Pbindef:

(
~bus = ~bus ?? { Bus.control(s,1).set(400) };
Pdef(\zed, 
	Pbind(
		\instrument, \default,
		\degree, Pseq([0],inf),
		\freqscale,Pgauss( 0.5, 0.125, inf ), 
		\freq, Prout({ arg ev;
			Ndef(\lfo1, { arg scale=1;
				In.kr(~bus)* scale;
			});
			loop{
				Ndef(\lfo1).set(\scale, ev[\freqscale]);
				ev = Ndef(\lfo1).asMap.yield;
			}
		}),
		\dur, 1,
		\amp, 0.1,
	)
).play;
);
1 Like

Forgot to answer the last question, this is still producing sound because a mapped bus is represented as a Symbol, and Symbol are also used to represent rests in Pbind. Sometime you want to scale a Pseq containing values and rest (symbols) so the multiplication of symbol by a value is not an error and return the symbol

Thank you @hemiketal for you clear explanation.
As you said, it was my misunderstanding on the bus working principle.