Every note so far has been spelled out. note("c3 eb3 g3")—you type the pitch, strudel plays it. That works, but it forces you to think in note names. Scales let you think in numbers. Pick a scale, type a number, and the scale decides which pitch to play.
s(), note(), stack(), cat(), setcpm(35),
mini-notation (~ * [] <> / @),
.gain(), .pan(),
.lpf(), .lpq(), .attack(), .decay(),
.sustain(), .release(),
.room(), .size(),
.delay(), .delaytime(), .delayfeedback(),
.distort(), chord notation [c3,eb3,g3],
progressions with <>,
.every(), .sometimes(), .jux(), .off(),
arrangement with cat() and gain automation,
and the phonk palette from EDM.4–7.
Eight numbers. One scale. Hit play:
That’s C minor, ascending. The numbers map to notes: 0=C, 1=D, 2=Eb, 3=F, 4=G, 5=Ab, 6=Bb, 7=C one octave up. You typed numbers. The scale decided the pitches.
Now rearrange those numbers into a rhythm:
Same scale. Different order, different grouping. Now it’s a melody, not a scale run. The last beat subdivides—[7 5] plays two notes where one used to be. Everything you know about mini-notation still works. The numbers just replace note names.
A scale is a set of notes ordered by pitch. Scale degrees are numbered positions in that set. 0 is the root—the home note. The scale decides which actual pitches the numbers map to. Change the scale, the same numbers produce different pitches.
Try n("0 4 2 6 4 1 3 5").scale("C:minor") for a different melody from the same seven notes. Or n("7 5 3 1 6 4 2 0") for a descending line. Same raw material, different shape.
C major. Same numbers as before:
Now C minor. Same code, one word changed:
Same numbers, different scale, completely different mood. Major is bright. Minor is dark. The difference is three notes: the 3rd, 6th, and 7th are each one semitone lower in minor.
Hear both back to back. Same degree pattern, different scale—first major, then minor:
One cycle bright, one cycle dark. cat() alternates between them. The degree pattern 0 2 4 7 4 2 stays identical. Only the scale name changes. That’s the power of scale degrees—the shape of the melody is separate from its mood.
The major scale follows the interval pattern: whole whole half whole whole whole half (W W H W W W H). The minor scale: W H W W H W W. The 3rd degree is the tell. A major 3rd sounds bright. A minor 3rd sounds dark. Three notes change. The whole character flips.
Try "C:dorian" or "C:mixolydian" in place of major or minor. Same root, different mood. Dorian is minor but warmer. Mixolydian is major but heavier. Preview of EDM.8b.
Play a note at 261.63 Hz (middle C). Double the frequency to 523.25 Hz. That’s the same note one octave higher. Every culture with a tonal system agrees on this: the octave is the most fundamental interval. The ratio is 2:1.
The question is how to fill the space between a note and its octave. Western music divides it into 12 equal steps (semitones). Each step multiplies the frequency by the 12th root of 2—approximately 1.05946. Twelve steps of that ratio land exactly on 2:1.
This system is called equal temperament. It’s a compromise. Pure intervals—a perfect fifth at exactly 3:2, a major third at exactly 5:4—sound cleaner. But they don’t add up evenly. Stack twelve perfect fifths and you overshoot seven octaves by about a quarter of a semitone (the Pythagorean comma). Equal temperament spreads that error across all twelve notes so every key sounds the same.
Not everyone makes this trade. Arabic maqam uses quarter tones (24 divisions). Indonesian gamelan uses 5 or 7 unequal divisions. Indian classical music uses 22 shrutis. The 12-note system is a choice, not a law.
| note | frequency (Hz) | semitones from C |
|---|---|---|
| C4 | 261.63 | 0 |
| C#/Db | 277.18 | 1 |
| D | 293.66 | 2 |
| D#/Eb | 311.13 | 3 |
| E | 329.63 | 4 |
| F | 349.23 | 5 |
| F#/Gb | 369.99 | 6 |
| G | 392.00 | 7 |
| G#/Ab | 415.30 | 8 |
| A | 440.00 | 9 |
| A#/Bb | 466.16 | 10 |
| B | 493.88 | 11 |
| C5 | 523.25 | 12 |
A major scale picks 7 of these 12 notes. A minor scale picks a different 7. A pentatonic picks 5. The chromatic scale uses all 12. Every scale is a selection from this grid.
A melody in C minor. Rests give it shape:
Four notes, four rests. The melody breathes. Now put it on top of the phonk beat from EDM.4:
The melody uses the same C minor scale that the chords and bass are in. Everything agrees on the key. The <7 5> alternation gives the melody a 2-bar phrase—different ending each time. Degree 7 is the octave C, degree 5 is Ab. One resolves up, one pulls down.
The / operator from EDM.6 works with scale degrees too. Spread a melody across two bars instead of cramming it into one:
Eight events spread across two cycles. Four notes per cycle. The melody slows to half speed. /2 stretches the pattern across two bars—useful for long phrases that need room.
Change the scale to "C:pentatonic"—only 5 notes, everything sounds good. Almost impossible to hit a wrong note. Or "C:blues" for the blues scale. Both covered in depth in 8b.
The phonk track from EDM.4–6, now with a scale-based melodic lead. Drums, 808 bass, pad, cowbell—everything you’ve built. The new layer: a melody written entirely in scale degrees. Numbers in, notes out. Four bars, four different melodic shapes over the same C minor scale.
n("<[4 ~ 7 ~ 5 ~ 2 ~] [3 ~ 0 ~ 4 ~ 6 ~]>") for a two-bar phrase that starts high and falls..scale("C:minor") to .scale("C:dorian"). Same numbers, warmer mood. The 6th degree shifts up one semitone—Ab becomes A natural..every(4, rev) to the melody line. Every fourth bar, the melody plays backward. Pattern variation from two words of code.| tool | does | looks like |
|---|---|---|
| .scale() | maps numbers to notes in a key | .scale("C:minor") |
| n() | play scale degrees (numbers) | n("0 2 4 7") |
| "C:major" | the major scale — bright, W W H W W W H | .scale("C:major") |
| "C:minor" | the minor scale — dark, W H W W H W W | .scale("C:minor") |
| scale degree numbers | 0=root through 7=octave | n("0 1 2 3 4 5 6 7") |
| /N in melodies | spread melody across N cycles | n("[0 2 4 7 4 2 0 ~]/2") |
.scale() to set the key. n() to write in numbers. "C:major" for bright, "C:minor" for dark. All mini-notation works inside n()—rests, groups, alternation, / for multi-bar phrases. The scale maps numbers to pitches. You write the shape.
Next: Modes. Same notes, different home. Same code, different mood.
Tracks that demonstrate this lesson’s concepts.
| artist | track | why |
|---|---|---|
| Koji Kondo | Zelda OoT: Gerudo Valley (1998) | (VGM) minor scale, flamenco guitar, rhythmic fire |
| Nujabes | Feather (2005) | (hip-hop) modal harmony in beat music |
| LTJ Bukem | Demon’s Theme (1992) | (atmospheric DnB) atmospheric DnB, melodic layers |
| Zhu Zaiyu | Equal Temperament treatise (1584) | (hip-hop) first mathematical derivation of 12-tone equal temperament |
The 12-note scale is a compromise. Different cultures divided the octave differently. The version we use today was the result of centuries of argument.
Pythagoras reportedly discovered that simple ratios produce consonant intervals — 2:1 (octave), 3:2 (fifth), 4:3 (fourth). He (or his followers) used a monochord to demonstrate this. The idea that musical beauty has mathematical structure became foundational to Western music theory. But stacking pure fifths (3:2 ratios) doesn’t perfectly cycle back — the “Pythagorean comma” means 12 pure fifths overshoot 7 octaves by about a quarter of a semitone.
The Chinese prince and scholar Zhu Zaiyu published the first mathematically precise calculation of equal temperament — dividing the octave into 12 equal semitones using the 12th root of 2. Simon Stevin in the Netherlands independently derived the same system around 1585. Equal temperament is a compromise: no interval except the octave is acoustically pure, but every key sounds equally “in tune” (or equally “out of tune”). It enabled modulation between keys without retuning.
Bach wrote preludes and fugues in all 24 major and minor keys to demonstrate that a well-tempered keyboard could play in any key. Whether he used equal temperament specifically is debated — “well-tempered” likely meant some form of circulating temperament. The practical effect was the same: the keyboard as a universal instrument, not locked to one key.
Sources: Barker, Greek Musical Writings, Vol. 2 (1989); Needham, Science and Civilisation in China, Vol. 4 (1962); Isacoff, Temperament (2001).