1/f noise pattern?

View: New views
3 Messages — Rating Filter:   Alert me  

1/f noise pattern?

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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



Re: 1/f noise pattern?

by Nathaniel Virgo-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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




Re: 1/f noise pattern?

by Julian Rohrhuber :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>Do we already have a 1/f noise pattern that I overlooked?
>
>If not, how about this?


nice.

note that according to the post reform pattern paradigm, lo, hi
should be able to be patterns, and length should be sent the value
message.

also you may want to use newCopyArgs for a simpler and faster init.


>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
>
>: <mailto:jamshark70@...>jamshark70@...
>
>: <http://www.dewdrop-world.net>http://www.dewdrop-world.net
>
>.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
>
>
>"Come said the Muse,
>
>Sing me a song no poet has yet chanted,
>
>Sing me the universal."  -- Whitman


--





.

_______________________________________________
sc-dev mailing list

info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-dev/
search: http://www.listarc.bham.ac.uk/lists/sc-dev/search/
LightInTheBox - Buy quality products at wholesale price