diff --git a/Processing/TESTS/Sampler/Sampler.pde b/Processing/TESTS/Sampler/Sampler.pde index ffe8f36..1360c87 100644 --- a/Processing/TESTS/Sampler/Sampler.pde +++ b/Processing/TESTS/Sampler/Sampler.pde @@ -2,29 +2,21 @@ import processing.sound.*; SoundFile[] file; -// Define the number of samples -int numsounds = 5; -int bpm = 280; -int divider = 16; -int duration = int((60/float(bpm))*1000); +// Initialize data +int numSounds = 0; +int numTracks = 0; +int bpm = 0; +int divider = 0; +int duration = 0; int beat = 0; -int[][] samples = { - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} -}; +int[][] samples; void setup() { size(640, 360); background(255); - // Load sound files - file = new SoundFile[numsounds]; - for (int i = 0; i < numsounds; i++) { - file[i] = new SoundFile(this, "bank1/" + (i+3) + ".wav"); - } + loadData(); } @@ -46,7 +38,8 @@ void draw() { fill(150); if(samples[i][beat] != 0) { fill(0, 200, 0); - file[samples[i][beat]+1].play(); + file[samples[i][beat]].stop(); + file[samples[i][beat]].play(); } rect((width/divider)*beat,(height/4)*i, width/divider, height/4); diff --git a/Processing/TESTS/Sampler/SetBeat.pde b/Processing/TESTS/Sampler/SetBeat.pde index ac24569..7822467 100644 --- a/Processing/TESTS/Sampler/SetBeat.pde +++ b/Processing/TESTS/Sampler/SetBeat.pde @@ -11,7 +11,7 @@ void keyPressed() { } else { int sample = keyCode-65; println(sample); - if(sample >= 0 && sample < numsounds) { + if(sample >= 0 && sample < numSounds) { setBeat(activeRow, beat, sample); } } diff --git a/Processing/TESTS/Sampler/data/bank1/12.wav b/Processing/TESTS/Sampler/data/bank1/2.wav similarity index 100% rename from Processing/TESTS/Sampler/data/bank1/12.wav rename to Processing/TESTS/Sampler/data/bank1/2.wav diff --git a/Processing/TESTS/Sampler/loadData.pde b/Processing/TESTS/Sampler/loadData.pde new file mode 100644 index 0000000..f98cfd7 --- /dev/null +++ b/Processing/TESTS/Sampler/loadData.pde @@ -0,0 +1,28 @@ +void loadData() { + + numSounds = 5; + numTracks = 4; + bpm = 280; + divider = 16; + duration = int((60/float(bpm))*1000); + beat = 0; + + String bank = "bank1"; + + samples = new int[numTracks][divider]; + for(int i=0; i