In the following code, I use SendReply
and OSCFunc
to reflect the output value of a BinaryOpUGen after a certain time interval:
Is there a way to do the same thing using only server-side operations?
In the following code, I use SendReply
and OSCFunc
to reflect the output value of a BinaryOpUGen after a certain time interval:
Is there a way to do the same thing using only server-side operations?
SendReply, at the moment of being triggered, samples the input signal and transmits it to the client, where there is no continuously updating information, so the last-received value effectively holds.
Sample-and-hold.
In the server, sample-and-hold is Latch.
(Here, I’m guessing that what you mean by “do the same thing” is to freeze a signal’s value at a moment in time – to get and keep the value. You might have meant something different, though.)
hjh
Thank you! Yes, Latch
does it! I had forgotten that.
However, using Latch
also has the same result when enclosing it in a process as follows:
(
s.waitForBoot {
var length;
length = 0.01;
{
var plotScale, signal, busAudio, peak, normalisingFatcor;
plotScale = 400;
signal = SinOsc.ar(1 * plotScale).lincurve(-1, 1, 0.1, 3.0, 2)
* SinOsc.ar(0.5 * plotScale, 1.5pi).linlin(-1, 1, 0.1, 1);
// peak = Peak.ar(signal);
peak = Latch.ar(Peak.ar(signal), Impulse.ar(length.reciprocal * 2));
normalisingFatcor = 1 / peak;
signal * normalisingFatcor
}.plot(length)
}
)
To avoid this, I need an audio bus as follows, if I am not mistaken:
(
s.waitForBoot {
var length, plotScale, signal, busAudio, peak;
length = 0.01;
plotScale = 400;
signal = {
SinOsc.ar(1 * plotScale).lincurve(-1, 1, 0.1, 3.0, 2)
* SinOsc.ar(0.5 * plotScale, 1.5pi).linlin(-1, 1, 0.1, 1)
};
busAudio = Bus.audio(s, 1);
peak = { Peak.ar(signal.()) }.play(s, busAudio);
{
var normalisingFatcor = 1 / In.ar(busAudio);
signal.() * normalisingFatcor
}.plot(length)
}
)
The structure is a bit more complex than expected, but it is shorter than the previous code:
(
s.waitForBoot {
var length, plotScale, signal, peak, sendPeak, osc, normalisingFatcor;
length = 0.01;
plotScale = 400;
signal = { SinOsc.ar(1 * plotScale).lincurve(-1, 1, 0.1, 3.0, 2)
* SinOsc.ar(0.5 * plotScale, 1.5pi).linlin(-1, 1, 0.1, 1)
};
peak = { Peak.ar(signal.()) };
sendPeak = { SendReply.kr(Impulse.kr(length.reciprocal), values: peak.()) }.play;
s.sync;
osc = OSCFunc({ |msg|
normalisingFatcor = 1 / msg[3];
osc.free;
sendPeak.free;
defer { { signal.() * normalisingFatcor }.plot(length) }
}, '/reply');
}
)
The question arose because of a misunderstanding of the flow of time within a network of UGens.