Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Fractal Noise
name
code content
// Script for generating fractal noise by cascading N first order filters. From: "The Sounding Object", chapter 8 s.boot; s.scope ( var fp1,n,fp,fo,a,b,beta,t,norm; fp1 = 50; // frequency of first pole n = 6; // nr. of poles h = 2; // density of poles per frequency decade beta = 1; // spectral parameter t = s.sampleRate.reciprocal ? 44100.reciprocal; // sampling period norm = exp(beta).reciprocal**1.72; fp = Array.newClear(n).put(0,fp1); // pole frequencies fo = Array.newClear(n); // zero frequencies a = Array.newClear(n); // pole coefficients b = Array.newClear(n); // zero coefficients n do: { |i| (i > 0).if { fp[i] = 10**h.reciprocal*fp[i-1] }; fo[i] = 10**(0.5*beta*h.reciprocal)*fp[i]; a[i] = exp(-2pi*fp[i]*t); b[i] = exp(-2pi*fo[i]*t) }; SynthDef(\fractalNoise,{ arg out=0; var signal = WhiteNoise.ar(1!2); n do: { |i| signal = FOS.ar(signal,1,b[i].neg,a[i]) }; Out.ar(out,norm*signal) }).add; ) // test it s.sendMsg('/s_new',\fractalNoise,s.nextNodeID,0,1); FreqScope.new // probably more useful as a pseudo-ugen FractalNoise { *ar { arg beta = 0, mul = 1, add = 0; var n = 6, h = 2, fp = 50, t = SampleDur.ir, norm = exp(beta).reciprocal**1.72, sig = WhiteNoise.ar(mul,add); n do: { var fo = 10**(0.5*beta*h.reciprocal)*fp; sig = FOS.ar(sig,1,exp(-2pi*fo*t).neg,exp(-2pi*fp*t)); fp = 10**h.reciprocal*fp }; ^(norm*sig) } }
code description
This code generates fractal noise by cascading N first order filter sections. beta = 0 -> white noise, beta = 1 -> pink noise, beta = 2 -> brown noise. Not too sure about the normalization constant, since it is purely based on empirical reasoning, but it seems to work pretty well.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change