Search code examples
matlabaudioquantization

Quantizing a audiorecorder sample in MATLAB


I have a recorded a sound wave (16-bit single channel) using audiorecorder and I need to quantize it into 15 bits (removing LSB) without using toolboxes other than MATLAB built-in ones. Can anyone help on this?

fs = 8000;
tmax = 2;
nbits = 16;
nchan = 1;
Recorder = audiorecorder(fs, nbits, nchan);
record(Recorder);
pause(tmax);
stop(Recorder);

Solution

  • You can use the bitshift function in MATLAB. I believe

    Recorder = audiorecorder(fs, nbits, nchan);
    data = getaudiodata(Recorder, 'int16');
    outData = bitshift(data, -1);
    

    Hope this helps.

    Dinesh