Browse Source

add erease

develop
Carmine De Rosa 5 years ago
parent
commit
50f0a23edc
  1. 16
      Processing/TESTS/Sampler/Sampler.pde
  2. 21
      Processing/TESTS/Sampler/SetBeat.pde
  3. 10
      Processing/TESTS/Sampler/loadData.pde

16
Processing/TESTS/Sampler/Sampler.pde

@ -10,7 +10,7 @@ int divider = 0;
int duration = 0; int duration = 0;
int beat = 0; int beat = 0;
int[][] samples;
boolean[][] samples;
void setup() { void setup() {
size(640, 360); size(640, 360);
@ -24,24 +24,24 @@ void draw() {
background(255); background(255);
stroke(255); stroke(255);
for(int i=0; i<4; i++) {
for(int i=0; i<numSounds; i++) {
fill(90); fill(90);
for(int y=0; y<divider; y++) { for(int y=0; y<divider; y++) {
rect((width/divider)*y,(height/4)*i, width/divider, height/4);
rect((width/divider)*y,(height/numSounds)*i, width/divider, height/numSounds);
} }
} }
for(int i=0; i<4; i++) {
for(int i=0; i<numSounds; i++) {
fill(150); fill(150);
if(samples[i][beat] != 0) {
if(samples[i][beat]) {
fill(0, 200, 0); fill(0, 200, 0);
file[samples[i][beat]].stop();
file[samples[i][beat]].play();
file[i].stop();
file[i].play();
} }
rect((width/divider)*beat,(height/4)*i, width/divider, height/4);
rect((width/divider)*beat,(height/numSounds)*i, width/divider, height/numSounds);
} }

21
Processing/TESTS/Sampler/SetBeat.pde

@ -1,18 +1,27 @@
int activeRow = 0;
int ereaseRow = 0;
void setBeat(int row, int index, int sample) {
samples[row][index] = sample;
void setBeat(int index, int sample) {
samples[sample][index] = true;
} }
void keyPressed() { void keyPressed() {
if(keyCode >= 49 && keyCode < 53) {
activeRow = keyCode-49;
if(keyCode >= 48 && keyCode < 53) {
ereaseRow = keyCode-48;
println("Set ereaseRow"+ereaseRow);
} else { } else {
int sample = keyCode-65; int sample = keyCode-65;
println(sample); println(sample);
if(sample >= 0 && sample < numSounds) { if(sample >= 0 && sample < numSounds) {
setBeat(activeRow, beat, sample);
println("ereaseRow"+ereaseRow);
setBeat(beat, sample);
if(ereaseRow>0) {
for(int x=0; x<divider; x++) {
samples[ereaseRow-1][x] = false;
}
//ereaseRow = 0;
}
} }
} }
} }

10
Processing/TESTS/Sampler/loadData.pde

@ -1,7 +1,7 @@
void loadData() { void loadData() {
numSounds = 5;
numTracks = 4;
numSounds = 10;
numTracks = numSounds;//4;
bpm = 280; bpm = 280;
divider = 16; divider = 16;
duration = int((60/float(bpm))*1000); duration = int((60/float(bpm))*1000);
@ -9,11 +9,11 @@ void loadData() {
String bank = "bank1"; String bank = "bank1";
samples = new int[numTracks][divider];
samples = new boolean[numTracks][divider];
for(int i=0; i<numTracks; i++) { for(int i=0; i<numTracks; i++) {
int[] tmp = new int[divider];
boolean[] tmp = new boolean[divider];
for(int x=0; x<divider; x++) { for(int x=0; x<divider; x++) {
tmp[x] = 0;
tmp[x] = false;
} }
samples[i] = tmp; samples[i] = tmp;

Loading…
Cancel
Save