Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Playback of large WAV files...

Thread view: 
ew75@yahoo.com - 05 Sep 2006 15:40 GMT
I'm writing an application to play a large WAV file (say a couple
hundred of megs), and allow the user to jump to / select a position in
the file (e.g. 120 seconds into it) to start playback.  The "skip"
method of AudioInputStream always seems to return the value "4096",
meaning it skipped 4K, no matter how far I actually tell it to skip.
While a "Clip" would seem to be the ideal method, it doesn't support
large files (over 5 meg?).

Anybody else do something similar and want to share some advice?  Or
have any idea why "skip" doesn't skip to where I want it?
Andrew Thompson - 05 Sep 2006 15:49 GMT
> I'm writing an application to play a large WAV file (say a couple
> hundred of megs),

That is *huge*.  What compression are these files using?
If using an efficient form osf compression, the files will
become much larger still, in memory.

>..and allow the user to jump to / select a position in
> the file (e.g. 120 seconds into it) to start playback.  The "skip"
[quoted text clipped - 3 lines]
> While a "Clip" would seem to be the ideal method, it doesn't support
> large files (over 5 meg?).

Perhaps you need to break the files into smaller parts.

> Anybody else do something similar and want to share some advice?  Or
> have any idea why "skip" doesn't skip to where I want it?

The secret to that lies in the JavaDocs for the next-listed method.
<http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/sampled/AudioInputStream.htm
l#available
()>

Andrew T.
Oliver Wong - 05 Sep 2006 17:46 GMT
>> The "skip"
>> method of AudioInputStream always seems to return the value "4096",
>> meaning it skipped 4K, no matter how far I actually tell it to skip.
[...]
>> Anybody else do something similar and want to share some advice?  Or
>> have any idea why "skip" doesn't skip to where I want it?

> The secret to that lies in the JavaDocs for the next-listed method.
> <http://java.sun.com/j2se/1.5.0/docs/api/javax/sound/sampled/AudioInputStream.htm
l#available
()>

   available() will only tell you how many bytes can be read without
blocking. You're free to request a read of more than that many bytes; it
simply means your request will (probably) cause some blocking.

   To the OP, did you try values which are multiples of 4096? E.g. 8192 or
12288? Skip will "round" to the nearest frame. Maybe all your frames are
4096 bytes in size.

   - Oliver
Brandon McCombs - 06 Sep 2006 03:42 GMT
>> I'm writing an application to play a large WAV file (say a couple
>> hundred of megs),
>
> That is *huge*.  What compression are these files using?
> If using an efficient form osf compression, the files will
> become much larger still, in memory.

Not really. A typical MP3 of a song is about 4 or 5 megs at 192kbps
(exact size dependent on song length of course). With MP3 you can expect
about a 5:1 compression ratio so the original WAV is approximately 50
megabytes. He is working with files then about 4 times the size of a
typical song (~4 minutes long).  He may very well be working with a 20
minute file with average bitrate or a shorter file with high bitrate.
WAV is not usually compressed and contains data in PCM format which
explains why files can be, as you say, *huge*. In reality, they aren't
huge for that format because they aren't compressed. But are they huge
compared to their compressed MP3 cousin? You could make that argument.

Brandon
HMBA - 11 Sep 2006 05:06 GMT
Just wanted to follow up with a thank you for all of the feedback.  The
heads-up re: buffer size and blocking, and the references to JMF
reading material were helpful and greatly appreciated!
Knute Johnson - 05 Sep 2006 19:04 GMT
> I'm writing an application to play a large WAV file (say a couple
> hundred of megs), and allow the user to jump to / select a position in
[quoted text clipped - 6 lines]
> Anybody else do something similar and want to share some advice?  Or
> have any idea why "skip" doesn't skip to where I want it?

My guess is that you can't skip beyond the limits of the buffer in the
AudioInputStream.  I would try using a FileInputStream and see if that
allows you to skip to where you want.  Then read the file and write the
data to a SourceDataLine.

Signature

Knute Johnson
email s/nospam/knute/

Matt Humphrey - 05 Sep 2006 21:13 GMT
> I'm writing an application to play a large WAV file (say a couple
> hundred of megs), and allow the user to jump to / select a position in
[quoted text clipped - 6 lines]
> Anybody else do something similar and want to share some advice?  Or
> have any idea why "skip" doesn't skip to where I want it?

If you're using JMF (or would like to), the book "Swing Hacks" by Marinacci
and Adamson show how to progressively load and play audio media.  The code
samples there are excellent.

Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.