Emulating sox trim using java sound APIs
843802Mar 28 2010 — edited Mar 28 2010Hi,
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.