How to ask Server to receive Bus out amplitude numerical values?

Hi,
I am looking for a quick way to print in the post window the amplitude numerical values coming from the Bus out used on the Server, for instance the Bus 0, for debugging.
I would like to have precise values without knowing the mul values of the Ugens used,
it could be useful to have the numbers visualized with the GUI meter, called with the command:
s.meter;
I tried different solutions but I have to specify the signal to analyze.

(
{
	var sig;
	var ampSig;
	sig = SinOsc.ar()*0.2;
	ampSig = Lag.kr(Amplitude.kr(sig, releaseTime:  1.0));
	ampSig.ampdb.round.poll(1, \amp).postln;       

	Out.ar(0, sig);

}.play;
)

Thank you for your suggestions.

It seems to be working here. Or maybe I misunderstood?

(
{
	var sig;
	var ampSig;
	sig = SinOsc.ar()*0.2;
	ampSig = Lag.kr(Amplitude.kr(sig, releaseTime:  1.0));
	ampSig.ampdb.poll;
	Out.ar(0, sig);

}.play;
)

I’m not sure about the “mul values of the UGen”.

Yes It is works,
sorry probably I was not so clear,
I tried different strategies, also this one:

(
{
	var trig, sig, amp;

	trig = Impulse.kr(10);
	sig = SinOsc.ar(440, mul: 0.2);
	amp = Lag.kr(Amplitude.kr(sig, releaseTime: 1.0)).ampdb.round;

	SendReply.kr(trig, '/amp', amp);
	sig
}.play;
)  

(
OSCdef(\getAmp, {
	arg msg;

	~amp = msg[3].postln;     
}, '/amp')
)

that also works but I would like to find a quick way to “poll” the Server Out without knowing in advance the Ugens to be analized with their respective gains, just as it does s.meter; command

1 Like

I believe s.meter creates a SynthDef, and then creates OSC responders to update the GUI. Is that .what you want?

Even without GUI, you need a Synth to read the Bus

See SendPeakRMS for inspiration:


(
{
    SendPeakRMS.kr(Dust.ar(20), 20, 3, "/replyAddress")
}.play;
)

(
o = OSCFunc({ |msg|
    "peak: %, rms: %".format(msg[3], msg[4]).postln
}, '/replyAddress');
)
o.free;

For Out, the signal will go onto a bus where it can be gotten. If it’s a control bus, theBus.get( ... action function ...) or theBus.getSynchronous. If it’s an audio bus, you’d need to add a synth to In.ar that bus, and SendReply to the language.

“… the UGens…” – you don’t have access to UGens inside a synth, from outside the synth. So this idea will just not work, period.

hjh

Thank you, I did not know it, usefull! what is % ?

1 Like

% character is used by format (String method), that replaces % by its items

Thank you, I tried this whit your suggestion:

(
{
	~sig = SinOsc.ar(440, mul: 0.2);
	~amp = Amplitude.ar(~sig, 0.001, 1.0);
	Out.kr(~busC, ~amp);
	Out.ar(0, ~sig);          
}.play;
)

(
{
	10.do{
		~busC.get({arg i;
			~amp = i.postln
		});
		1.0.wait;
	}
}.fork;
)

Could you please explain me better why this way does not work?

~busControl = Bus.control(s);
~input = {SinOsc.ar(220, phase: 0.2)}.play;
~ampli = {Amplitude.kr(~input, 0.001, 1.0)}.play;
~outC = Out.kr(~busControl, ~ampli);

(
~routine = {
	10.do{|i|
		~busControl = i.postln;
	}
}.fork;
)

// ERROR: should not use a Synth inside a SynthDef

Thank you

This would with with the JIT library. But in SuperCollider itself, it makes little sense You’re trying to create a SynthDef, and using a Synth inside it. You probably need to review the Client/Server help files, and tutorials.