[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] selfdestroying synth that destroys another synth stored in a variable



Hi Ronni,
My apologies if someone all ready responded, it seems sometimes I'm not always seeing responses to questions. You can use SendReply and an OSCresponder to do this:

(
SynthDef.new(\SoundA,{
|gate=1|
var sine,env;
env = EnvGen.ar(Env.asr(0.1,1,0.25,-4),gate:gate,doneAction:2);
sine = SinOsc.ar(440,0,0.3);
Out.ar(0,[sine,sine]*env);
}).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;

You could also set up NodeWatcher to do something similar. Best,

Chad


On Mon, Sep 20, 2010 at 12:42 AM, kimm furt <kimm.furt@xxxxxxxxxxxxxx> wrote:
hi,
i had a similar problem recently.
it would be so great having a doneAction sending a osc message!
i ended up doing it this way:
- b pauses itself instead of freeing
- b has an envelope inside that triggers a SendReply.kr
- the OSCresponder getting the message frees both synths...
best, florian

Am 20.09.2010 um 00:49 schrieb ronni montoya:

> 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/