1

我一直在尝试使用 Matlab 制作和理解 ADC。我制作了这个小程序,允许我修改波形的位数(2^8,8 是位数,可以从 1 到 64)。但是,在计算机中播放声音时,听起来好像有什么东西停止了声音。可以更改频率,但问题仍然存在。我想知道我做错了什么?

clf                         %clr screen

t = 0:1:1600                  
fs = 1000                      

senial = sin((2*pi*t)/fs)       

quant=max(senial)/(2^8)          % R/L = size of sep

y=round(senial/quant)            % Quantizationto 2^N bit 
signe=uint8((sign(y)'+1)/2)      % transforms it to int 8 bit
out=[signe]                      % The first bit represents the sign of the number

sound(y,fs)
plot(y,'b');
4

1 回答 1

2

有几件事。首先,您生成的正弦波只有 1Hz,因此您永远听不到它。

t = 0:1:1600                  
fs = 1000           
freq = 440           

senial = sin(2*pi*t*freq/fs)
play(senial, 1000)

下一个问题是你的量化。除了没有将数据重新归一化到 -1 到 1 的范围外,您就快到了。你可能听到了削波。尝试这样的事情:

y = round(senial*2^8)/2^8

这是一个示例(再次为 1Hz 以使绘图更容易)

plot(round(sin(2*pi*t/1000)*2^4)/2^4)

在此处输入图像描述

于 2015-01-21T09:03:46.113 回答