I am working on synthesizing sound of thunder in MATLAB. I had generated pink noise and now I'm trying to add bandpass filter on 30Hz, but I am getting the error:
The frequency specifications Fpass, Fstop must have increasing values.
Here's my code:
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);
Maybe there an other way to synthesize it?
I am getting an error. "The frequency specifications Fpass, Fstop must have increasing values."
This error means that Fstop
should be greater than Fpass
. You mentioned that you need Fpass=30Hz
. So you would need Fstop > 30
, but you specified a value of 10Hz. To fix this error you should increase the Fstop
value (for example to 100Hz for starters then tweak until you get what you like).