Browse Source

Merge branch 'feature/controller_buttons' into develop

develop
Dslak 5 years ago
parent
commit
2cbb239126
  1. 70
      Processing/Sampler/Sampler.pde
  2. 65
      Processing/Sampler/SetBeat.pde
  3. 28
      Processing/Sampler/controllerStatus.pde
  4. 0
      Processing/Sampler/data/BANK1/1.wav
  5. 0
      Processing/Sampler/data/BANK1/2.wav
  6. 0
      Processing/Sampler/data/BANK1/3.wav
  7. 0
      Processing/Sampler/data/BANK1/4.wav
  8. 0
      Processing/Sampler/data/BANK1/5.wav
  9. 0
      Processing/Sampler/data/BANK1/6.wav
  10. 0
      Processing/Sampler/data/BANK2/1.wav
  11. 0
      Processing/Sampler/data/BANK2/2.wav
  12. 0
      Processing/Sampler/data/BANK2/3.wav
  13. 0
      Processing/Sampler/data/BANK2/4.wav
  14. 0
      Processing/Sampler/data/BANK2/5.wav
  15. BIN
      Processing/Sampler/data/bank1/2.aiff
  16. 13
      Processing/Sampler/setData.pde
  17. 60
      Processing/TESTS/Sampler/Sampler.pde
  18. 28
      Processing/TESTS/Sampler/SetBeat.pde
  19. 16
      Processing/TESTS/Sampler/controllerStatus.pde

70
Processing/Sampler/Sampler.pde

@ -6,48 +6,70 @@ SoundFile[] file;
int numSounds = 0;
int numTracks = 0;
int bpm = 0;
int pattern = 0;
int swing = 0;
int divider = 0;
int duration = 0;
int beat = 0;
String patternLabel = "NO PATTERN";
String swingLabel = "100%";
boolean[][] samples;
void setup() {
size(640, 360);
size(640, 460);
background(255);
loadData();
setData();
}
void draw() {
background(255);
background(50);
stroke(255);
fill(200);
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);
}
}
printControllerStatus();
for(int i=0; i<numSounds; i++) {
if(controller[0] == "PLAY") {
for(int i=0; i<numSounds; i++) {
for(int y=0; y<divider; y++) {
fill(samples[i][y] ? 120: 90);
rect((width/divider)*y,((height-100)/numSounds)*i, width/divider, (height-100)/numSounds);
}
}
fill(150);
if(samples[i][beat]) {
fill(0, 200, 0);
file[i].stop();
file[i].play();
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-100)/numSounds)*i, width/divider, (height-100)/numSounds);
}
rect((width/divider)*beat,(height/numSounds)*i, width/divider, height/numSounds);
beat++;
if(beat>=divider){beat=0;}
// ################################## End of beat
if(beat==0) {
if(doRec == false) {
controller[1] = "UNSET";
}
doRec = false;
}
if(ereaseRow>0 && doErease && beat==0) {
for(int x=0; x<divider; x++) {
samples[ereaseRow-1][x] = false;
}
ereaseRow = 0;
doErease = false;
}
}
beat++;
if(beat>=divider){beat=0;}
delay(duration);
}

65
Processing/Sampler/SetBeat.pde

@ -1,26 +1,59 @@
int ereaseRow = 0;
boolean doErease = false;
boolean doRec = false;
boolean chooseBank = false;
boolean choosePattern = false;
boolean chooseBPM = false;
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;
//println(keyCode);
if(keyCode >= 64 && keyCode <= 88) { // From A to Z
//println(key);
//ereaseRow = keyCode-48;
if(key == 'b') { // BANK
chooseBank = true;
controller[0] = "STOP";
controller[2] = "CHOOSE...";
}
if(key == 'p') { // PLAY/STOP
controller[0] = controller[0] == "PLAY" ? "STOP" : "PLAY";
beat=0;
}
if(key == 'r') { // REC/OVERDUB
controller[1] = controller[1] == "UNSET" ? "REC/OVERDUB" : "UNSET";
doRec = true;
}
if(key == 'o') { // PATTERN
choosePattern = true;
controller[0] = "STOP";
patternLabel = "CHOOSE...";
}
if(key == 'x') { // EREASE
controller[1] = "EREASE";
}
} else if(keyCode >= 48 && keyCode < 57) { // From 1 to 9
int code = keyCode-49;
ereaseRow = controller[1] == "EREASE" ? keyCode-48 : 0;
doErease = ereaseRow>0;
if(code >= 0 && code < numSounds && !doErease) {
if(chooseBank) {
controller[2] = "BANK" + (code+1);
setData();
chooseBank = false;
} else if(choosePattern) {
pattern = (code+1);
patternLabel = "PATTERN" + (code+1);
setData();
choosePattern = false;
} else if(controller[1] != "EREASE" && controller[1] != "UNSET") {
setBeat(beat, code);
}
}
}

28
Processing/Sampler/controllerStatus.pde

@ -0,0 +1,28 @@
String[] controller = {"STOP", "UNSET", "BANK1", "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);
fill(200);
text("PATTERN:", (width/2)+20, height-75);
text("BPM:", (width/2)+20, height-55);
text("SWING:",(width/2)+20, height-35);
fill(240);
text(patternLabel, (width/2)+100, height-75);
text(bpm, (width/2)+100, height-55);
text(swing, (width/2)+100, height-35);
stroke(200);
line(width/2, height-85, width/2, height-15);
}

0
Processing/Sampler/data/bank1/6.wav → Processing/Sampler/data/BANK1/1.wav

0
Processing/Sampler/data/bank1/7.wav → Processing/Sampler/data/BANK1/2.wav

0
Processing/Sampler/data/bank1/8.wav → Processing/Sampler/data/BANK1/3.wav

0
Processing/Sampler/data/bank1/9.wav → Processing/Sampler/data/BANK1/4.wav

0
Processing/Sampler/data/bank1/10.wav → Processing/Sampler/data/BANK1/5.wav

0
Processing/Sampler/data/bank1/11.wav → Processing/Sampler/data/BANK1/6.wav

0
Processing/Sampler/data/bank1/1.wav → Processing/Sampler/data/BANK2/1.wav

0
Processing/Sampler/data/bank1/2.wav → Processing/Sampler/data/BANK2/2.wav

0
Processing/Sampler/data/bank1/3.wav → Processing/Sampler/data/BANK2/3.wav

0
Processing/Sampler/data/bank1/4.wav → Processing/Sampler/data/BANK2/4.wav

0
Processing/Sampler/data/bank1/5.wav → Processing/Sampler/data/BANK2/5.wav

BIN
Processing/Sampler/data/bank1/2.aiff

Binary file not shown.

13
Processing/Sampler/loadData.pde → Processing/Sampler/setData.pde

@ -1,13 +1,18 @@
void loadData() {
void setData() {
numSounds = 10;
numTracks = numSounds;//4;
numSounds = 5;
numTracks = numSounds;
bpm = 280;
pattern = 1;
swing = 50;
divider = 16;
duration = int((60/float(bpm))*1000);
beat = 0;
String bank = "bank1";
String bank = controller[2];
println(bank);
println(patternLabel);
samples = new boolean[numTracks][divider];
for(int i=0; i<numTracks; i++) {

60
Processing/TESTS/Sampler/Sampler.pde

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

28
Processing/TESTS/Sampler/SetBeat.pde

@ -1,26 +1,30 @@
int ereaseRow = 0;
boolean doErease = false;
boolean doRec = false;
void setBeat(int index, int sample) {
samples[sample][index] = true;
}
void keyPressed() {
println(keyCode);
if(keyCode >= 48 && keyCode < 53) {
ereaseRow = keyCode-48;
println("Set ereaseRow"+ereaseRow);
} else if(keyCode >= 74) {
if(key == 'p') {
controller[0] = controller[0] == "PLAY" ? "STOP" : "PLAY";
beat=0;
}
if(key == 'r') {
controller[1] = controller[1] == "UNSET" ? "REC/OVERDUB" : "UNSET";
doRec = true;
}
} 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;
doErease = ereaseRow>0;
if(sample >= 0 && sample < numSounds && !doErease) {
if(controller[1] != "EREASE" && controller[1] != "UNSET") {
setBeat(beat, sample);
}
}
}

16
Processing/TESTS/Sampler/controllerStatus.pde

@ -0,0 +1,16 @@
String[] controller = {"STOP", "UNSET", "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