Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Audio File Play length

Status
Not open for further replies.

THEMAN101

Programmer
Apr 29, 2003
44
US
I have an audio file array declared like so:

java.io.File[] file = new java.io.File[151];
for (int w = 0; w < 151; w++)
{
file[w] = new java.io.File(voice+"/"+letters[w]+".wav");
}
java.applet.AudioClip[] letAud = new java.applet.AudioClip[151];

try
{
for (int r = 0; r < 151; r++)
{
letAud[r] = java.applet.Applet.newAudioClip(file[r].toURL());
}
}


I would then like to find out how long it is.

Something like:

letAud[x].getNumberOfFrames() * letAud[x].getFrameRate();

This would then yeild the length of the audio file. Now how would i write the above code so that it would compile (LOL).

Thanks
 
Looked at the javadoc and found these classes... See if they r of any use -

javax.sound.sampled.AudioFormat
javax.sound.sampled.AudioInputStream

The above classes have methods to meet ur requirement (getFrameLength, getFrameRate). There are more interesting classes in the same package so check them out too.



LOL A ship is safe in the harbour, but that's not what it is meant for!!! LOL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top