I\'m trying to use recorderjs on an app engine site where users upload short audio recordings (say, 1 to a dozen seconds long). I\'ve noticed that the WAV files I\'m uploadi
I'm using the same recorder code and I needed to lower the bit rate. My solution produces a 11025Hz mono file. it's not very elegant so I'll be glad if someone has corrections for me.
First I change sample rate in the init
function to be 11025 instead of the audio context's bit rate (this is the non elegant part since the context might not be 44100Hz).
I replace the interleave
function content with this
var length = inputL.length / 4;
var result = new Float32Array(length);
var index = 0,
inputIndex = 0;
while (index < length) {
result[index++] = 0.25 * (inputL[inputIndex++] + inputL[inputIndex++] +
inputL[inputIndex++] + inputL[inputIndex++]);
}
return result;
This takes only the left channel and turns every 4 buffer samples into 1 in the result so it takes up less memory. if the bit rate is changed by the same ratio (divided by 4 e.g. 11025), the file will sound the same but will be much smaller.
I also changed the channel count in encodeWAV
to one
/* channel count */
view.setUint16(22, 1, true);
The recording will be 1/8 in size compared to originally produced file.