Sound and Music Computing
Dr Charles Martin
You can think of a composition as a program (or instructions) for making sounds.
Compositions is about making choices for what the instructions are.
Choosing is hard!
Can we get some help making all these choices?
Music is full of patterns, repetitions, heuristics and systems.
We can take advantage of this knowledge to make algorithms for making insteresting choices.
Algorithmic composition: using a program to make choices for musical parameters (e.g., pitch, rhythm, timbre).
Existed since before computers…
Repetition
Variation
Counters and cos
, a quick LFO.
These are useful for non-pitch parameters:
Try randomising LFO speeds or controlling the LFO with an LFO.
Eurodance in a box: Algorithm to space notes evenly in a sequence of fixed duration spaces.
Produces common and useful patterns, e.g., clave patterns, that sound great in EDM and are used all the time.
We’ve touched on random previously, now we’re going to process random values in difference ways:
you can use random
numbers to create frequencies for a synth.
Pd really only has one kind of random
function: integers between 0 and $1
(the first
argument)
want to trigger different things randomly? try select
Try using random
to control the steps of a sequencer.
random 2
to create either a 0 or 1spigot
Good for making quick, interesting patterns!
My hardware drum machine has this feature!
Recall that different multiplying frequencies produces consonant (nice-sounding) intervals.
Doubling a frequency results in a frequency that we call an octave.
Pitches (A, B, C, D,.. etc) are distributed along the frequencies so that the ratio between any two adjacent pitches is the same.
We end up with pitches that sound even and logarithmic scale of frequencies.
To convert, use mtof
or ftom
in Pd or look at this table.
In Pd, we use MIDI numbers, not note names. 60 == C4, 61 == C#4, etc…
In European and Chinese music (among others) we tend to divide the octave into 12 pitches with a ratio of 2112 between the frequencies.
You can call this “12-TET” (12-tone equal temperament).
Other schemes are possible, used in practice and sound super cool, e.g.:
Using the same random
object, but with different values, we can create MIDI pitch numbers (0-127).
You might want to use a nice “musical” range, e.g.,
Let’s abstract things a bit by using two random choices one to choose pitch, one for octave. We can separate out a nice parameter for the base pitch.
metro
You know how to schedule repeating notes with metro
you have to supply the number of milliseconds in between bangs.
How about randomising the metro
’s time after each bang?
We can make a “random” metronome with a maximum and minimum time.
metro
This composition uses additive synthesis to create:
It’s random
all the way down.
Using all the frequencies can sound good.
Can also be good to restrict to particular collections of pitches.
This can let us:
It can sound nice to use a subset of the 12 pitches.
We can select the same subset in each octave.
In music we call this a scale.
You can define a scale as an array showing the offsets from a starting point.
Then use tabread
to access the offset and add it to a starting MIDI note.
We’ve travelled deep music theory land, no turning back now.
Scales can have different numbers of notes, you might have learned some 7-note, heptatonic scales and are probably familiar with the sound of 5-note pentatonic scales.
Here’s a few examples of scales:
[0, 2, 3, 7, 8]
[0, 2, 4, 6, 8, 10]
[0, 2, 3, 5, 7, 9, 10]
[0, 2, 3, 5, 6, 8, 9, 11]
Scales have lots of interesting patterns and properties but we won’t go into further detail.
Pd doesn’t have any built in knowledge about scales.
It’s straightforward to create objects for scales you might want to use, see the aeolian.pd
as an example.
Here’s an example with aeolian
generating FM pad sounds.
Copy 5-Scales.pd
from the board and use it as the basis for a composition.
We’ve talked about consonant and dissonant combinations of frequencies before.
This idea can explain why melodies seem move away and then come back “home” to a certain pitch.
Movement from dissonant to consonant gives us a sense of “movement”.
Structured changes between combinations of frequencies is called harmony. It’s a deep study but we can look at some useful basics.
Now that we understand scales, we can call the first note of a scale the “root”.
It’s often where we start a melody and where we return. (not always!!)
You can emphasise a scale by using the root note as a second part (e.g., a repeating bass line, like in techno)
The other notes (or degrees) from a scale can be used for a bass line as well. E.g.,
[1, 2, 6, 5]
This changes how we hear the original sequence!
Changing the bass note makes us hear that note as the “new” root, and we hear the sequence differently.
Harmony is complicated and there are lots of ways of notating and explaining harmonic changes.
So our chord progression [1, 2, 6, 5]
on a major scale would be: I, ii, vi, V
(the major/minor-ness is taken from the notes of the scale here)
Here’s something simple:
[1, 3, 5]
from the scale[1, 2, 6, 5]
just add drums and we have techno!
Our decisions have, so far been low level: “I want to play a note, but which one?”
What about some higher level decision making:
Suppose you want to take one action 20% of the time, and another 80% of the time?
You can split random numbers with the moses
object to achieve this.
This extends to more weighted decisions if you want.
Try using a probability instead of a toggle on each step of a sequencer.
My hardware synth and drum machine have this feature!
What about having a different weighted decision depending on what the last decision was?
This is called a Markov process. You can do it with the moses
method, but it
might get out of hand quickly.
Maybe try c_markov.pd
in rjlib
.
Get started, you have to make something today that includes:
Want some extra tools?