• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Length of Audio Clip in seconds

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic