Done action 2 cuts off reverb

In the following code the sig is mutiplied by an envelope .
Next assignment of sig is freeverb with sig as input , but somehow the done action cuts of the reverb and or creating audible clicks
How is this possible , since sig*env is only entering the reverb ?



(
SynthDef (\simple,
{
|att=0.001,dec=0.200,mod=500,pitch=0,filterfreq=400,reso=0.5,vol=0.5|
var sig,env;

		env=EnvGen.ar(Env([0,1,0],[att,dec],[0,-5]),doneAction:2);
		sig=Pulse.ar(pitch.midicps,mul:0.5)+Saw.ar((pitch+7).midicps,mul:0.5);///////I an
		sig=RLPF.ar(sig,filterfreq+(env*mod).clip(40,20000),rq:reso);
		sig=sig*env;
		sig=FreeVerb.ar(sig,mix:0.5,room:1,mul:1)!2;
		Out.ar(0,sig*vol)
}).add
)


/////////////////////////////////
(
Pdef(\zxcv,

	Pbind(\instrument,\simple,
		\dur,Pseq([2,0.5,0.5,1,0.25],inf),
		\pitch,Pseq([44,47,40,52,44,40,63],inf),
		\filterfreq,Prand([200,150,50,],inf),
		\dec,Pseq([0.125,0.125,4.125,0.7,0.25],inf),
		\att,Prand([0.001,0.1,0.01,0.001],inf),
		\reso,Pseq([0.5,0.5,0.5,0.2,0.5,0.5,0.1],inf),
		\vol,Pseq([0.2],inf),
		\mod,Pseq([30,50,20,150],inf),
	)
))
///
Pdef(\zxcv).play;
Pdef(\zxcv).stop;

I created a new variabe wig ,deleted all automation in Pbind same issue
Perhaps it’s audio buffer related , but the issue dissapears when done action is set to 0
It’s obviously noticeable when setting the decay value in the Pbind to 0.125 s , it really affects the reverb
Weird


(
SynthDef (\simple,
{
|att=0.001,dec=0.200,mod=500,pitch=0,filterfreq=400,reso=0.5,vol=0.5|
var sig,env,wig;

		env=EnvGen.ar(Env([0,1,0],[att,dec],[0,-5]),doneAction:2);
		sig=Pulse.ar(pitch.midicps,mul:0.5)+Saw.ar((pitch+7).midicps,mul:0.5);///////I an
		sig=RLPF.ar(sig,filterfreq+(env*mod).clip(40,20000),rq:reso);
		sig=sig*env;
		wig=FreeVerb.ar(sig,mix:0.5,room:0.8,mul:1)!2;
		Out.ar(0,wig*vol)
}).add
)


/////////////////////////////////
(
Pdef(\zxcv,

	Pbind(\instrument,\simple,
		\dur,Pseq([2,0.5,0.5,1,0.25],inf),
		\pitch,Pseq([44,47,40,52,44,40,63],inf),
		\filterfreq ,200,
		\dec,1,
		\att,0.001,
		\reso,0.5,
		\vol, 0.2,
		\mod,50,
	)
))
///
Pdef(\zxcv).play;
Pdef(\zxcv).stop;

doneAction: 2 frees the synth, which encloses itself when the envelope reaches the last breakpoint. You should firstly get rid of the argument “doneAction: 2” from EnvGen.ar and use FreeSelf and TDelay as follows:

(
SynthDef (\simple,
{
|att=0.001,dec=0.200,mod=500,pitch=0,filterfreq=400,reso=0.5,vol=0.5|
var sig,env,wig;

		env=EnvGen.ar(Env([0,1,0],[att,dec],[0,-5]));
		sig=Pulse.ar(pitch.midicps,mul:0.5)+Saw.ar((pitch+7).midicps,mul:0.5);///////I an
		sig=RLPF.ar(sig,filterfreq+(env*mod).clip(40,20000),rq:reso);
		sig=sig*env;
		FreeSelf.kr(TDelay.ar(env, 3)); // If the argument 3 cuts sound, you should increase it. I cannot hear the sound precisely now.. 
		wig=FreeVerb.ar(sig,mix:0.5,room:0.8,mul:1)!2;
		Out.ar(0,wig*vol)
}).add
)
1 Like

Better practice is to run one reverb synth (like an fx insert). Reverbs are CPU-heavy; you wouldn’t normally want to run a separate reverb for every note.

11. Busses | SuperCollider 3.12.2 Help includes a mono example but it should be pretty easy to bump up to stereo.

hjh

3 Likes

The buss and routing chapter was exactly what I was going to study next

My email reply to this topic two hours ago still hasn’t shown up here…
(We shouldn’t have switched from mailing list to forum, it’s such a drag!)

That’s what I posted via email two days ago (still hasn’t made it to this forum):
Let me chime in with a question about the order of processing: Wouldn’t it be enough to start the reverb synth first, then starting the other synths, to already achieve correct processing order?

You can also use DetectSilence and run the output of the synth through it. Use doneAction 2 in DetectSilence and 0 on the envelope

@Alberto_Gomez

DetectSilence is, for me, the hardest way when using it with a reverb effect… For me, the best way is using Bus.audio as @jamshark70 wrote, then the way I suggested is also simple. Probably, I did not find good argument values for DetectSilence…

Then you have a separate reverb UGen for every note. Reverbs are CPU-heavy. You might think putting the reverb in the same place as a single note is a neat way to sidestep signal routing, but it’s really not efficient.

Synth.new() and events use a default addAction = addToHead for exactly this reason – because it’s very common to start an effect processor first, and later play sound through it.

s.boot;

b = Bus.audio(s, 2);

a = { |inbus, outbus|
	var sig = In.ar(inbus, 2);
	Out.ar(outbus, FreeVerb2.ar(sig[0], sig[1]))
}.play(args: [inbus: b]);

s.queryAllNodes;

NODE TREE Group 0
   1 group
      1000 temp__0

b = Synth(\default, [out: b]);

s.queryAllNodes;

NODE TREE Group 0
   1 group
      1001 default
      1000 temp__1

1001 went to the head of the group, before the reverb, OK!

In my own work, I make all of these problems go away by my MixerChannel class – here, writing the reverb as a DAW-style fx insert.

~channel = MixerChannel(\synth, s, 2, 2,
	completionFunc: { |chan|
		~rvb = chan.playfx { |outbus|
			var sig = In.ar(outbus, 2);
			FreeVerb2.ar(sig[0], sig[1], room: 0.9, damp: 0.2)
		};
	}
);

p = ~channel.play(Pbind(
	\degree, Pwhite(-7, 7, inf),
	\dur, 0.25,
	\legato, 0.2
));

p.stop;

hjh

1 Like

You are 100% correct. I was just suggesting an alternative method, and if your CPU can take it, simpler, but the best practice of course is to have a separate synth for that