This creates a bit longer than 10 second clip of weird broadband noise. It's value is that it is energetic, and has no zeros or near zeros in its spectrum.
It creates a file called "whooosh.wave".
You may have to swap to wavwrite on octave. The rest should "just work" in octave, although I lack a modern octave any longer, having actual matlab.
---file pgen.m---
---end pgen.m---
Free for non-commercial use.
It creates a file called "whooosh.wave".
You may have to swap to wavwrite on octave. The rest should "just work" in octave, although I lack a modern octave any longer, having actual matlab.
---file pgen.m---
clc
clear all
close all
fs=48000;
blen=2^ceil(log2(10*fs)); %next step up from 10 seconds.
x(1:blen,1)=0;
x(round(blen/2),1)=1;
xt=fft(x);
%phi only needs to be 2:blen/2 memory is cheap
phi=rand(blen,1)*2*pi;% many will be unused, so?
phi=phi-sum(phi)/blen; % make DC value zero
phi=phi *5.6 ; %just fiddle for the right spread
[bb,aa]=butter(4, .1); %the fractional lp frequency affects spread too
phi=filter(bb,aa,phi); %limit speed of phase change.
phi(1)=0; % to prevent complex DC part
for ii=2:blen/2
xt(ii)=xt(ii)*( cos(phi(ii)) + i*sin(phi(ii)));
end
xt(blen:-1: (blen/2+2))=conj(xt(2: (blen/2))); % conjugate spectrum for real only output.
%notice 1 and blen/2+1 are unmodified and purely real, not complex
xx=ifft(xt);
t=max(abs(xx));
xx=xx*.9/t;
audiowrite('whooosh.wav',xx,fs,'BitsPerSample', 24);
plot(xx)
figure
plot(abs(fft(xx,2*blen)))
---end pgen.m---
Free for non-commercial use.
Last edited: