kidult
Junior Member
Offline
Posts: 84
getCurrentFrame() + getNumFrame issues
Feb 26th , 2006, 1:45am
I wrote a small test program that draws a timeline a sample to test the getCurrentFrame and getNumFrames calls and the calls function correctly, but when I move the code to a larger program the getCurrentFrame and getNumFrame data is inconsistent and stops working. Is there an update or refresh function I can call to refresh the data? Because at the moment it works towards the middle of the sample and outputs 0 values the rest of the sample... has anyone else experienced inconsistencies w/ those functions? heres the code for the test program if anyones curious. import pitaru.sonia_v2_9.*; Sample mySample; void setup(){ size(200,200,P3D); ellipseMode(CENTER); rectMode(CENTER); Sonia.start(this); mySample = new Sample("FILENAME"); mySample.play(); // play the sample once. } void draw(){ if(mySample.isPlaying()) { noFill(); stroke(0); pushMatrix(); int timeline_width = 100; translate(timeline_width/2,height-30); float percent = float(mySample.getCurrentFrame())/float(mySample.getNumFrames()); float marker = percent*float(timeline_width); println("-------------------------"); println("mySample.getCurrentFrame()"+mySample.getCurrentFrame()); println("mySample.getNumFrames()"+mySample.getNumFrames()); println("percent: "+percent); println("timeline_width: "+timeline_width); println("marker: "+marker); line(marker,0,marker,-10); //line(0, 10, timeline_width, 10); for(int i = 0; i < timeline_width; i +=10) { line(i,0,i,-5); } line(0,0,0,-20); line(0, 0, timeline_width, 0); popMatrix(); } }