Creating a WAV file from raw PCM data using the Android SDK

OK, I’ve got this figured out. This post was crucial in helping me:
http://computermusicblog.com/blog/2008/08/29/reading-and-writing-wav-files-in-java

Basically, I used ByteArrayOutputStream to write the raw PCM data from AudioRecord, which then lets me get the byte array and its size when the process is done. I can then use that data in conjunction with the SampleRate, BitRate, and Stereo/Mono settings to create the WAV header as per the link above. The resulting file works perfectly!

Leave a Comment