| Thanks for the help on pink noise, Josep & David. I got pretty good results
with it once I found the right scalar for the weighting coefficients. The
output amplitude seems to be linear, when bandpass filtered with a bandwidth
proportional to the centre frequency. The only problem is that butterbp seems
to let a lot of hiss through, so I had to run any band pass filtered material
through a low pass filter.
Here's the orc:
sr = 44100
kr = 22050
ksmps = 2
nchnls = 1
instr 1
isc = .6 ; scalar chosen to match white noise amplitude
ksw expseg 30, p3, 18000 ; sweep filter from 30Hz to 18000Hz
a1 init 0
a2 init 0
a3 init 0
a4 init 0
a5 init 0
a6 init 0
anz trirand 30000 ; white noise
a1 = .997 * a1 + isc * .029591 * anz
a2 = .985 * a2 + isc * .032534 * anz
a3 = .950 * a3 + isc * .048056 * anz
a4 = .850 * a4 + isc * .090579 * anz
a5 = .620 * a5 + isc * .108990 * anz
a6 = .250 * a6 + isc * .255784 * anz
apnz = a1 + a2 + a3 + a4 + a5 + a6
apnz butterbp apnz, ksw, ksw * .05 ; sweep filter
apnz butterlp apnz, ksw * 1.2 ; remove high end which passes thru
out apnz
endin
----
and the sco:
i1 0 20
e
Brandon
Josep M Comajuncosas wrote:
> Hi,
> there was a short talk about this topic at music.dsp some weeks ago. Here
> you have two -3dB/oct filter (approximations!) posted to that list. You can
> port them to csound with rand, biquad and kfilter2, or coding them directly
> of course.
> Hope this helps,
>
> Josep M Comajuncosas
>
> How to make pink noise
> ----------------------
>
> This is an approximation to a -3dB/oct filter using a weighted sum
> of 6 first order low-pass filters. The weighting coefficients (the
> second number on each line) need to be scaled to suit your
> application (ie. the amplitude of your white noise input and what
> peak or rms output level you want).
>
> ...
>
> white = (double)(rand() - HALF_RAND_MAX);
>
> buf0 = 0.997 * buf0 + 0.029591 * white;
> buf1 = 0.985 * buf1 + 0.032534 * white;
> buf2 = 0.950 * buf2 + 0.048056 * white;
> buf3 = 0.850 * buf3 + 0.090579 * white;
> buf4 = 0.620 * buf4 + 0.108990 * white;
> buf5 = 0.250 * buf5 + 0.255784 * white;
>
> pink = buf0 + buf1 + buf2 + buf3 + buf4 + buf5;
>
> an equiripple approximation to the ideal pinking filter can be realized by
> alternating real poles with real zeros. a simple 3rd order solution that i
> obtained is:
>
> pole zero
> ---- ----
> 0.99572754 0.98443604
> 0.94790649 0.83392334
> 0.53567505 0.07568359
>
> the response follows the ideal -3 dB/octave curve to within + or - 0.3 dB
> over a 10 octave range from 0.0009*nyquist to 0.9*nyquist. probably if i
> were to do it over again, i'd make it 5 poles and 4 zeros.
--
brandon_nelson@bigfoot.com
ICQ: 11617296
|