This is a Two type of synth
A
(
SynthDef(\x, {
arg freq=440, modFreq=20;
var snd = LFNoise1.ar(freq, mul: 0.5);
var mod = SinOsc.ar(modFreq, mul: 0.5);
var env = EnvGen.kr(Env.perc(0.03, 2.0), doneAction:2);
snd = snd * mod * env;
Out.ar(0, snd!2);
}).add;
)
B
(
SynthDef(\x, {
arg freq = 440, modFreq= 20;
var sig,snd,env;
sig = SinOsc.ar(100);
sig = ((sig - Delay1.ar(sig))/2pi) % 1;
sig = sig * SinOsc.ar(200).range(freq, modFreq/2);
sig = (Phasor.ar(DC.ar(0), sig, 0.0, 1.0)* 2pi).sin;
(sig * 10.dbamp) ! 2;
env = EnvGen.kr(Env.adsr(0.2,1.0,0,1.0), doneAction: 2);
// env = EnvGen.kr(Env.perc(0.01, 0.125), doneAction: 2); //percussion?
snd = SinOsc.ar(200) * sig * env;
Out.ar(0, snd!2);
}).add;
)
I would like to trigger in Rotuine
(
b = ModernLife.new.setRule("245678/3").fps_(2).fadeAmount_(1).play;
r = Routine.run({
inf.do({
var sig = b.getFreq[0]; // sum of array of simple number
var mod = b.getFreq[1]; // sum of array of simple number
// [sig, mod].postln;
Synth(\x).set(\freq, sig, \modFreq, mod);
// Synth(\x).set(\modFreq, mod);
1.0.rand.wait;
// "done".postln;
}).play;
});
)
Run code A in the Routine Cpu meter is OK,
but Run code B in the Routine, the CPU meter keeps accumulating so fast
at some point reaches 100 percent.
Is there any way to release the used Synth?! or is it not going to peak?
b is simple array and b.getFreg is number from the sum of array.