I have a pcm file, and I want to convert it to a wav file.
Is there any suitable api or code for this?
I cannot yet leave comments, but be aware that the get16BitPcm method in devflow's answer is [oddly] scaling the input data. If you already have 16 bit pcm data to write to the wav file, the method should look something like this:
public byte[] get16BitPcm(short[] data) {
byte[] resultData = new byte[2 * data.length];
int iter = 0;
for (short sample : data) {
resultData[iter++] = (byte)(sample & 0x00ff);
resultData[iter++] = (byte)((sample & 0xff00) >>> 8);
}
return resultData;
}