# Signal Music, More Sources of Randomness Making signal music that fits into a rhythmic grid is not too tough. Ramps can be subdivided, shifted, and shrunk. But it is also not too tough to make music that doesn't live on the grid. ![[abstract-patch-3.png]] We used `[noise~]` and `[stash~]` previously as sources of controlled randomness. We used `[noise~]` to help generate new notes for our sequences. We used `[stash~]` as a sort of sequencer, where we randomly change one step every so often, creating a sort of "evolving randomness". Another useful source of controlled randomness is `[rand~ 1.]`. You can change the rate of change by changing the `1.` to some other number. It creates a signal that slowly drifts, but stays within the bounds of `-1.` to `1.`. ## Gradual Randomness, and a Ray-Gun Generator We can use `[rand~ 1.]` piped into something like `[scale~ -1. 1. 0. 20.]` piped into `[phasor~ 1.]`. What this does is create a repeating ramp wave that fluctuates slowly in speed, from a minimum speed of 0 Hz, to a maximum speed of 20 Hz. This technique can be used to create music whose tempo shifts slowly over time. See [[Instrument IV, Blip Generator]]. > [!example] > ![[example-2.mp4]] > An example of using the Blip Generator to create laser gun sounds. ([[example-2.mp4|Click here to view, if it's not displaying]]) ## Evolving Randomness, and a Karplus-Strong Guitarist Using the above techniques of off-grid rhythmic variations and generating of evolving random values with `[noise~]`, and `[stash~]`, we can add variation to any patch. I borrowed the `[gen~]` patch from `gen~.karplus_strong` example file. I then created a `[rand~ 1.]`-varied phasor, and five `[stash~]`es to control various parameters (velocity, gate, MIDI note, decay, and dampening). > [!example] > ![[example-3.mp4]] > Using Karplus-Strong synthesis to create guitar-like sounds. ([[example-3.mp4|Click here to view, if it's not displaying]]) ## Other Kinds of Randomness ### Colors of Noise There are many colors of noise, from violet to white to red, which can be useful to get slightly different frequencies in percussion patches. In Max, you can get white noise and pink noise with `[noise~]` and `[pink~]`, but you can get variable-rate low-frequency noise using `[rand~]`. It can be used in audio-frequency range for interesting effects. You can also use effects on a noise source to get some strange sounds. Low-pass and band-pass filters, bitcrushers, ring modulation, phasers, and flangers can all spice up noise sounds. > [!example] > ![[image-60.png]] > White noise, pink noise, and low-frequency noise. ### More Basic Sources of Randomness A noise source into a sample-and-hold can let you take a "snapshot" of a noise source at one point in time. One trick is to trigger the sample-and-hold at rhythmic intervals. For example, you can trigger a sample-and-hold every quarter note, and use that as a pitch source, to get a random melody whose note changes every step. Using a `[stash~ @mode 2]`, you can "scan" through the values stored in the `[stash~]` using a signal whose value is in the range 0.0-1.0. That means you can do something like, scan through the `[stash~]` with a ramp once every measure, or you can pick a random value from the `[stash~]` using a random signal in the range of 0.0-1.0. > [!example] > ![[image-64.png]] > Four more examples of sources of randomness. `[stash~]` can be used on stored sequences of values. You can alternatively give it a size, like `[stash @size 4]`, and then feed it values periodically, while it independently emits values. For example, every seven beats, we can write a random value to the current write index. Independently, every beat, we can read the value at the current read index. If the reads happen more often than the writes, there will be a sense of evolution, because some notes will be repeated sometimes (and "repetition legitimizes"), but notes will change occasionally as well. One final point. You can use a comparator on the signal emitted by the `[stash~]` to generate gates, which can be used for creating rhythms or with `[*~]` to mute/unmute signals. > [!example] > ![[image-66.png]] > Create a ramp signal which plays 1-8x ramps for the duration of a quarter note, then picks a new multiplier. > [!example] > ![[image-65.png]] > More sophisticated example. Picks a rate to play a ramp signal, then emits one ramp wave. Then it picks another rate, and emits one ramp wave. And so on. ### Distributed Noise One way of providing "energy" as a song progresses, is to have notes "tend" higher near an emotional climax in the piece. You can use a `[scale~]` object to constrain a value to be between some other low value and high value. > [!example] > ![[image-69.png]] > View graph on [Desmos](https://www.desmos.com/calculator/zlvnbljpov) In the above graph, the x axis represents some "energy" value, which can range between 0.0 and 1.0. The y axis is some output value, also constrained to be between 0.0 and 1.0. The red area is allowed values. So first you find the vertical line that goes through the x value, and then determine what the lowest or highest values could be. For example, at x = 0.5, the lowest a value can be is roughly 0.145, and the highest is roughly 0.854. An input value of 0.75 would come out roughly 0.65. This patch has a ramp which repeats every four measures. This ramp is driving the scale curves (in the `[gen~]` abstraction). When it is time for `[stash~]` to sample a new note, it will attempt to do so from a value scaled to the current low and high values. Early on in the 4-bar loop, it will be more likely to sample low notes. Later on it will be more likely to sample high notes. This can be a way to "introduce" new values overtly changing them. > [!example] > ![[image-71.png]] > This patch plays a loop of four notes, but new notes are occasionally resampled. The way this sampling happens, if it happens early in a four-bar loop, the new note will be on the lower side of the range. If it happens later in a four-bar loop, the note will on the higher side of the range. A way to "introduce" new values gradually into a loop. > [!example] > ![[image-72.png]] > The `[gen~]` subpatch for the above patch.