Writing PCM recorded data into a .wav file (java android)

后端 未结 4 496
别跟我提以往
别跟我提以往 2020-11-30 23:33

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

4条回答
  •  借酒劲吻你
    2020-12-01 00:00

    I've been wrestling with this exact same question for hours now, and my issue was mostly that when recording in 16 bits you have to be very careful about what you write to the output. The WAV file expects the data in Little Endian format, but using writeShort writes it to the output as Big Endian. I also got interesting results when using the other functions so I returned to writing bytes in the correct order and that works.

    I used a Hex editor extensively while debugging this. I can recommend you do the same. Also, the header in the answer above works, I used it to check versus my own code and this header is rather foolproof.

提交回复
热议问题