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 / August 2006

Tip: Looking for answers? Try searching our database.

Concatenating wavs with Java

Thread view: 
Big D - 17 Aug 2006 01:10 GMT
Hey there.  I'd like to concatenate multiple wav files together.  I've
got an almost completely working system for it, actually...  I'm using
AudioSystem.write and my own subclass of AudioInputStream to do it.  

Basically, my AudioInputStream contains a List of AudioInputStreams that
came from the wav files I want to concatenate, and
for each stream added, I add its frameLength to my subclass's framelength
so it reports as being the
right length.  All my source wav files are the same type, so that is a safe
assumption to make.

Then when it comes time to read, my AudioInputStream just overrides the
read methods and calls read on each subsequent stream in its List.

It all works pretty well.  When I open the resulting output in Audacity, it
plays perfectly.   However, when I open it with Windows Media Player, it
reports an error mid-way through and then stops playing 2 seconds from the  
end of the file.

When I export the file I created from Audacity as a wav, it creates a wav
of exactly the same number of bytes, however when I compare my output and
Audacity's output in a hex editor, I see that some of the bytes are
different throughout the files.

Can anyone tell me what I'm doing wrong / how to get the wavs I create to
work in media player?

I considered that maybe I'm getting the headers repeatedly in there, but
I've discounted that possibility because I can successfully concatenate my
test wavs 20+ times with repetitions and it plays fine every time until 2
seconds before the end.  If I'd gotten headers in there, I'd expect them to
make popping sounds or screw things up earlier.

Thanks for any advice!
admin@sagewire.org - 17 Aug 2006 04:11 GMT
Have you stumbled across this yet in your search?  Seems to be on
target with what you're doing and there are some source code examples:

http://www.jsresources.org/examples/AudioConcat.html

Hope that helps.

---------------------------------------------------------------------------
http://www.sagewire.org/

> Hey there.  I'd like to concatenate multiple wav files together.  I've
> got an almost completely working system for it, actually...  I'm using
[quoted text clipped - 30 lines]
>
> Thanks for any advice!
Big D - 17 Aug 2006 11:42 GMT
I hadn't found that - thanks!

Unfortunately, this code seems to be doing exactly what I'm doing.  There
are a couple minor differences, though (like, I get the audio format from
the first source file instead of hard coding it, and I aggregate the
framelengths in my subclass rather than calculating each time).  I'll give
it another look-over next to my code and see if there are any other
differences.  I'll also probably compile that and see if it has the same
problem as mine - maybe whoever wrote it never tested with WMP. :-)

Thanks!

> Have you stumbled across this yet in your search?  Seems to be on
> target with what you're doing and there are some source code examples:
[quoted text clipped - 5 lines]
> -----------------------------------------------------------------------
> ---- http://www.sagewire.org/


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.