From CSWiki
// Drum Patterns
// Copyright (C) 2008 Ruslan Prokopchuk <fer.obbee@gmail.com>
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation, Inc.
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
JCRev r => dac;
.01 => r.mix;
SinOsc s[16];
SndBuf b[16];
for(0 => int i; i < 16; i++) {
s[i] => blackhole;
b[i] => r;
}
"./samples/heavykick.wav" => b[0].read;
"./samples/kick.wav" => b[1].read;
"./samples/hihat-open.wav" => b[2].read;
"./samples/snare-chili.wav" => b[3].read;
"./samples/snare-hop.wav" => b[4].read;
"./samples/hihat.wav" => b[5].read;
"./samples/snare.wav" => b[6].read;
"./samples/woodblock.wav" => b[7].read;
"./samples/tom-high.wav" => b[8].read;
"./samples/tom-mid.wav" => b[9].read;
"./samples/tom-low.wav" => b[10].read;
"./samples/hihat-open.wav" => b[11].read;
"./samples/snare-chili.wav" => b[12].read;
"./samples/snare-hop.wav" => b[13].read;
"./samples/hihat.wav" => b[14].read;
"./samples/snare.wav" => b[15].read;
while(1) {
30::second + now => time next;
for(0 => int i; i < 16; i++) {
Std.rand2f(0, 8) => s[i].freq;
}
Std.rand2(6,9)*20::ms => dur t;
while(now < next) {
0.0 => float f;
for(0 => int i; i < 16; i++) {
s[i].last() +=> f;
}
Math.sqrt(f*f) => f;
for(0 => int i; i < 16; i++) {
if((f > (i / 6.0)) && (f < ((i + 1) / 5.0))) { 0 => b[i].pos; }
}
t => now;
}
}