|
Author |
Topic: timing problem (Read 437 times) |
|
MrHunt
|
timing problem
« on: Nov 12th, 2004, 11:32pm » |
|
I have a problem that plays different sample files.3 of them play once at six frames.3 of them play once at 12 frames. 2 of them play once at 24 frames.The synchronization between the samples are ok.However sometimes the time when files should play delays.What can cause that problem. here is the code: Ses[] sesler=new Ses[8]; BFont font; int framerate1=25; int[] bpm= {12,12,12,6,6,24,24,9}; //------------------------------------------------ //---------------------------------------------------------------------- void initialize(){ for(int i=0;i<8;i++){ int j=i+1; sesler[i] = new Ses(random(10,290),random(10,230),int(random(0,255)),int(random(0,255)),int(random(0,255)),bpm[i]/7*2,bpm[i],j); } } void setup() { ellipseMode(CENTER_DIAMETER); size(320,240); font = loadFont("BauerBodoni.vlw.gz"); textFont(font,20); //---------------------------------------------- Sonia.start(this); framerate(framerate1); initialize(); } void loop(){ background(255); for (int i=0;i<7;i++){ sesler[i].update(); sesler[i].execute(); } } public void stop(){ Sonia.stop(); super.stop(); } ////////////////////////////////////////////// class Ses { ////////////////////////////7 float x,y; int r,g,b; int low_rad; int rad; ////////////////////////////// int bpm; int counter=0 ; int mod ; Sample _sample; int wavno; Ses(float x1,float y1,int r1 ,int g1,int b1,int rad1,int bpm1,int fname){ x=x1; y=y1; r=r1; g=g1; b=b1; low_rad=rad1; rad=low_rad; bpm=bpm1; mod=bpm; println(mod); _sample= new Sample(fname + ".wav"); wavno=fname; } void execute(){ float time; fill(r,g,b,90); ellipse(x,y,rad,rad); fill(0,0,0); text(bpm + ".",x,y); if((counter % mod)==0){ _sample.play(); time=millis(); rad=low_rad; } } void update(){ rad++; counter++; /*t ytemp=random(-1,1); if(x>10 && x<290) x += xtemp; if(y>10 && y<290) y += ytemp;*/ } }
|
|
|
|
fjen
|
Re: timing problem
« Reply #1 on: Nov 13th, 2004, 2:48am » |
|
i'm not 100 % sure, but i think this is due to timing problems in java. it depends on the system you are running on and how many other processes are running at the same time. anyway, i don't have a solution to this except not to rely on framerate(). maybe sonia implements a better timing? /F
|
|
|
|
MrHunt
|
Re: timing problem
« Reply #3 on: Nov 13th, 2004, 6:04pm » |
|
Do you think ,instead of using samples,liveoutput data can work?
|
|
|
|
fjen
|
Re: timing problem
« Reply #4 on: Nov 13th, 2004, 6:27pm » |
|
i'm not familiar with sonia, sorry.
|
|
|
|
|