20 changed files with 108 additions and 0 deletions
@ -0,0 +1,53 @@ |
|||
import processing.sound.*; |
|||
|
|||
SoundFile[] file; |
|||
|
|||
// Initialize data |
|||
int numSounds = 0; |
|||
int numTracks = 0; |
|||
int bpm = 0; |
|||
int divider = 0; |
|||
int duration = 0; |
|||
int beat = 0; |
|||
|
|||
boolean[][] samples; |
|||
|
|||
void setup() { |
|||
size(640, 360); |
|||
background(255); |
|||
|
|||
loadData(); |
|||
|
|||
} |
|||
|
|||
void draw() { |
|||
background(255); |
|||
stroke(255); |
|||
|
|||
for(int i=0; i<numSounds; i++) { |
|||
fill(90); |
|||
for(int y=0; y<divider; y++) { |
|||
rect((width/divider)*y,(height/numSounds)*i, width/divider, height/numSounds); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
for(int i=0; i<numSounds; i++) { |
|||
|
|||
fill(150); |
|||
if(samples[i][beat]) { |
|||
fill(0, 200, 0); |
|||
file[i].stop(); |
|||
file[i].play(); |
|||
} |
|||
rect((width/divider)*beat,(height/numSounds)*i, width/divider, height/numSounds); |
|||
|
|||
} |
|||
|
|||
beat++; |
|||
if(beat>=divider){beat=0;} |
|||
|
|||
delay(duration); |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
int ereaseRow = 0; |
|||
|
|||
void setBeat(int index, int sample) { |
|||
samples[sample][index] = true; |
|||
} |
|||
|
|||
|
|||
void keyPressed() { |
|||
if(keyCode >= 48 && keyCode < 53) { |
|||
ereaseRow = keyCode-48; |
|||
println("Set ereaseRow"+ereaseRow); |
|||
} else { |
|||
int sample = keyCode-65; |
|||
println(sample); |
|||
if(sample >= 0 && sample < numSounds) { |
|||
println("ereaseRow"+ereaseRow); |
|||
setBeat(beat, sample); |
|||
|
|||
if(ereaseRow>0) { |
|||
for(int x=0; x<divider; x++) { |
|||
samples[ereaseRow-1][x] = false; |
|||
} |
|||
//ereaseRow = 0; |
|||
} |
|||
} |
|||
} |
|||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,28 @@ |
|||
void loadData() { |
|||
|
|||
numSounds = 10; |
|||
numTracks = numSounds;//4; |
|||
bpm = 280; |
|||
divider = 16; |
|||
duration = int((60/float(bpm))*1000); |
|||
beat = 0; |
|||
|
|||
String bank = "bank1"; |
|||
|
|||
samples = new boolean[numTracks][divider]; |
|||
for(int i=0; i<numTracks; i++) { |
|||
boolean[] tmp = new boolean[divider]; |
|||
for(int x=0; x<divider; x++) { |
|||
tmp[x] = false; |
|||
} |
|||
|
|||
samples[i] = tmp; |
|||
} |
|||
|
|||
// Load sound files |
|||
file = new SoundFile[numSounds]; |
|||
for (int i = 0; i < numSounds; i++) { |
|||
file[i] = new SoundFile(this, bank + "/" + (i+1) + ".wav"); |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue