Dan's link is a more streamed line way to go about this so I would definitely check it out. However to answer your question in regards to why that particular code wasn't working, it is because you env is much much longer so the release will continue on even though the gate has closed. You can use a second env using an Env.asr to close it out earlier if you need:
(
SynthDef.new(\SoundA,{
|gate=1|
var sine,env,susEnv;
//env = EnvGen.ar(Env.asr(0.1,1,0.25,-4),gate:gate,doneAction:2);
susEnv = EnvGen.ar(Env.asr(0.1,1,1.0,-4),gate:gate,doneAction:2);
env= EnvGen.ar(Env.new([0,Rand.new(0.0,
1.0),Rand.new(0.0,1.0),Rand.new(0.0,1.0), 0],[Rand.new(0.0,
17.0),Rand.new(0.0, 17.0),Rand.new(0.0,
17.0),Rand.new(0.0,17.0)],[0,3, -3, -1]) ,gate:gate,doneAction:2 );
sine = SinOsc.ar(440,0,0.3);
Out.ar(0,[sine,sine]*env*susEnv);
}).store;
SynthDef.new(\SoundB,{
var sine,env,gateEnv,length;
length = Rand(0.25,3.0);
gateEnv = EnvGen.kr(Env.new([0,0,1],[0.1+length,0]));
env = EnvGen.kr(Env.asr(0.1,1,0.25,-4),gate:(1-gateEnv).abs,doneAction:2);
sine = SinOsc.ar(200,0,0.3);
SendReply.kr(gateEnv,'soundBTrig',[env]);
Out.ar(0,[sine,sine]*env);
}).store;
o = OSCresponderNode(nil,'soundBTrig', { |t,r,msg| msg.postln;
~synthA.set(\gate,0); }).add;
)
(
t = Task({
loop {
~synthA = Synth(\SoundA );
2.0.wait;
Synth(\SoundB );
4.0.wait;
}
})
)
t.play
t.stop
o.remove;
Hope that helps. Best,
Chad
On Mon, Sep 20, 2010 at 12:57 PM, Dan Stowell
<danstowell+sc3@xxxxxxxxx> wrote:
Yep I'd recommend what Batuhan suggests too.
I recently blogged about a related requirement, to use one synth to
pause/unpause another.
http://mcld.co.uk/blog/blog.php?308
Replace Pause.kr with Free.kr and you have yet another way to do it...
Dan
2010/9/20 Batuhan Bozkurt <batuhan@xxxxxxxxxxxxxxxxxx>:
> Create a group for each of your synth pairs and use doneAction: 14. This frees the enclosing group.
>
> See doneAction help for other types of behavior.
>
> Best,
> Batuhan Bozkurt
> /* http://www.earslap.com */
>
>
>
>
> On Sep 20, 2010, at 1:49 AM, ronni montoya wrote:
>
>> Hello dear list, im using task for sequencing behaivors , the task
>> have 2 nested "do", when the first do is called it creates a synth an
>> stores it in a variable, then when the second "do" is called it
>> create another synth that selfdestroys after a while. I want that when
>> my second synth selfdestroys also destroy the first synth stored in
>> the variable.
>> Any idea of how to do this?
>>
>> here is the code
>>
>> (
>> t = Task({
>> inf.do({
>>
>> 1.do {
>> arg i;
>> a = Synth(\sound_a );
>> (20.rand ).wait;
>> };
>>
>>
>> 1.do {
>> arg i;
>> Synth(\sound_b ); //
>> -----------------------------------------------------> when this
>> selfdestroys, i want that also destroys variable a
>>
>> };
>>
>>
>>
>> (40.rand * 0.1 ).wait;
>> })
>> })
>> )
>>
>> t.play
>> t.stop
>>
>>
>>
>> THANKS!
>>
>> _______________________________________________
>> sc-users mailing list
>>
>> info (subscription, etc.):
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
>> archive:
https://listarc.bham.ac.uk/marchives/sc-users/
>> search:
https://listarc.bham.ac.uk/lists/sc-users/search/
>
>
> _______________________________________________
> sc-users mailing list
>
> info (subscription, etc.):
http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
> archive:
https://listarc.bham.ac.uk/marchives/sc-users/
> search:
https://listarc.bham.ac.uk/lists/sc-users/search/
>
--
http://www.mcld.co.uk