We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › getCurrentFrame() + getNumFrame issues
Page Index Toggle Pages: 1
getCurrentFrame() + getNumFrame issues (Read 742 times)
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();
 }
}
Page Index Toggle Pages: 1