|
Author |
Topic: play wav files in different bpms (Read 715 times) |
|
MrHunt
|
play wav files in different bpms
« on: Nov 4th, 2004, 4:18pm » |
|
I want to write an application that plays various wav files in different bpms.I have written a code and I want to know if thats ok or is there a more convinient way to do it?For example with LiveOutput. Here is the code: Sample[] mySample = new Sample[9]; int framerate=25; int maincounter=0; int[] bpm= {140,140,140,70,70,70,280,280,210}; //different bpms values for different files int[] dlay= {0,5,10,0,5,10,0,7,0}; //for the files that have same bpm there is a factor of delay int[] counter ={0,0,0,0,0,0,0,0,0}; //counter for every file int[] mod = new int[9]; //an array for holding the time when to play the related wav void initialize(){ for(int i=0;i<9;i++){ int j=i+1; mySample[i] = new Sample(j + ".wav"); mod[i]=(framerate*60)/bpm[i]; //here I calculate the counter time when the play the wav file } } void setup() { size(200,200); Sonia.start(this); framerate(framerate); initialize(); } void loop(){ background(0); maincounter++; //this is a main clock for (int i=0;i<9;i++){ if(maincounter>=dlay[i]) counter[i]++; //every wav has its own clock and starts to increment when the delay time is passed if((counter[i] % mod[i])==0){ mySample[i].play(); //if the time is ok play the file } } } public void stop(){ Sonia.stop(); super.stop(); } 1.The point I want to be sure is is this code really play files in the determined bpms or not? thanks. 2. I also wnat to know how far I can go with this code. Can Sonia handle for example 25-30 sample files?
|
|
|
|
|