使用sin函数,我试图生成一种声音,其频率在1秒内从minFreq增大到maxFreq,然后又回到minFreq,然后又开始增大。
Here's my code and my unexpected result
在频谱图上您可以看到,频率并没有完全回到minFreq。
我检查了freq的值,它们始终在minFreq和maxFreq之间,所以我不明白为什么会这样。
有人知道为什么会这样吗?
如果您想自己尝试,请贴上我的代码:
pkg load signal;
function ret = genSon(duration, lapDuration)
rate = 44100.0;
minFreq = 50.0;
maxFreq = 3000.0;
ret = zeros(rate * duration, 1);
radialisation = 2.0 * pi / rate;
step = (maxFreq - minFreq) / (lapDuration * rate);
freq = minFreq;
for i = 1:size(ret, 1)
freq = freq + step;
if(freq > maxFreq)
freq = minFreq;
endif
ret(i) = sin( i * radialisation * freq );
endfor
endfunction
son = genSon(4, 1);
specgram(son);