Quantizing a audiorecorder sample

6 ビュー (過去 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 Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by