Browse Source

add PLAY/STOP

develop
Carmine De Rosa 5 years ago
parent
commit
9e6425041a
  1. 27
      Processing/TESTS/Sampler/Sampler.pde
  2. 21
      Processing/TESTS/Sampler/SetBeat.pde
  3. 16
      Processing/TESTS/Sampler/controllerStatus.pde

27
Processing/TESTS/Sampler/Sampler.pde

@ -13,7 +13,7 @@ int beat = 0;
boolean[][] samples; boolean[][] samples;
void setup() { void setup() {
size(640, 360);
size(640, 460);
background(255); background(255);
loadData(); loadData();
@ -21,33 +21,42 @@ void setup() {
} }
void draw() { void draw() {
background(255);
background(50);
stroke(255); stroke(255);
fill(200);
printControllerStatus();
if(controller[0] == "PLAY") {
for(int i=0; i<numSounds; i++) { for(int i=0; i<numSounds; i++) {
fill(90);
for(int y=0; y<divider; y++) { for(int y=0; y<divider; y++) {
rect((width/divider)*y,(height/numSounds)*i, width/divider, height/numSounds);
fill(samples[i][y] ? 120: 90);
rect((width/divider)*y,((height-100)/numSounds)*i, width/divider, (height-100)/numSounds);
} }
} }
for(int i=0; i<numSounds; i++) { for(int i=0; i<numSounds; i++) {
fill(150); fill(150);
if(samples[i][beat]) { if(samples[i][beat]) {
fill(0, 200, 0); fill(0, 200, 0);
file[i].stop(); file[i].stop();
file[i].play(); file[i].play();
} }
rect((width/divider)*beat,(height/numSounds)*i, width/divider, height/numSounds);
rect((width/divider)*beat,((height-100)/numSounds)*i, width/divider, (height-100)/numSounds);
} }
beat++; beat++;
if(beat>=divider){beat=0;} if(beat>=divider){beat=0;}
if(ereaseRow>0 && doErease && beat==0) {
for(int x=0; x<divider; x++) {
samples[ereaseRow-1][x] = false;
}
ereaseRow = 0;
doErease = false;
}
}
delay(duration); delay(duration);
} }

21
Processing/TESTS/Sampler/SetBeat.pde

@ -1,27 +1,24 @@
int ereaseRow = 0; int ereaseRow = 0;
boolean doErease = false;
void setBeat(int index, int sample) { void setBeat(int index, int sample) {
samples[sample][index] = true; samples[sample][index] = true;
} }
void keyPressed() { void keyPressed() {
println(keyCode);
if(keyCode >= 48 && keyCode < 53) { if(keyCode >= 48 && keyCode < 53) {
ereaseRow = keyCode-48; ereaseRow = keyCode-48;
println("Set ereaseRow"+ereaseRow);
} else if(keyCode >= 74) {
if(key == 'p') {
controller[0] = controller[0] == "PLAY" ? "STOP" : "PLAY";
beat=0;
}
} else { } else {
int sample = keyCode-65; int sample = keyCode-65;
println(sample);
if(sample >= 0 && sample < numSounds) {
println("ereaseRow"+ereaseRow);
doErease = ereaseRow>0;
if(sample >= 0 && sample < numSounds && !doErease) {
setBeat(beat, sample); setBeat(beat, sample);
if(ereaseRow>0) {
for(int x=0; x<divider; x++) {
samples[ereaseRow-1][x] = false;
}
//ereaseRow = 0;
}
} }
} }
} }

16
Processing/TESTS/Sampler/controllerStatus.pde

@ -0,0 +1,16 @@
String[] controller = {"STOP", "REC", "BANK", "PATTERN"};
void printControllerStatus() {
fill(200);
text("PLAY/STOP:", 10, height-75);
text("REC/OVERDUB/ERASE:", 10, height-55);
text("BANK:", 10, height-35);
text("PATTERN/BPM/SWING:", 10, height-15);
fill(240);
text(controller[0], 180, height-75);
text(controller[1], 180, height-55);
text(controller[2], 180, height-35);
text(controller[3], 180, height-15);
}
Loading…
Cancel
Save