DrumChucKer (Chucklib Test)
First test of ChuckLib. Random drumbeats generated using the drum sounds included with Renoise. Change the paths to use your own directories of samples.
(
var renoiseSampDir, reverbChannel, kickFiles, snareFiles, hatFiles;
/*Change Directory Settings As Needed*/
renoiseSampDir = "C:/Program Files/Renoise 2.8.0/Samples/";
kickFiles = PathName(renoiseSampDir ++ "Kicks/").files.collect{|file| file.fullPath};
snareFiles = PathName(renoiseSampDir ++ "Snares/").files.collect{|file| file.fullPath};
hatFiles = PathName(renoiseSampDir ++ "HiHats/").files.collect{|file| file.fullPath};
//Number Of Steps In A Bar And Tempo
~numSteps = 16;
TempoClock.default.tempo = 2.1366279069767;
//Get Number Of Buffers Loaded
~numKik = kickFiles.size;
~numSnare = snareFiles.size;
~numHat = hatFiles.size;
//Clean Up just in case
BP([kik, snare, hat]).free;
// ----- KICK -----
PR(bufPerc).chuck(BP(kik), parms: (
bufPaths: kickFiles,
bufCoords: [0, -1]!~numSteps,
amps: [1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1],
rates: [1],
bufs: {~numKik.rand}!~numSteps,
));
BP(kik).barCount = -1;
BP(kik).pbindPreAction = {~barCount = (~barCount + 1) % 4; if(~barCount == 0, {~bufs = {41.rand}!16; "KICK:".postln; (~bufs * ~amps).postln;}) };
// ----- SNARE -----
PR(bufPerc).chuck(BP(snare), parms: (
bufPaths: snareFiles,
bufCoords: [0, -1]!~numSteps,
amps: [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1],
rates: [1],
bufs: {~numSnare.rand}!~numSteps
));
BP(snare).barCount = -1;
BP(snare).pbindPreAction = {~barCount = (~barCount + 1) % 5; if(~barCount == 0, {~bufs = {44.rand}!16; "SNARE:".postln; (~bufs * ~amps).postln;}) };
// ----- HAT -----
PR(bufPerc).chuck(BP(hat), parms: (
bufPaths: hatFiles,
bufCoords: [0, -1]!~numSteps,
amps: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
rates: [1],
bufs: {~numHat.rand}!~numSteps
));
BP(hat).barCount = -1;
BP(hat).pbindPreAction = {~barCount = (~barCount + 1) % 3; if(~barCount == 0, {~bufs = {50.rand}!16; "HAT:".postln; (~bufs * ~amps).postln;}) };
//Create Mixer
~dcMixer = MixingBoard('DrumChucKer', nil, BP(kik).chan, BP(snare).chan, BP(hat).chan);
reverbChannel = MixerChannel(rvb, s, 2, 2, level:1, completionFunc: { |chan|
"creating reverb synth".postln;
chan.playfx({ |outbus|
var sig = In.ar(outbus, 2); // read from channel's bus
FreeVerb2.ar(sig[0], sig[1], 1, 0.6, 0.5)
});
});
~dcMixer.add(reverbChannel); // add to MixingBoard
BP(kik).chan.newPostSend(reverbChannel, 0.0);
BP(snare).chan.newPostSend(reverbChannel, 0.0);
BP(hat).chan.newPostSend(reverbChannel, 0.0);
//Clean up when CmdPeriod is hit
CmdPeriod.doOnce{
BP([kik, snare, hat]).free;
{~dcMixer.free}.defer(0.4); //Delay cleaning up the mixer to avoid throwing an error
};
//Play after a delay to let everything have a chance to load
{BP([kik, snare, hat]).play;}.defer(4);
)
Tags :