Week 9 - Generating Music

Opening Links

Cultural Subjectivity

P5 Sound Library

Be sure you have the latest version of the sound library.

Our examples this week focus on simple music generation. We will be working at a higher level of abstraction, thinking about the notes to play, rather than the creating the sound of a note.

You can experiement with generating sounds and noise yourself if you like. Take a look at the p5 docs for information about the library functions p5 provides for working with sound.

Some Music Theory

I don’t have a great deal of knowledge around music theory, so this information will not be deep (and there is so much more depth below). It is possible that some of it will be incorrect.

Still, these are the assumptions I used in creating the examples we will study this week.

First

Pitches

NoteCC#DD#EFF#GG#AA#B
Equal Temperament hz261.63277.18293.66311.13329.63349.23369.99392.00415.30440.00466.16493.88
Equal Temperament ratio11.0591.1221.1891.2591.3341.4141.4981.5871.6811.7811.887
Just Interval Ratio1-1.125-1.21.333-1.5-1.666-1.875
Just Interval Ratio1/1-9/8-5/44/3-3/2-5/3-15/8

Scales

NoteCC#DD#EFF#GG#AA#B
C-Majorxxxxxxx
Stepwwhwwwh

Rhythm

Arrays

emptyArray = [];
simpleArray = [1, 2, 3];
nestedArray = [[60, 1], [62, 1]];
nestedArray.push([64, 1]);
nestedArray[1][0];
nestedArray[1][1];
nestedArray2 = [[70, 1], [72, 1]];
combinedArray = nestedArray.concat(nestedArray2);

MonoSynth, QuickMusic, and Examples

For this weeks class, I have created two small javascript libraries and several example sketches.

MonoSynth

MonoSynth, uses the p5.js oscillator and envelope classes to create an synth object that can play back a sequence of notes.

var synth = new MonoSynth();
synth.playNotes([[60, 1/4], [62, 1/4]]);

QuickMusic

QuickMusic provides a few utilty functions for processing sequences of notes and working with keys/scales.

Supported Musical Scales

Library Functions

Examples

I also created several fully commented example scripts, we will review them in class, but I suggest also reading them at your own pace.

Example Download

Example Documentation

Links