Quantizing a audiorecorder sample
7 次查看(过去 30 天)
显示 更早的评论
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 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!