That looks good and would be handy - very similar to one I have in my (currently still private) lib that I called Ppink.
It may also be helpful to put a simple low-pass filter on the result (e.g. value = x*value + (1-x)*previous_value) ) simply because the Voss-McCartney method produces a bit too much very high end, which makes the individual values a bit too un-correlated to each other.
(also an LFPink UGen would be handy for me too)
Nathaniel
2008/7/22 James Harkins <
jamshark70@...>:
Do we already have a 1/f noise pattern that I overlooked?
If not, how about this?
hjh
// McCartney-Voss 1/f noise
Pmcvoss : Pattern {
var <>lo, <>hi, <>generators, <>length;
*new { |lo = 0, hi = 1, generators = 8, length = inf|
^super.new.lo_(lo).hi_(hi).generators_(generators).length_(length)
}
embedInStream { |inval|
var counter = 1,
maxCounter = 1 << (generators-1),
gens = { 1.0.rand } ! generators,
total = gens.sum,
i, new;
length.do {
inval = ((total / generators) * (hi-lo) + lo).yield;
i = counter.trailingZeroes;
new = 1.0.rand;
total = total - gens[i] + new;
gens[i] = new;
counter = (counter + 1).wrap(1, maxCounter);
}
^inval
}
}
: H. James Harkins
: jamshark70@...
: http://www.dewdrop-world.net
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman