Compute dynamically a signal from a bus

Is there a way to compute dynamically a signal from a bus? In practice, I would like to add or to subtract values under condition applied directly to a signal. Thanks for any help.

I’d say that’s what buses are designed for.

Possible so far but I don’t understand what you mean with the continuation of the sentence:

Could you explain a bit further what you mean with this ? How comes the condition into play and what should it cause ?

To be clear, before the signal goes to the DAC I want to modify the current value if this value reaches a threshold, a bit like a compressor on the fly but with my own conditions and my own functions.

You can write a dedicated SynthDef for this and pipe the signal through a Synth of that kind. Busses and order of execution have to be considered, but this would be a normal fx chain and should be rather straight.
If you are thinking about using the ‘if’ ugen for conditions, see this first:

I want to work with the Ugen In
and the condition(s) is/are applied on the signal value,
something like:
if i>0.3 then add 0.1 else subtract 0.3

IIRC in the server (i>0.3) gives 0.0 or 1.0 so you could write;
sig=(sig > 0.3) * 0.1+ ( (sig < 0.3) * (-0.3) ) + sig;

Yes (though really it should be ( (sig <= 0.3) * (-0.3) ) because otherwise it doesn’t handle sig == 0.3 exactly).

Or, to avoid repeating the comparison:

((true - false) * condition + false) + sig
= (0.4 * (i > 0.3) - 0.3) + sig


This does not work for me.
Let this snippet be the testing code:

SynthDef("help-PinkNoise", { arg out=0;,

SynthDef("help-In", { arg out=0, in=0;
    var sig;
	sig =, 1).poll;
// here is your suggestion...
	sig=(sig > 0.3) * 0.1+ ( (sig < 0.3) * (-0.3) ) + sig;
// the idea is to work with the value you can post with poll ...., sig);


//play noise on the right channel
x = Synth("help-PinkNoise", [\out, 1]);

//read the input and play it out on the left channel
Synth.after(x, "help-In", [\out, 0, \in, 1]); outputs -1 to +1.

The argument 0.1 is a multiplier, so outputs -0.1 to +0.1.

The maximum output value, 0.1, is below the threshold 0.3. So all possible values are below the threshold.

So the expected discontinuity at the threshold will never be triggered.


Yes, it seems that it works.
I have to test a little bit more…

I got it.
Thanks for the trick.

One useful takeaway from this thread is that it’s almost always useful to think in terms of signal ranges, e.g., 0, mul: 50, add: 100) isn’t just a sinewave. It’s rather:, 0)  // -1 .. +1
* 50     // -50 .. +50
+ 100    // +50 .. +150

Having this in your mind for every signal makes it a lot clearer to reason about the behavior of UGens and math ops.