Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Emulating sox trim using java sound APIs

843802Mar 28 2010 — edited Mar 28 2010
Hi,

I would like to know if there is a way to split large wave files into smaller ones (approx 5 min clips, similar to "sox trim") using java sound APIs? I tried the following, but it doesn't seem to work for me

1. Open a wave file using AudioSystem.getAudioInputStream();
2. Read 300 * sample_rate * bytes_per_sample bytes into a buffer.
3. Read the written bytes back using AudioSystem.getAudioInputStream().
4. Write the stream using AudioSystem.write();

I can't get step 3 to work, possibly because headers are not written into the buffer and AudioSystem complains about unknown audio format. How do I get this working?

TIA.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2010
Added on Mar 28 2010
1 comment
222 views