[sc-users] Complicated Routines

Dionysis Athinaios adroid28 at yahoo.gr
Tue Jan 16 18:40:56 PST 2007


Hello everyone :-)

I am a bit stuck in a routine related problem and I was wondering whether someone could help me
out. I am creating Routines in order to use them in a structure where they will be randomly chosen
by other routines itterating functions with .choose like 
{a Routine, a Routine, a Routine}.choose.reset.play. 

In the Routines I have created I am using both control busses and OscResponder messages(for  dynamicaly changing the wait time). This means that I have to find a way (for after the Routine stops) to free the synths that are used for the control busses and the density as well as removing the OscResponder. For this purpose I used the scheduller that also allows me to have random durations
 for each Routine.

My problem is that I can not have multiple instances of the same routine because all instances stop
after the first instance stops (as scheduled). This will be a problem if the .choose happens to choose the same routine twice. Is there a way to achieve multiple instances of a routine that uses busses and OscResponder messages as well as having a mechanism for freeing everything after completion? 

This is some code resembling what I have untill now although it doesn't include busses:

// The Synth

(

SynthDef("R-sine", 
              {arg out = 0, freq = 440, freq1 = 4440, pan = 0.0;
              var jug = Rand(freq,freq1); //Random frequencies

Out.ar( out, Pan2.ar({ 

SinOsc.ar(440)

}
            , pan, 

           EnvGen.kr(Env.perc(0.01, 0.02), Rand(0.3,1.0), 0.3, doneAction: 2))
           , 0 )
           
 
 }).load(s);
 )

// The Density control synths (via OscResponder)

 //density
(

SynthDef(\density, {arg  trigtime;
     var modu;
     modu = LFDNoise1.kr(LFDNoise1.kr(0.2, 0.4, 0.6), 0.07, 0.08); // the modulation signal
         // send out the value of the signal
     SendTrig.kr(Impulse.kr(trigtime.reciprocal), 0, modu);
     }).load(s);
          
//spread

SynthDef(\density_spread, {arg  trigtime;
     var denser;
     denser = MouseY.kr(0, 0.03); // the modulation signal
         // send out the value of the signal
     SendTrig.kr(Impulse.kr(trigtime.reciprocal), 1, denser);
     }).load(s);
          
)


(

// "simple"
~simple = Routine.new({  var osc, waitfunc = 0.1, waitfunc2 = 0, al, bl, trigtime,                                     runtime, pan;
// random pan for the rut routine
pan = rrand(-1.0,1.0);
// set a time to check the mouse vals... and change the random  generator's parameters
trigtime = 0.06;
// the amount of time for this to run (can be a random range!!)
runtime = rrand(2, 20); 
// the osc responder
osc = OSCresponderNode(s.addr, '/tr', {arg time, responder, msg;
            [{waitfunc = msg[3]},  {waitfunc2 = msg[3]}]
            [msg[2]].value(time, msg);
              }).add;

// start the density synths 
     s.sendMsg(\s_new, \density, al = s.nextNodeID, 0, 1, \trigtime,  trigtime);
     s.sendMsg(\s_new, \density_spread, bl = s.nextNodeID, 0, 1, \trigtime,  trigtime);

// schedule the routine to stop and remove the osc responder
     SystemClock.sched(runtime, {
    ~texture_simple.stop;osc.remove; s.sendMsg(\n_free, al); s.sendMsg(\n_free, bl)});

//The sound part
    inf.do({ 
    s.makeBundle(0.05, 
         {Synth("R-sine",[\freq, rrand(700, 10000), \freq1, 12000, \pan, pan]) }
                                     );
            exprand((waitfunc - waitfunc2).fold(0.001, 3), waitfunc + waitfunc2).wait; //Density control (paraxeno to fold)
    })
});

)

 // PLAY THE ROUTINE
 ~simple.reset.play;  
   

s.queryAllNodes; 




	

	
		
___________________________________________________________ 
Χρησιμοποιείτε Yahoo!; 
Βαρεθήκατε τα ενοχλητικά μηνύματα (spam); Το Yahoo! Mail 
διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών 
μηνυμάτων http://login.yahoo.com/config/mail?.intl=gr 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.create.ucsb.edu/pipermail/sc-users/attachments/20070116/e11018a9/attachment-0001.htm


More information about the sc-users mailing list