UGens output valid as a Boolean

It makes sense. Thanks both of you.

Perhaps:

{Select.ar(LFSaw.kr(1) > 0, [ SinOsc.ar(mul: 0.25), PinkNoise.ar(0.25)])}.play

Or even

{

var scale = LFSaw.kr(1) > 0;

var sine = SinOsc.ar(mul: 0.25) * scale;

var noise = PinkNoise.ar(0.25) * (1 - scale);

Out.ar(0, sine + noise);

}.play

There are tricks.

Josh

Though - be aware that in the cases above ALL UGens are always running. The synth graph is static - but the signal flow isn’t.

Hello,
all you need to know is here:
https://supercollider.github.io/tutorials/If-statements-in-a-SynthDef.html
Fabien

It makes sense. Thanks both of you.

In this case how could I do that with this example:

filtervalue =Select.kr( freq > 300, [100, 1000]);

“when the freq value go above 300hz the filer value will ramp “exponentialy” from 100 to 1000 hz in 10 seconds”
Thanks

I found this way:

	filterstart=100;
	
	gate=Select.kr(freq > 300, [0,1]);
	
	envvv=EnvGen.kr(Env([1,10],[10],[-7]),gate);

	ramp=Select.kr(freq > 300, [1,envvv ]);
  
        snd= LPF.ar(snd, filterstart * ramp);


But to be more specific my problem is there: the freq value comes from an never ending ascending and descending sirene (using LFDNoise3 ). My solution with the code above works only with the rise state (and I have the feeling it’s heavy and not really classy) and I would like this filter ramp behave the same but as opposite when it goes down (ie "when the freq value go below 300hz the filter value will ramp from 1000 to 100 in 10 sec), like a mirror. What could I do?
Thanks

I’d use LagUD:

{
	var freq, filt, sine, lowFreq, filtervalue;
	// mouse X for testing
	freq = MouseX.kr(200, 400);
	// just so you can hear the transitions
	sine = SinOsc.ar(freq, mul: 0.1);
	lowFreq = 100;
	filtervalue =Select.kr( freq > 300, [lowFreq, 1000]);
	filtervalue = Lag2UD.kr(filtervalue, 10, 10);
	// filters do NOT like values of 0, so make sure this value is always at least your low value
	filtervalue = filtervalue.max(lowFreq);
	filt = BPF.ar(PinkNoise.ar, filtervalue, 0.1);
	[sine, filt]
}.play;
// move the mouse from left to right  to left to hear the transition of the filter freq

That’s great, thanks.