Browse Source

setData

develop
Carmine De Rosa 5 years ago
parent
commit
cc5a9069f5
  1. 7
      Processing/Sampler/Sampler.pde
  2. 27
      Processing/Sampler/SetBeat.pde
  3. 14
      Processing/Sampler/controllerStatus.pde
  4. 5
      Processing/Sampler/setData.pde

7
Processing/Sampler/Sampler.pde

@ -6,16 +6,21 @@ SoundFile[] file;
int numSounds = 0; int numSounds = 0;
int numTracks = 0; int numTracks = 0;
int bpm = 0; int bpm = 0;
int pattern = 0;
int swing = 0;
int divider = 0; int divider = 0;
int duration = 0; int duration = 0;
int beat = 0; int beat = 0;
String patternLabel = "NO PATTERN";
String swingLabel = "100%";
boolean[][] samples; boolean[][] samples;
void setup() { void setup() {
size(640, 460); size(640, 460);
background(255); background(255);
loadData();
setData();
} }
void draw() { void draw() {

27
Processing/Sampler/SetBeat.pde

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

14
Processing/Sampler/controllerStatus.pde

@ -1,6 +1,5 @@
String[] controller = {"STOP", "UNSET", "BANK1", "PATTERN"}; String[] controller = {"STOP", "UNSET", "BANK1", "PATTERN"};
void printControllerStatus() { void printControllerStatus() {
fill(200); fill(200);
text("PLAY/STOP:", 10, height-75); text("PLAY/STOP:", 10, height-75);
@ -13,4 +12,17 @@ void printControllerStatus() {
text(controller[1], 180, height-55); text(controller[1], 180, height-55);
text(controller[2], 180, height-35); text(controller[2], 180, height-35);
text(controller[3], 180, height-15); 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);
} }

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

@ -1,8 +1,10 @@
void loadData() {
void setData() {
numSounds = 5; numSounds = 5;
numTracks = numSounds; numTracks = numSounds;
bpm = 280; bpm = 280;
pattern = 1;
swing = 50;
divider = 16; divider = 16;
duration = int((60/float(bpm))*1000); duration = int((60/float(bpm))*1000);
beat = 0; beat = 0;
@ -10,6 +12,7 @@ void loadData() {
String bank = controller[2]; String bank = controller[2];
println(bank); println(bank);
println(patternLabel);
samples = new boolean[numTracks][divider]; samples = new boolean[numTracks][divider];
for(int i=0; i<numTracks; i++) { for(int i=0; i<numTracks; i++) {
Loading…
Cancel
Save