[linux-audio-dev] Re: Tuning

Tom Szilagyi tszilagyi at users.sourceforge.net
Sat Jan 29 10:03:52 UTC 2005


On Sat, 29 Jan 2005 04:16:05 -0600, Jan Depner
<eviltwin69 at cableone.net> wrote:

> > Is there any way I could try to understand what good it does without
> > having to decompose Tom's plugin ?
>
>    Just got back from a gig and it's 0330 so this might ramble a bit -
> almost everything in nature is fractal.  There are a couple of good
> books on chaos theory that cover this.  Fractals can be generated using
> FFTs but they're very compute intensive.  You can google for midpoint
> displacement and find some good info on it.  Almost all of the digital
> terrains that you see in games are generated using midpoint
> displacement.  It gives you a very natural looking surface and just uses
> a pseudo random number generator to approximate a fractal surface (or
> line in this case).  It's actually a pretty simple algorithm.  I was
> lucky enough to take the fractal seminars at the 1986 Siggraph.
> Unfortunately stupid me lost the books.  Doh!

Here's a short and simple implementation of generating a fractal line
with the midpoint displacement method. (Taken from tap_doubler.c, from
tap-plugins-0.7.0)

/* generate fractal pattern using Midpoint Displacement Method
 * v: buffer of floats to output fractal pattern to
 * N: length of v, MUST be integer power of 2 (ie 128, 256, ...)
 * H: Hurst constant, between 0 and 0.9999 (fractal dimension)
 */
void
fractal(LADSPA_Data * v, int N, float H) {

        int l = N;
        int k;
        float r = 1.0f;
        int c;

        v[0] = 0;
        while (l > 1) {
                k = N / l;
                for (c = 0; c < k; c++) {
                        v[c*l + l/2] = (v[c*l] + v[((c+1) * l) % N]) / 2.0f +
                                2.0f * r * (rand() - (float)RAND_MAX/2.0f) / (float)RAND_MAX;
                        v[c*l + l/2] = LIMIT(v[c*l + l/2], -1.0f, 1.0f);
                }
                l /= 2;
                r /= powf(2, H);
        }
}


Tom



More information about the Linux-audio-dev mailing list