• Post Reply Bookmark Topic Watch Topic
  • New Topic

Length of Audio Clip in seconds

 
Manoj Tyagi
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I have to display the running length of Audio clip (in seconds) before playing it.

java.applet package does not give any such method.

I was also looking into javax.sound.sampled package but could not figure out the exact way.

Can any one offer me some solution for getting the audio length.


Thanks,

Manoj
 
Christopher Arthur
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know the uncompressed length in bytes of the sample, the sampling rate, and the sample size (16-bit or 8-bit) you can figure it out:

Example: If you have a 200KB 16-bit stereo sample at 44.1KHz (CD quality), then the length is computed as follows

16 bits * 2 channels * 44100 = 164000 bytes/sec

so, 200KB/164000 = 1.2195 seconds

Chris
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!