Quantizing a audiorecorder sample

3 visualizzazioni (ultimi 30 giorni)
Kayne
Kayne il 12 Lug 2012
Risposto: Image Analyst il 29 Nov 2013
Hi,
I have used the audiorecorder() function in Matlab to record my voice with the following script
fs = 4000;
tmax = 4;
nbits =16;
nchan = 1;
%Now record my voice for x second
Recorder = audiorecorder(fs,nbits,nchan);
record(Recorder);
fprintf(1,'recording....\n');
pause(tmax);
stop(Recorder);
%covert to floating-point vector and play back
yi = getaudiodata(Recorder,'int16');
y = double(yi);
y = y/max(abs(y));
plot(y)
sound(y,fs);if true
end
I would like to now quantize the audio sample from 16bit and remove the least significant bit eventually until there is only 1 bit left.
I have been trying to use the quantize function but I am not sure how to make it work with my script. Thats if it can be done using this function to start with.
Any guidance would be great.
Thanks
  1 Commento
Remi
Remi il 29 Nov 2013
Any luck in this ?, If so it would be very helpful for me.
Thanks

Accedi per commentare.

Risposte (1)

Image Analyst
Image Analyst il 29 Nov 2013
Just either use bitshift(), or divide your image by 2 at each step. Here it is both ways:
y=uint16(341)
y1 = y
dec2bin(y)
while y > 1
% Method 1: using bitshift
y = bitshift(y, -1)
dec2bin(y)
% Method 2: using division.
y1 = uint16(floor(double(y1)/2))
dec2bin(y1)
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by