A beginner's question

Hello ! (I’m a begginer. so…
I have a simple question …
I don’t know the way to stop the case method, in .do…
I put the variable (~fgh), before the method case, it works but it erases one of the 3 synths…
So I can’t find the proper place to put the variable to erase later all the 3 Synths which are played in this Routine…

Here is my effort

~noteE=Routine.new({
~t6forstop=Synth.new(defName: \reverb3,args: [\in,~reverb_bus,\out,0,\mix,0.8,\room,0.9],target: ~groupZ);
~t2againforstop=Synth.new(defName: \delay,args: [\in,~delay_bus,\out,0],target: ~groupB);
~steop=3.do{arg i;
i.postln;
~fgh*= case
{i==0}{Synth.new(\playerme1fordelay,args: [\buf,~harpordinario[0],\spkr_out,0,\reverb_out,~reverb_bus,\delay_out,~delay_bus,\amp,0.05,\rate,0.6],target: ~groupA);}
{i==1}{Synth.new(\playerme1fordelay,args: [\buf,~harpordinario[1],\spkr_out,0,\reverb_out,~reverb_bus,\delay_out,~delay_bus,\amp,0.01,\rate,0.8],target: ~groupA);}
{i==2}{Synth.new(\playerme1fordelay,args: [\buf,~harpordinario[2],\spkr_out,0,\reverb_out,~reverb_bus,\delay_out,~delay_bus,\amp,0.04],target: ~groupA);};
3.5.wait};
}).play;
},

Thanks

Hello thakoum,

Welcome aboard!

Before we get into the question, please markup code examples by putting them between three backticks
```
code
```
to get

code

Also note that the code you pasted isn’t complete, so we cannot run it to see where you made a mistake.

In general, if you want to create and track three different synths independently, you can e.g. store the synths in a dictionary, or in an array.

Example with an array:

(
s.waitForBoot({
	~synths = [];
	
	SynthDef(\pulse, {
		| out=0, freq=440, amp=0.1 |
		var env = EnvGen.ar(Env.perc(0.01, 15), doneAction:2);
		var sig = LFPulse.ar(freq:freq);
		Out.ar(out, env*amp*sig!2);
	}).add;
	
	s.sync;
	
	3.do {
		| index |
                // store the synth into an array of synths
		~synths = ~synths.add(Synth(\pulse, [\out, 0, \freq, 440.rrand(880)]));
	};
	
	// now you have three synths: ~synths[0], ~synths[1] and ~synths[2]
});
)

// try to kill one by one
~synths[0].free;
~synths[1].free;
~synths[2].free;

Example with a dictionary:

(
s.waitForBoot({
	~synths = ();
	
	SynthDef(\pulse, {
		| out=0, freq=440, amp=0.1 |
		var env = EnvGen.ar(Env.perc(0.01, 15), doneAction:2);
		var sig = LFPulse.ar(freq:freq);
		Out.ar(out, env*amp*sig!2);
	}).add;
	
	s.sync;
	
	3.do {
		| index |
		~synths[index.asSymbol] = Synth(\pulse, [\out, 0, \freq, 440.rrand(880)]);
	};
	
	// now you have three synths: ~synths[\0], ~synths[\1] and ~synths[\2]
});
)

// try to kill some
~synths[\0].free;
~synths[\1].free;
~synths[\2].free;

Thanks a lot!! I’ try to do it following your code. Next time I will be more specific…