- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatChapter9/C091704d.cpp File Reference

`#include "MusimatChapter9.h"`

Go to the source code of this file.

## Functions
| MusimatChapter9Section (C091704d)
Real | VossFracRand (Integer n, RealList L)
Static Void | para1 ()

## Function Documentation

MusimatChapter9Section | ( | C091704d |  | ) |

Definition at line 2 of file C091704d.cpp.

References para1().

    00002                                  {
    00003 Print("*** Voss’s Method ***");
    00004 /*****************************************************************************
    00005
    00006 Voss’s Method
    00007
    00008 Martin Gardner (1978) reported a fractal noise generator attributed to Voss. A
    00009 set of random variables xk are summed on each sample n, and the result is output. The random vari-
    00010 ables are updated at different rates. If , then the k th variable is assigned a new random
    00011 number Us. The index k ranges from 0 to N – 1. So x0 is randomized every sample, x1 is randomized
    00012 every other sample, x2 is randomized every fourth sample, and so on, until finally xN–1 is only
    00013 randomized every  samples.  We can code this method as follows:
    00014 *****************************************************************************/
    00015         para1(); // Step into this function to continue.
    00016 }

Static Void para1 | ( |  | ) |

Definition at line 30 of file C091704d.cpp.

References n(), Random(), and VossFracRand().

    00030                     {
    00031 /*****************************************************************************
    00032 The following creates and prints a list of 128 fractal noise samples over four octaves:
    00033 *****************************************************************************/
    00034
    00035 RealList L(Random(), Random(), Random(), Random());
    00036 RealList R;
    00037
    00038 For (Integer n = 0; n < 128; n = n + 1) {
    00039         R[n] = VossFracRand(n, L);
    00040 }
    00041
    00042 Print("*** Voss' Fractal Method ***");
    00043 Print(R);
    00044
    00045 /*****************************************************************************
    00046 Figure 9.32 shows how this noise is constructed by this method. Each function changes at a rate
    00047 twice as fast as the previous function, and the functions are summed. Random values in the rapidly
    00048 changing functions have only local influence, whereas values in the slowly changing functions extend
    00049 their influence over many samples of the summed result, giving the result a fractal characteristic.
    00050 *****************************************************************************/
    00051 }}

Real VossFracRand | ( | Integer | n,
|  | RealList | L |
| ) |  |  |

Definition at line 18 of file C091704d.cpp.

References N, Random(), and sum().

    00018                                            {
    00019         Real sum = 0.0;
    00020         Integer N = Length( L );
    00021         For(Integer k = 0; k < N; k = k + 1) {
    00022                 If (Mod(n, Integer(Pow(2, k))) == 0) {
    00023                          L[k] = Random(-1.0, 1.0);
    00024                 }
    00025                 sum = sum + L[ k ];
    00026         }
    00027         Return(sum);
    00028 }