Quantizing a audiorecorder sample

조회 수: 4 (최근 30일)
Kayne
Kayne 2012년 7월 12일
답변: Image Analyst 2013년 11월 29일
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
Remi
Remi 2013년 11월 29일
Any luck in this ?, If so it would be very helpful for me.
Thanks

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2013년 11월 29일
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

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by