如何用带通滤波器合成雷声

How to synthesize a thunder sound with bandpass filter

我正在 MATLAB 中合成雷声。 我产生了粉红噪声,现在我正尝试在 30Hz 上添加带通滤波器,但出现错误:

The frequency specifications Fpass, Fstop must have increasing values.

这是我的代码:

dur=[0:1/Fs:time-1/Fs];
sz=length(dur);
g=randn(1, sz); %
Y=fft(g);

NumUniquePts = sz/2 + 1;
n = 1:NumUniquePts;
n = sqrt(n);
Y(1:NumUniquePts) = Y(1:NumUniquePts)./n;

Y(NumUniquePts+1:sz) = real(Y(sz/2:-1:2)) -1i*imag(Y(sz/2:-1:2));

y = ifft(Y);

y = real(y(1, 1:sz));

y = y - mean(y);
yrms = sqrt(mean(y.^2));
y = y/yrms;

d = fdesign.lowpass('Fp,Fst,Ap,Ast',30,10,0.5,50,48e4);
Hd1 = design(d,'equiripple');
Hd2 = design(d,'butter');

out = filter(Hd1,y);

也许还有其他合成方法?

I am getting an error. "The frequency specifications Fpass, Fstop must have increasing values."

这个错误意味着 Fstop 应该大于 Fpass。您提到您需要 Fpass=30Hz。所以你需要 Fstop > 30,但你指定了 10Hz 的值。要修复此错误,您应该增加 Fstop 值(例如,对于初学者为 100Hz,然后进行调整,直到获得您喜欢的值)。