How to write out wave file using Java Sound API?

J

John

Hi,

I receive audio via a socket. I receive 16-bit, mono, 8000sps data. I
can play this out the speaker using Java Sound perfectly. It's
wonderful how much easier this is than DirectX.

Anyway, I need to be able to save the data I receive for later play
back. I was going to write the Wave header myself, but it seems like
there should be some way to write out the data using Java Sound.

I create a ByteArrayInputStream. I create an AudioInputStream from
this. I then call AudioSystem.write() using the AudioInputStream and a
FileOutputStream.

I can hear the sounds, but it has pops in it. I'm guessing that it is
writing out a WAVE header for every call to AudioSystem.write(). How do
I tell it that I'm going to call AudioSystem.write() many times and
only write out one header?

I tried using AU and got the same results.

THANKS!
John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top