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

[sc-users] Re: The crazy pianist



/*
hi,
I am not a drummer but i am crazy. 
The crazyDrummer is out of the main script. 
I'm a new by in SC and actually, I do not know how to manage it.
I replaced the FSinOsc in the bass by a SinOsc, otherwise my eMac HP would
crash.
Happy X-mas to all.
*/

s.boot;

(
~crazyPianist= Pbind(
\scale, (0 ..11),
\degree,
        Pindex(
                (0, 7 ..77)%12,
                Prand([[0],[-1],[1],[2],[0,4,1],[0,4,1,5],[4,1,5,2]],inf)
                        +
                Pseq((0 ..11), inf)%12
        ),
[\dur, \legato],
        Prand([
                Pseq([[1,3/4]],3),
                Pseq([[1,5/4]],1),
                Pseq([[1/2,2/3]],2),
                Pseq([[1/3,3/8]],3),
                Pseq([[1/4,1/5]],4)
        ], inf)
);

//--
SynthDef(\crazyBassist, {|freq, amp, crazyness|
        var src;
        src= LPF.ar(
                Saw.ar(
                       #[1, 1.01]*freq,
                       SinOsc.ar(#[3, 3.01]*freq*crazyness, 0, 0.3, 0.5) 
                ),
                freq+170,
                Lag.kr(amp, 0.1)
        );
        Out.ar(0, src);
}).store;

//--

~crazyBassist= Pmono(
        \crazyBassist, #[\freq, \amp, \crazyness],
        \scale, (0 ..11),
        \degree, Prand([Pseq(Array.fill(12, {rrand(0, 18)}), 2),
                Prand((0..20), 12)], inf),
        \octave, Pwrand([Pn(2.5, 12), Pn(3, 12)], #[0.8, 0.2], inf),
        \amp, Pseq(Array.fill(12, {1-1.0.linrand}).thresh(0.5), inf),
        \crazyness, Pseq([Pn(0.001, 70), Pn(1, inf)]),
        \dur, Pseq(Array.fill(12, {[0.25, 0.5, (1/6).dup(3)].wchoose(
                #[0.5, 0.3, 0.2])}).flat, inf)
);
)

(
~crazyPianist.play;
~crazyBassist.play;
)
//--drums
(
SynthDef("bell", 
	{ arg out=0, freq=440, dur=0.05, amp=0.1, pan=0.0;
		var env, bells;
		env = EnvGen.kr(Env.perc(0.01, dur), doneAction:2) * amp;
		bells = Klank.ar(`[Array.rand(12, 2800.0, 5800.0),// frequencies
						nil,	 // amplitudes (default to 1.0)
						Array.rand(12, 0.1, 2) // ring times
						], Decay.ar(Impulse.ar(1), dur*0.2, ClipNoise.ar(0.01)));
		Out.ar(out, Pan2.ar(bells,pan,1*amp))
	}).store;

SynthDef("snare", 
	{arg out=0, amp=0.0, freq=0.1, pan=0.0;
        var z;
        var snare, drum;
         var n;
         n = 8;                                              
         snare=Decay.ar(
                       Impulse.ar(Line.kr(0.1,0.1,0.2,doneAction:2)),   //
impulse to trigger the decay
                       freq*0.0019, //0.5,    decay time
                       PinkNoise.ar(0.225)
                        );                       
                        n.do({
                           z=AllpassN.ar(
                              snare,    
                              0.04,      // max delay time                      
     
                              0.09, // delay time
                              0.89  // echo decay time                          
    
                           )
                           });                        
                        drum = Impulse.ar(EnvGen.kr(Env.new([1.5,0.0],[0.5]),
doneAction:2));                              
	                   Out.ar(out,Pan2.ar(Mix.new([snare*6.25+z*0.95,
drum]),pan,amp*2))
      }).store;
      
SynthDef("openhat",
			{arg out=0, amp=0.0, freq=0.0, pan= 0.0; 
               Out.ar(out,
               Pan2.ar(
              
BPZ2.ar(WhiteNoise.ar(Line.kr(0.0,0.1500-(freq*0.0001pi),(freq*0.0002pi),doneAction:2),Dust.ar(1,
1.0))) 
               		,pan,amp*1.5))
       }).store;
       
SynthDef("kick",
			{arg out=0, amp=0.5, freq=0.1, pan=0.0;
               var outLeft;
               var outRight;
               outLeft =
SinOsc.ar(90,0.5pi,Line.kr(amp,0,0.0005pi*freq,doneAction:2));                 
                            
               Out.ar(out,                       
               Pan2.ar(outLeft,pan, amp*2));                       
        }).store;


# a, b, c, d, e = {EventPatternProxy.basicNew} ! 5;

a.source = Pbind(
				\instrument, "bell",
				\dur, Prand([0.25, 0.125], inf),
				\legato, 0.01,
				\midinote, Prand([60,61,63,61]+36, inf),
				\amp, Prand([0.5,0.1,0.125]*0.75, inf)
				);
b.source = Pbind(
				\instrument, "snare",
				\dur, Prand([1.0, 1.5, 0.250], inf),
				\legato, 0.5,
				\midinote, Prand([58,\rest,52,\rest]-24, inf),
				\amp, Prand([0.5,1.0,0.125]*0.85, inf)
				);
c.source = Pbind(
				\instrument, "openhat",
				\dur, Prand([0.5, 0.25], inf),
				\legato, 0.01,
				\midinote, Prand([60,63,\rest], inf),
				\amp, Prand([0.5,0.75,0.125]*0.55, inf)
				);
d.source = Pbind(
				\instrument, "kick",
				\dur, Prand([1.0, 0.5, 0.250], inf),
				\legato, 0.1,
				\midinote, Prand([40,\rest, 45,\rest], inf),
				\amp, Prand([0.50,0.25]*0.85, inf)
				);

				e =Ppar([a, Pseq([b,Pstretch(0.25, b)],inf),c,d]).play; //--
)
// e is playing a, b, c, d
e.stop; 
e.play;