# Chaos algorithm for choosing pitches

Mathematicians have observed that certain repeated iterative equations create interesting visual patterns when the results are graphed. Those equations are a part of the study of "chaos theory". This patch uses one such equation, and outputs the results as MIDI pitch values, to make chaotic pitch patterns.

The equation used for this patch is x = rx(1-x), where the new result x on the left side of the equation is then used as the current value of x on the right side of the equation the next time the equation is solved. Depending on the value of r, the pattern created by repeated iterations of this equation might be chaoticâ€”unpredictable but not totally random, containing some almost repetitive patternsâ€”or it might oscillate cyclically around some small set of values to create a clearly repetitive pattern. Listen to the output using the supplied default r value of 3.8, then listen as you change the r value to something slightly different.

In this patch we use the expression *1000./$f1* in the **expr** object to convert notes per second to a millisecond interval to be used by the **metro**. This is equivalent to using a **!/ 1000.** object. The output of the equation is multiplied by 60 and offset by 36 to map the x value into a reasonable range of MIDI pitches.