Tuesday, August 26, 2008

CC3 Week 4 - Splice & Dice

I'm not convinced that my patch even works this week which is unfortunate because it looks good! I have used the example code and have my drum parts playing as a break beat with the stuttering. However the stuttering isn't controlling how I want it to. The stutter-chance is meant to be controlled using the sliders.

Below is my code. For an audio example click here [1.7MB].





You will need to place these samples [204KB] on the desktop for my code to work.



(

// Variables
var kick, snare, hats, clock1, clock2, clock3, cutkick, cutsnare, cuthats, cutprockick, cutprocsnare, cutprochats, sbs;

~kickstutterchance = 0.5;
~snarestutterchance = 0.5;
~hatsstutterchance = 0.5;




// WHOLE WINDOW
w = SCWindow.new.front;
// Parameters
w.bounds = Rect(170,150,450,300); // Rectangular Window Bounds (Bottom Left Width Height)
w.name_("Phat Beats"); // Window Name
w.alpha_(0.8); // Transparency
// w.boxColor_(Color.black);


// PANEL
e = SCCompositeView(w,Rect(10,50,430,230));
e.background = Gradient(Color.blue,Color.black);


// Color.new255(100,250,50);




// TEXT (KICK)
n = SCStaticText(e, Rect(350, 80, 100, 20));
n.stringColor_(Color.white);
n.string = "Kick";
n.font_(Font("CalisMTBol", 13));


// SLIDER (KICK)
r = SCRangeSlider(e, Rect(30, 85, 300, 15))
.lo_(0.001)
.hi_(1)
.range_(1)
.knobColor_(HiliteGradient(Color.red, Color.red, Color.red))
.action_({ |slider|
slider.lo=0;
~kickstutterchance = slider.hi;
// r.stringColor_(Color.white);

[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});


//// NUMBER BOX (KICK)
// r = SCTextField(
// parent: e,
// bounds: Rect(350, 110, 50, 15) // Left Top Width Height
// ).boxColor_(Color.new255(100,0,50));
//

// TEXT (SNARE)
t = SCStaticText(e, Rect(350, 150, 100, 20));
t.stringColor_(Color.white);
t.string = "Clap";
t.font_(Font("CalisMTBol", 13));


// SLIDER (SNARE)
t = SCRangeSlider(e, Rect(30, 85+70, 300, 15))
.lo_(0.0001)
.hi_(1)
.range_(1)
.knobColor_(HiliteGradient(Color.red, Color.red, Color.red))
.action_({ |slider|
slider.lo=0;
~snarestutterchance = slider.hi;
//t.stringColor_(Color.white);

[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});

//
//// NUMBER BOX (SNARE)
// t = SCTextField(
// parent: e,
// bounds: Rect(350, 180, 50, 15) // Left Top Width Height
// ).boxColor_(Color.new255(100,0,50));


// TEXT (HATS)
u = SCStaticText(e, Rect(350, 220, 150, 20));
u.stringColor_(Color.white);
u.string = "Hi-Hats";
u.font_(Font("CalisMTBol", 13));


// SLIDER (HATS)
u = SCRangeSlider(e, Rect(30, 225, 300, 15))
.lo_(0.001)
.hi_(1)
.range_(1)
.knobColor_(HiliteGradient(Color.red, Color.red, Color.red))
.action_({ |slider|
slider.lo=0;
~hatsstutterchance = slider.hi;
// u.stringColor_(Color.white);

[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});


//// NUMBER BOX (HATS)
// u = SCTextField(
// parent: e,
// bounds: Rect(350, 250, 50, 15) // Left Top Width Height
// ).boxColor_(Color.new255(100,0,50));
//






// Setup & Initialise Scheduling Clock
clock1 = ExternalClock(
tempoclock: TempoClock(tempo: 2.7725) // 166.35 BPM
);


// Setup & Initialise Scheduling Clock
clock2 = ExternalClock(
tempoclock: TempoClock(tempo: 2.7725) // 166.35 BPM
);


// Setup & Initialise Scheduling Clock
clock2 = ExternalClock(
tempoclock: TempoClock(tempo: 2.7725) // 166.35 BPM
);

// Start Routine

Routine.run({


// Cut Data -- buffer data and segmentation
kick = BBCutBuffer(
filename: "/Users/student/Desktop/kick.wav",
beatlength: 4 // number of beats in soundfile (estimates source tempo)
);


// Cut Data -- buffer data and segmentation
snare = BBCutBuffer(
filename: "/Users/student/Desktop/snare.wav",
beatlength: 4 // number of beats in soundfile (estimates source tempo)
);



// Cut Data -- buffer data and segmentation
hats = BBCutBuffer(
filename: "/Users/student/Desktop/hats.wav",
beatlength: 2 // number of beats in soundfile (estimates source tempo)
);
s.sync; //this forces a wait for the Buffer to load


// Cutting Synthesiser -- playback for buffer
cutkick = CutBuf2(
bbcutbuf: kick, // buffer to cut up
offset: 0.1, // random cut playback probability
dutycycle: CutPBS1({rrand(0.8,1.0)}, 0) // ratio of inter onset interval (delta!? of cuts)
);

// Cutting Synthesiser -- playback for buffer
cutsnare = CutBuf2(
bbcutbuf: snare, // buffer to cut up
offset: 0.1, // random cut playback probability
dutycycle: CutPBS1({rrand(0.8,1.0)}, 0) // ratio of inter onset interval (delta!? of cuts)
);


// Cutting Synthesiser -- playback for buffer
cuthats = CutBuf2(
bbcutbuf: hats, // buffer to cut up
offset: 0.1, // random cut playback probability
dutycycle: CutPBS1({rrand(0.8,1.0)}, 0) // ratio of inter onset interval (delta!? of cuts)
);


cutprockick = BBCutProc11(
phrasebars: 2, // number of phrase bars
stutterchance: ~kickstutterchance, // phrase tail chance of repetition
stutterspeed: {[4,8].wchoose([0.7,0.3])} // stutterspeed relative to sub division
);

cutprocsnare = BBCutProc11(
phrasebars: 2, // number of phrase bars
stutterchance: ~snarestutterchance, // phrase tail chance of repetition
stutterspeed: {[4,8].wchoose([0.7,0.3])} // stutterspeed relative to sub division
);


cutprochats = BBCutProc11(
phrasebars: 2, // number of phrase bars
stutterchance: ~hatsstutterchance, // phrase tail chance of repetition
stutterspeed: {[4,8].wchoose([0.7,0.3])} // stutterspeed relative to sub division
);


// Cutting Scheduler - cut groups and how they will be cut
z = BBCut2(
cutgroups: cutkick, // array of cut groups
proc: cutprockick // algorithmic routine used to generate the cuts
).play(clock1);

// Cutting Scheduler - cut groups and how they will be cut
y = BBCut2(
cutgroups: cutsnare, // array of cut groups
proc: cutprocsnare // algorithmic routine used to generate the cuts
).play(clock2);

// Cutting Scheduler - cut groups and how they will be cut
x = BBCut2(
cutgroups: cuthats, // array of cut groups
proc: cutprochats // algorithmic routine used to generate the cuts
).play(clock3);

});

clock1.play;
clock2.play;
clock3.play;


)








[1] Christian Haines. "Creative Computing: Semester 2 - Week 4 - Splice & Dice". Lecture presented at the Electronic Music Unit, University of Adelaide, South Australia, 21st August 2008