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

[sc-users] Groping two Synths and four Pdef into a single routine



 
 
i'd like to play  as the head says two Synths and four Pdef into a single routine , using an  automata and a collection of elements, a sort of algorithic composition,  both linked  and then with just a  routine let them run stochastically. 
Which class allows me to do this, i think  Group, and Demand might be nice. 
This is the code i hope you like it, you can change the envelope or everything if you need it.  
 
s.boot
(
(
SynthDef(\pop,{|freq=50, amp=0.5, dur=3, gate=1, out=0,pan=0|
  var sig, env, fil, eco;
  sig = WhiteNoise.ar((Impulse.kr(freq)),0);
  sig = sig+LFNoise0.ar(XLine.kr(freq,2000,dur));
  sig = sig+Formant.ar(XLine.kr(freq,600,dur),XLine.kr(freq*2,freq,dur),XLine.kr(freq*4,freq,dur));
  fil = CombN.ar(sig,1,0.01,0.001,-1);
  eco = FreeVerb.ar(fil,15,0.5,0.005,0.5,0.5).distort;
  env = EnvGen.kr(Env.perc(0.01,dur),gate,doneAction:2);
   Out.ar(out,Pan2.ar(eco*env,pan));
}).memStore
);
q=Synth(\pop);
q.set(\gate,0);
q.trace
(
j = (
Pdef(\higo,Pbind(\instrument,\pop,
  \note, Pseq([5,-14,1,1,-3,6,3,-7,14,1,-10,3,40,70,-70,1,-2,3,4,-5].neg,inf),
  \dur, Pseq([0.9,0.45,1,23,0.425,0.5,2.5,0.5,3,0.5,3.50,0.5,0.75,3.50,0.5,15,0.5,25,0.6],inf),
  \amp, Prand([0.1,0.1,0.1].normalizeSum,inf),
  \tempo, 100/60,
  \pan,Pseq([1,-1],inf)
)))
);
/*
Pdef(\higo).play;
Pdef(\higo).stop;
*/
/*
.adsr(0,1,1,0)
.sine(dur,amp)
.perc(0.01,dur)
.adsr(0,amp,amp,0)
*/
(
SynthDef(\yyy,{|freq=44,gate=1,out=0,amp=1,pan=0,dur=3|
  var sig, env, fil;
  sig = PinkNoise.ar(LFPulse.kr(freq));
  sig = Pitch.kr(sig)+RHPF.ar(sig,100,0.5).distort;
  sig = RHPF.ar(Formant.ar(sig).distort+SinOsc.ar(sig)+Formant.ar(sig));
  //sig = Amplitude.kr(sig);
  fil = FreeVerb.ar(sig,XLine.kr(100,0.5,5),XLine.kr(0.02,2,5),XLine.kr(2,0.2,5));
  env = EnvGen.kr(Env.perc(0.01,dur),gate,doneAction:2);
   Out.ar(out,Pan2.ar(fil*env,pan));
}).memStore
);

d = Synth(\yyy);
d.set(\gate,0);
d.trace
/*
.asr(0,0.4,0.5,0)
.sine(1,1)
.adsr(0,0.4,0.5,0)
.asr(0,0.4,0.5,0)
*/
(
p= (
Pdef(\lolo,Pbind(\instrument,\yyy,
  \freq,Pseq([8,6,9,3,2,4,3].midicps,inf),
  \amp,Prand([0.4,0.8].normalizeSum,inf),
  \pan,Pseq([-1,1],inf),
  \dur,Pseq([25,15,25,0],inf)
)))
);
/*
Pdef(\lolo).play;
Pdef(\lolo).stop;
/*

(
SynthDef(\LPDanzon_Likesthat,{|freq=0.4, amp=0.05, out=0,gate=1,pan=0,dur=4|
  var sig, env, eco, fil;
  sig = WhiteNoise.ar(freq,0,Impulse.kr(XLine.kr(freq*4,freq,dur),0,2,6));
  sig = LFNoise2.ar(sig,(SinOsc.kr(XLine.kr(freq,freq*8,dur),0,LFPulse.ar(sig,0,2,4))));
  fil = RLPF.ar(sig*Saw.ar,[freq,18000],0.5,1);
  eco = FreeVerb.ar(fil,10,XLine.kr(2.0,0.001,dur),XLine.kr(0.001,5,dur),1);
  env = EnvGen.kr(Env.sine(dur,1),gate,doneAction:2);
        Out.ar(out,Pan2.ar(eco*env,pan));
  
}).memStore;
);    
 
g = Synth(\LPDanzon_Likesthat)
g.trace
/*
.adsr(0,amp,amp,0)
.perc(0.01,dur)
*/
(
v = (
Pdef(\gigo,Pbind(\instrument,\LPDanzon_Likesthat,
  \freq,Pseq([1,2,3,4,0.5,6,70,8,9,1,
       2,3,4,5,6,7,8,9,1,2,3,4,5,6,70,8,9,1,
       1,2,3,0,5,6,70,8,9,1].midicps.neg,inf),
  \amp,Pseq([0.3,0.6,0.9].normalizeSum,inf),
  \tempo,150/60,
  \pan,Pseq([-1,1],inf)
  )))
);
/*
v = Pdef(\gigo).play;
v = Pdef(\gigo).stop;
/*
(
SynthDef(\functionB,{|freq=100,amp=1,gate=1,out=0,pan=0,damp=0.3,ws=0.2, dur=40|
  var sig, env, eco, fil;
  sig = Pulse.ar(freq,0.3,amp);
  sig = SinOsc.ar(sig,0,sig/2);
  sig = PitchShift.ar(sig,ws,2,0.3,0.75);
  fil = RHPF.ar(sig,freq,0.5);
  eco = FreeVerb.ar(fil,1,0.4,damp);
  env = EnvGen.kr(Env.sine(dur,amp),gate,doneAction:2);
  Out.ar(out,Pan2.ar(eco*env,pan));
}).memStore;
);
f=Synth(\functionB);
f.trace
/*
.perc(0.01,dur)
.adsr(0,amp,amp,0)
/*
(
h = (
Pdef(\locomotiva,Pbind(\instrument,\functionB,
  \freq,Pseq([100,4000,200,8000,300,12000],inf),
  \amp,Pseq([1,1.5,1.5,1.5],inf),
  \note,Pseq([0.5,1],inf),
  \legato,Pseq([0.1,1,5],inf),
  \dur,Pseq([40,50],inf)
)))
);
/*
Pdef(\locomotiva).play;
Pdef(\locomotiva).stop;
/*

(
SynthDef(\imperative,{|freq=200,amp=0.51,gate=1,out=0,pan=0|
  var sig, env,eco;
      sig = SinOsc.ar(LFNoise0.ar(freq,amp));
      sig = Saw.ar(sig,PitchShift.ar(sig,0.3,0.4,0.5));
      sig = PitchShift.ar(sig);
      eco = FreeVerb.ar(sig,1,4,0.5,amp);
      env = EnvGen.kr(Env.adsr(0,amp,amp,0),gate,doneAction:2);
   Out.ar(out, Pan2.ar(eco*env,pan));
      }).send(s);
);
/*
a =Synth(\imperative);
a.set(\gate,0);
a.trace
*/
(
SynthDef(\expressiveness,{|pan=0,freq=10,gate=1,amp=0.5,dur=20,out=0|
   var sig, env, fil,eco;
   sig = LFTri.ar(freq).distort;
   sig = LFPulse.ar(sig).distort;
   sig = PinkNoise.ar(sig).distort;
   sig = Pitch.kr(sig);
   sig = Formant.ar(sig).softclip;
   
   fil = CombC.ar(sig,XLine.kr(0.1,1,dur),XLine.kr(0.001,1,dur),20);
   eco = FreeVerb.ar(fil,XLine.kr(40,0.002,dur),XLine.kr(0.001,0.4,dur),XLine.kr(1,10,dur));
   env = EnvGen.kr(Env.adsr(0,amp,amp,0),gate,doneAction:2);
    Out.ar(out,Pan2.ar(eco*env,pan));
}).send(s)
);
/*
r= Synth(\expressiveness);  
r.set(\gate,0);  
r.trace 
*/
)
 
this is the automata
 
// Ppar variables.
.
(
~ava = Pseq([5000,10,15000,10000],1);
~ima = Prand([[200,100,1100],[300,200,100],[500,300,100],[100,500,100]],1);
);
//collection of element.
(
~dir= Dictionary[
  \r->[0,1,2,3,4,5,6,7,8,9].midicps,
 ` \a->Ppar([~ava,~ima],2),
  \v->[1000,2000,111,4321,6543,].cpsmidi,
  \p->Pseq([1],Prand([2,1])),
  \j->[0,7,-6,1,10,-8,20],
  \h->Pn(Prand([4,3,2,5],1)).asStream;
  ]
);
(
~ficus=
        Pfsm([[0,1],
             \r,#[0,4],
             \a,#[1,2,5],
             \v,#[2,3,1],
             \p,#[3,4,1],
             \j,#[4,5,2],
             \h,#[5,0,1],
                       nil,nil],1).asStream;
);

//how to link them?
w = ~ficus.nextN(4).collect({|i|~dir.matchAt(i)});
t = if(w.isNumber,{i},w.isStream)
o = (
Routine({|i|
 lopp({
      //Synth_collection(\sale,[\dur,,\freq,,\amp,,];
  i.wait;
)}
)}
);
o.play
o.stop