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

后端 未结 4 493
别跟我提以往
别跟我提以往 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

    As Ronald Kunenborg correctly states the problem is the Litte Endian / Big Endian conversion.

    The simplest way is to write a short helper like this:

    public static void writeShortLE(DataOutputStream out, short value) {
      out.writeByte(value & 0xFF);
      out.writeByte((value >> 8) & 0xFF);
    }
    

    This is very helpful if you record audio to a wave file with Android and you're in need of the short array, too.

    (Credits: https://stackoverflow.com/a/1394839/1686216)

提交回复
热议问题