Get audio play position or length in seconds

How do you go about getting the current play position or length of an audio file in seconds?

I know the function .getPosition() will return a value from 0.0f - 1.0f of where you are currently in an audio file but it does not give me an exact position, simply a percentage of the length.

Is there is a function or formula for determining the length of an audio file in seconds and current play position in seconds?

Thanks.

With ofFmodSoundPlayer you can get the duration in seconds with

  
  
ofFmodSoundPlayer player;  
player.loadSound("yourSound.wav", false);  
float durationInSeconds = player.length/player.internalFreq;  
  

1 Like