diff --git a/Processing/Sampler/Sampler.pde b/Processing/Sampler/Sampler.pde index ba0f356..4728b46 100644 --- a/Processing/Sampler/Sampler.pde +++ b/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=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){beat=0;} - + delay(duration); } diff --git a/Processing/Sampler/SetBeat.pde b/Processing/Sampler/SetBeat.pde index b09c06d..d1f86f2 100644 --- a/Processing/Sampler/SetBeat.pde +++ b/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= 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); } } } diff --git a/Processing/Sampler/controllerStatus.pde b/Processing/Sampler/controllerStatus.pde new file mode 100644 index 0000000..e0a73d1 --- /dev/null +++ b/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); +} diff --git a/Processing/Sampler/data/bank1/6.wav b/Processing/Sampler/data/BANK1/1.wav similarity index 100% rename from Processing/Sampler/data/bank1/6.wav rename to Processing/Sampler/data/BANK1/1.wav diff --git a/Processing/Sampler/data/bank1/7.wav b/Processing/Sampler/data/BANK1/2.wav similarity index 100% rename from Processing/Sampler/data/bank1/7.wav rename to Processing/Sampler/data/BANK1/2.wav diff --git a/Processing/Sampler/data/bank1/8.wav b/Processing/Sampler/data/BANK1/3.wav similarity index 100% rename from Processing/Sampler/data/bank1/8.wav rename to Processing/Sampler/data/BANK1/3.wav diff --git a/Processing/Sampler/data/bank1/9.wav b/Processing/Sampler/data/BANK1/4.wav similarity index 100% rename from Processing/Sampler/data/bank1/9.wav rename to Processing/Sampler/data/BANK1/4.wav diff --git a/Processing/Sampler/data/bank1/10.wav b/Processing/Sampler/data/BANK1/5.wav similarity index 100% rename from Processing/Sampler/data/bank1/10.wav rename to Processing/Sampler/data/BANK1/5.wav diff --git a/Processing/Sampler/data/bank1/11.wav b/Processing/Sampler/data/BANK1/6.wav similarity index 100% rename from Processing/Sampler/data/bank1/11.wav rename to Processing/Sampler/data/BANK1/6.wav diff --git a/Processing/Sampler/data/bank1/1.wav b/Processing/Sampler/data/BANK2/1.wav similarity index 100% rename from Processing/Sampler/data/bank1/1.wav rename to Processing/Sampler/data/BANK2/1.wav diff --git a/Processing/Sampler/data/bank1/2.wav b/Processing/Sampler/data/BANK2/2.wav similarity index 100% rename from Processing/Sampler/data/bank1/2.wav rename to Processing/Sampler/data/BANK2/2.wav diff --git a/Processing/Sampler/data/bank1/3.wav b/Processing/Sampler/data/BANK2/3.wav similarity index 100% rename from Processing/Sampler/data/bank1/3.wav rename to Processing/Sampler/data/BANK2/3.wav diff --git a/Processing/Sampler/data/bank1/4.wav b/Processing/Sampler/data/BANK2/4.wav similarity index 100% rename from Processing/Sampler/data/bank1/4.wav rename to Processing/Sampler/data/BANK2/4.wav diff --git a/Processing/Sampler/data/bank1/5.wav b/Processing/Sampler/data/BANK2/5.wav similarity index 100% rename from Processing/Sampler/data/bank1/5.wav rename to Processing/Sampler/data/BANK2/5.wav diff --git a/Processing/Sampler/data/bank1/2.aiff b/Processing/Sampler/data/bank1/2.aiff deleted file mode 100644 index 00f2e48..0000000 Binary files a/Processing/Sampler/data/bank1/2.aiff and /dev/null differ diff --git a/Processing/Sampler/loadData.pde b/Processing/Sampler/setData.pde similarity index 74% rename from Processing/Sampler/loadData.pde rename to Processing/Sampler/setData.pde index 5090ff6..626a942 100644 --- a/Processing/Sampler/loadData.pde +++ b/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=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){beat=0;} - + delay(duration); } diff --git a/Processing/TESTS/Sampler/SetBeat.pde b/Processing/TESTS/Sampler/SetBeat.pde index b09c06d..6f9d61d 100644 --- a/Processing/TESTS/Sampler/SetBeat.pde +++ b/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; x0; + if(sample >= 0 && sample < numSounds && !doErease) { + if(controller[1] != "EREASE" && controller[1] != "UNSET") { + setBeat(beat, sample); } } } diff --git a/Processing/TESTS/Sampler/controllerStatus.pde b/Processing/TESTS/Sampler/controllerStatus.pde new file mode 100644 index 0000000..6be7956 --- /dev/null +++ b/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); +}