I\'m using AudioRecord to record 16 bit PCM data in android. After recording the data and saving it to a file, I read it back to save it as .wav file.
The problem is
Are you certain of the byte order? "RIFF", "WAV", "fmt", and "data" look fine but the numbers in the header may need to be a different order (little endian vs. big endian). You also don't need to convert to bytes manually using your intToByteArray
method. You could use the writeInt
and writeShort
methods of DataOutputStream
. For the first one, this would look something like:
outFile.writeInt(Integer.reverseBytes((int)myChunkSize));
For the shorts it'd be like:
outFile.writeShort(Short.reverseBytes((short)myFormat))
This way you also don't need to provide the offset and length (0, 4)
numbers. It's nice.