Quantizing a audiorecorder sample

3 visualizaciones (últimos 30 días)
Kayne
Kayne el 12 de Jul. de 2012
Respondida: Image Analyst el 29 de Nov. de 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 comentario
Remi
Remi el 29 de Nov. de 2013
Any luck in this ?, If so it would be very helpful for me.
Thanks

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 29 de Nov. de 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

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by