在特定持续时间内生成频率的斜坡音频信号



我想以 10hz 的步长生成 10hz 到 1000hz 的频率,假设在 5 秒内(所有频率在时间范围内平均分布(。如何通过下面的单个频率发生器功能实现这一点?

function [ ] = producefeq( frequency, duration, amplitude, freqsampling )
if ~exist('freqsampling', 'var'), freqsampling = 44100; end
if ~exist('amplitude', 'var'), amplitude = 1; end
if nargin <2, error('Not enough input arguments'); end
% the frequency argument will be like this for the case above 10:10:1000
t = 0:(1/freqsampling):duration;
y = amplitude*sin(2*pi*frequency*t);
sound(y, freqsampling);
end

提前感谢!

您可以多次调用producefeq,并使用pause在多次执行之间等待。

totalDuration = 500;
frequencies = 10:10:1000;
duration = totalDuration/length(frequencies);
for i = 1:length(frequencies)
    producefeq( frequencies(i), duration)
    pause(duration)
end

最新更新