# algorithmic composition

## Saving and recalling presets in pattrstorage

This patch demonstrates the use of pattr objects to store several attributes of a note-generating algorithm, and pattrstorage to store and recall preset values for all of those pattrs. In order to use the presets already designed for this patch, you will first need to download the file called notestreams.json and place it somewhere in the Max file search path.

## Repeated notes at 6 related tempi, with different probabilities

This example (taken from Tutorial 37 in the original Max tutorials) demonstrates one way the passpct program, from the example "Pass a certain percentage of bangs", could be used. In order for this patch to work properly, you'll need to download that patch, passpct.maxpat, and store it in the Max file search path.

## Minimal loops using a portion of a table

This patch composes a melody in Minimal style, playing periodically-varying diatonic melodic loops of different lengths. A 16-stage sequence of velocity values is stored in one table, and a 32-stage sequence of pitch values is stored in another table.

## Linear motion in two voices

Two oscillators, one in the left channel and one in the right channel, play notes that have a continuously changing frequency, at a continuously changing note rate. Every few seconds (some randomly-chosen number of seconds from 2 to 8) each of the two oscillators gets a new destination frequency and destination note rate, and heads toward those destination values over the next few (randomly-chosen number of) seconds.

## Six upper harmonics of a fundamental

This is an algorithmic generator of sound patterns based on the number 6. The patch a) uses the urn object to generate a list consisting of a random ordering of the six digits 0 to 5, b) uses a metro to bang a counter six times per second in order to count through that list of digits, c) uses those six digits to produce six frequencies representing harmonics 7 through 12 of a fundamental (110 Hz, initially), and d)uses those freque

## Algorithmic composition with math functions

This patch is based on an example in the Max 3.5 Tutorial, chapter 44. It demonstrates a) the use of math functions to generate patterns for musical parameters and b) faster-than-realtime recording of MIDI data in the detonate object.

## Using the preset capabilities of pattrstorage

[In order for this example to work properly, you should first download the file called noiseburstpresets.json and save it with that name somewhere in the Max file search path.]

## Bass drum player with swing

This patch uses the transport object to control an algorithmic performer of kick drum patterns. When the transport is turned on, the metro also turns on because its active attribute is set on. The metro sends a bang on every 16th note. Those bangs are first used to trigger information from the transport itself, and then to look up in a table of patterns to see whether or not to play a bass drum note.

## 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.