Skip to content

Art and animation, written as code. Illustrations, loops, interactive web art, launch-videos and scored films in dozens of styles, identical on every render.

music theory references: melody, harmony, rhythm, mood, form, sound (cited, scale-degree examples, each rule tied to what craft measures)

Alex Greenshpunddf8f1cdf957
diff --git a/skills/anidoodle/references/music/theory/README.md b/skills/anidoodle/references/music/theory/README.md
new file mode 100644
index 0000000..ac0ce12
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/README.md
@@ -0,0 +1,19 @@
+# Music theory for the composer
+
+These pages are the craft behind [../compose.md](../compose.md): what makes a line beautiful, a
+progression move, a groove feel good and a mood read true. Each page cites its sources and ends in
+rules you can apply. Examples use scale degrees and shapes, never tunes to copy.
+
+| Page | Read it when |
+|---|---|
+| [melody.md](melody.md) | writing the motif and phrases: development, contour, climax, leaps, non-chord tones |
+| [harmony.md](harmony.md) | writing chords and bass: function, cadences, voice leading, modal colour, tension |
+| [rhythm.md](rhythm.md) | writing grooves and lines: metre, syncopation, swing, fills, density |
+| [mood.md](mood.md) | choosing tempo, mode, register and density for a feeling (the research, and the 21-mood table) |
+| [form.md](form.md) | laying out sections: song and cue forms, builds, orchestration slots, counterpoint |
+| [sound.md](sound.md) | voicing and arranging for a clear mix: critical bands, masking, low limits, space |
+
+`node tools/music.mjs craft <score.ts#export>` measures these rules in milliseconds, with no render,
+and `check` prints the same report. Scores run from 0 to 1 and are advisory. Each `CRAFT` line names what
+it saw, where, and a fix. Only a note an acoustic instrument cannot play is an error. The rest is
+yours to judge: a rule broken on purpose is style, and one broken by accident is a fault.
diff --git a/skills/anidoodle/references/music/theory/form.md b/skills/anidoodle/references/music/theory/form.md
new file mode 100644
index 0000000..3fdd779
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/form.md
@@ -0,0 +1,111 @@
+# Form, arrangement, orchestration, counterpoint
+
+## 1. Song forms (and the engine's section kinds)
+
+| Form | Shape | Engine kinds |
+|---|---|---|
+| Verse-chorus | intro, verse, chorus, verse, chorus, bridge, chorus x2, outro | intro, verse, hook, bridge, drop, outro |
+| AABA (32-bar) | A (the tune), A (varied end), B (contrast: new key area), A | verse, verse, bridge, hook |
+| Loop / beat | 4-8 bar loop; layers in and out every 4-8 bars | groove, hook, half, breakdown, drop |
+| Build-drop (EDM, trailer) | intro, build (riser), breath, drop, outro | intro, build, breath, drop, outro |
+| Through-composed cue | motif stated, developed, climax, coda | intro, verse, swell, hook, outro |
+
+- The chorus (hook) holds the **motif's clearest statement**, the fullest layers and the most home
+ harmony.
+- The verse is lighter and leaves room.
+- The bridge goes somewhere new: a borrowed or relative key area, a new rhythm, a thinner texture.
+ Then it **returns**.
+- Return is what makes form. A-B-A satisfies because B made A new (Huron 2006: expectation built,
+ then fulfilled).
+
+## 2. Film cue structure (scoring to picture)
+
+Working film composers structure a cue around **hit points**: the frames where something happens
+(Karlin & Wright 2004; Davis 2010).
+
+1. **Spot the cue.** List the beats with times: the reveal, the claim, the cut, the logo.
+2. **Pick 1-3 sync points** that get a structural downbeat: an arrival, a hit, or a change of layer.
+ Don't hit everything. Hitting every cut is "mickey-mousing", fine for comedy and tiring elsewhere.
+3. **Tempo from the picture.** Choose a bpm so the key hits land on downbeats (the engine's `fitScore`
+ and `stretch` help). A bar lasts `beatsPerBar x 60 / bpm` seconds.
+4. **Shape:**
+ - establish (the motif, low density);
+ - develop (sequence, rising harmony);
+ - a breath (one bar of near-silence);
+ - the peak on the key frame (the climax note, full layers, home chord);
+ - release;
+ - a button or tail.
+5. **Stingers:** a one-bar hit on a sudden picture event, placed off the grid (`hit: true`).
+6. **Leave dialogue space.** Under a voice, thin the 1-4 kHz band. Keep the lead low or tacet and let the
+ chords carry the harmony.
+
+## 3. Builds and releases
+
+- **Build** with 4-8 bars of rising density, rising register and rising harmonic rhythm (twice as fast
+ into the cadence). Use a dominant pedal or a sus chord, fragments of the motif, and a crescendo. End
+ on a lean (V, sus4, a breath), never on home.
+- **Release:** land on home, on the downbeat, with the most layers, the motif augmented or in full, and
+ the climax note.
+- **Before the peak, a dip:** a breakdown, a breath or a drum drop-out. Contrast makes the landing
+ (the tension curve in [harmony.md](harmony.md), and `craft`'s tension line).
+- **Endings:**
+ - a held home chord with the motif's last word;
+ - a button (a short tutti hit on 1);
+ - a fade only for loops;
+ - an open hold only for suspense.
+
+## 4. Orchestration: registers and frequency slots
+
+Every instrument owns a register. Two parts in the same register fight (masking, see
+[sound.md](sound.md)). Arrange by giving each part its slot:
+
+| Slot | Range (fundamentals) | Who owns it | Rule |
+|---|---|---|---|
+| Sub | 30-60 Hz (B0-B1) | kick body, 808/sub bass | one owner at a time; mono |
+| Bass | 60-250 Hz (B1-B3) | bass, cello/contrabass, piano left hand, tuba | the root; open 5ths and octaves only |
+| Low-mid | 250-500 Hz (B3-B4) | chords, pads, guitar body, low brass, male voice | the mud zone: thin it, don't stack it |
+| Mid | 500 Hz-2 kHz (B4-B6) | melody, lead, violins, trumpet, flute, female voice | the lead's home; one lead at a time |
+| Presence | 2-5 kHz (harmonics) | attacks, consonants, snare crack, pick | what makes parts audible; not everything bright |
+| Air | 5-16 kHz | hats, shakers, cymbals, breath, sparkle (celesta, glock) | light touches |
+
+Guidelines:
+
+- **Spacing follows the harmonic series:** wide intervals low, close intervals high (Rimsky-Korsakov
+ 1913; Adler 2016).
+- **Doubling:**
+ - an octave doubling adds weight and brightness;
+ - a unison doubling adds body and chorus;
+ - a melody doubled in the 3rd or 6th sounds sweet (pop, folk);
+ - don't double the leading tone or a chord 7th in classical idioms.
+- **At most 3-4 families at once** outside the climax, each in its slot. Five simultaneous functions
+ is a useful ceiling:
+ 1. foundation (bass and drums);
+ 2. pad (sustained harmony);
+ 3. rhythm (a moving accompaniment);
+ 4. lead;
+ 5. fills and counter.
+
+ (Owsinski 2017, the arrangement elements.)
+- **Timbre as contrast:** move the motif to a new instrument for the second statement. It is new
+ without changing a note.
+
+## 5. Counterpoint basics (a second line that helps)
+
+A counter-melody is a second voice that stays independent (Fux 1725, *Gradus ad Parnassum*; Jeppesen
+1939):
+
+- **Move when the melody holds, hold when it moves** (complementary rhythm). The `counterMelody` guard
+ asks for at most 50 % shared onsets.
+- **Prefer contrary and oblique motion** to the melody. Similar motion into a 5th or octave hides the
+ counter.
+- **Consonances on strong beats** (3rds, 6ths, 5ths, octaves). Dissonances pass by step on weak beats,
+ or are suspensions that resolve down.
+- **Its own register**, a 3rd to a 10th away from the tune, and ideally a different timbre.
+- **Call and response:** the counter answers in the melody's rests. This is the easiest, most
+ idiomatic counterpoint for pop and film.
+
+Sources: Caplin, *Classical Form* (1998); Everett, *The Foundations of Rock* (2009); Karlin & Wright,
+*On the Track* (2nd ed., 2004); Davis, *Complete Guide to Film Scoring* (2nd ed., 2010);
+Rimsky-Korsakov, *Principles of Orchestration* (1913); Adler, *The Study of Orchestration* (4th ed.,
+2016); Owsinski, *The Mixing Engineer's Handbook* (4th ed., 2017); Fux, *Gradus ad Parnassum* (1725);
+Jeppesen, *Counterpoint* (1939); Huron, *Sweet Anticipation* (2006).
diff --git a/skills/anidoodle/references/music/theory/harmony.md b/skills/anidoodle/references/music/theory/harmony.md
new file mode 100644
index 0000000..63e645a
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/harmony.md
@@ -0,0 +1,123 @@
+# Harmony: function, voice leading, colour, tension
+
+Roman numerals are relative to the key (`I ii iii IV V vi vii°` in major, `i ii° III iv v VI VII` in
+minor, `b` = borrowed or lowered). These are idioms, which are vocabulary. A multi-bar progression
+together with its rhythm and groove is a piece, and novelty checks for that. `craft` measures this page
+on the **harmony** line.
+
+## 1. Function: home, away, leaning, home
+
+| Function | Chords (major) | Feels like | Use |
+|---|---|---|---|
+| Tonic (T) | I, vi, iii | home, rest | starts, arrivals, the end |
+| Subdominant / predominant (S) | IV, ii, (bVI, iv borrowed) | moving away, opening | verses, bridges, before the lean |
+| Dominant (D) | V, V7, vii°, (bVII in rock/modal) | leaning, wanting home | the bar before an arrival |
+
+The standard motion is T -> S -> D -> T. Film and pop often skip D (`I bVII IV I`, a plagal or modal
+world) for warmth without the classical "push".
+
+## 2. Cadences: where a phrase breathes
+
+| Cadence | Motion | Effect | `craft` label |
+|---|---|---|---|
+| Authentic | V(7) -> I | full stop, arrival | `authentic` |
+| Plagal | IV -> I (or iv -> I) | "amen", gentle, hymn-like | `plagal` |
+| Modal / backdoor | bVII -> I, bVI -> I, bII -> I | rock, film, epic warmth | `modal` |
+| Half | ... -> V | a question, a comma | `half` |
+| Deceptive | V -> vi (or bVI) | surprise, "not yet", extends a phrase | `deceptive` |
+
+Put half and deceptive cadences inside the piece and the full one at the end. `craft` lists each
+section's ending. It warns when nothing before the last section breathes, and when a non-loop piece ends
+away from home (except where the idiom allows an open ending). **A loop should not cadence home** at its
+end. Lean back into bar 1 instead (end on V, IV or a turnaround).
+
+## 3. Voice leading
+
+Chords are voices moving, not blocks (Aldwell & Schachter 2011; Tymoczko 2011):
+
+- **Hold common tones.** Move every other voice to the **nearest** tone of the next chord. Efficient
+ voice leading averages 1-3 semitones per voice per change (`craft`: "voice motion").
+- **Contrary motion** between the bass and the melody gives independence and strength.
+- **No parallel 5ths or octaves** between independent voices in common-practice idioms: chorale,
+ choir, orchestral, nocturne, lullaby, music box, cinematic. They fuse two voices into one. `craft`
+ warns in these styles and only notes them elsewhere. Parallel 5ths are the **sound** of rock power
+ chords, of planing in jazz, house and lo-fi, and of folk drones. Doubling a line in octaves is
+ orchestration, not a fault (`craft` counts it separately), except in a choir.
+- **Inner voices** move by step or stay. A jump bigger than a 5th in an inner voice is a revoicing
+ mistake.
+- **Tendency tones:** the leading tone (7) rises to 1. The chord 7th falls by step. The suspended 4th
+ falls to 3.
+
+## 4. Voicing and the low end
+
+- **Spread low, close high.** Below about C3, use only octaves and 5ths. Put thirds from about C3 up,
+ and seconds from about E3 up. `craft` flags close intervals under the **low interval limits**
+ (the chart in [sound.md](sound.md) and `craftTables.ts`), because they turn to mud.
+- **The bass owns the root** (or a chosen inversion). The chord part sits above it in its own octave.
+- **Voicings by genre:**
+
+| Idiom | Voicing |
+|---|---|
+| Classical / choral | 4 parts SATB, root doubled, close or open position, 3rd never doubled in V |
+| Jazz, lo-fi, neo-soul | rootless 3-7-9 or 7-3-13 shells between E3 and E4; the bass has the root (Levine 1995) |
+| Pop / piano ballad | root-5-8 in the left hand, triad or add9 in the right |
+| Rock | power chords (1-5-8) in the low guitar; keys add the 3rd higher up |
+| Film / orchestral | open 5ths in the low strings, triads in the violas and violins, octave doublings for weight |
+| Ambient / pad | add9, sus2 and maj7#11 clusters, placed high and wide |
+
+## 5. Colour: modes, borrowed chords, extensions
+
+| Colour | How | Feeling |
+|---|---|---|
+| Lydian `#4` | I -> II (major) | wonder, flight, magic (film "flying" music) |
+| Mixolydian `b7` | I -> bVII -> IV | sunny, rock, easygoing |
+| Dorian `6` | i -> IV (major) | bittersweet, moving forward |
+| Phrygian `b2` | i -> bII | menace, heat |
+| Borrowed iv | I -> iv -> I | a sudden ache, nostalgia (the "minor iv") |
+| bVI and bVII | I -> bVI -> bVII -> I | epic, heroic lift |
+| Chromatic mediants | I -> III or I -> bVI (major triads) | awe, a scene turning, the film "magic" shift (Lehman 2018) |
+| Extensions | maj7, 9, 11, 13 | warmth and sophistication (jazz, lo-fi); triads sound plainer and bolder |
+| Sus chords | sus4 -> 3, sus2 | openness; a lean that resolves |
+
+## 6. Secondary dominants, pedals, modulation
+
+- **Secondary dominant:** V/x before any chord x (`V/vi -> vi`, `V/V -> V`). It adds a leading tone and
+ energy for one chord without leaving the key.
+- **Pedal point:** hold the bass (1 or 5) while the chords change above it. A tonic pedal gives calm or
+ a drone. A dominant pedal gives the build before an arrival.
+- **Modulation:**
+ - pivot chord (smooth, a new chapter);
+ - direct lift up a step or a half step for the last chorus (energy; declare it on the section);
+ - chromatic mediant (cinematic);
+ - relative major and minor (mood change, same notes).
+
+## 7. Harmonic rhythm: pacing
+
+How often the chord changes sets the pace as much as the tempo does.
+
+- 1 chord per 2 bars: calm, spacious, ambient, awe.
+- 1 per bar: song default.
+- 2 per bar: urgency, jazz, a cadence approach.
+
+**Speed the harmonic rhythm up into a cadence** (the sentence's continuation) and slow it down after
+an arrival. Change chords on strong beats. An eighth-note anticipation is fine; changes between beats
+blur the metre (`craft`: "chord changes on beats").
+
+## 8. Tension curve
+
+`craft` draws a per-bar tension curve. It blends:
+
+- the chord's distance from home (Lerdahl 2001, simplified);
+- the sonority's dissonance (Huron 1994 interval-class ratings);
+- density;
+- the melody's register;
+- loudness.
+
+Plan the curve **before** the notes: rise, a dip just before the peak (a breath or breakdown), the
+peak on the key picture moment, then release. It warns on a flat curve, on a first section that is the
+most intense, and on a last section with no release.
+
+Sources: Aldwell & Schachter, *Harmony and Voice Leading* (2011); Kostka & Payne, *Tonal Harmony*
+(8th ed., 2018); Piston, *Harmony* (1941/1987); Tymoczko, *A Geometry of Music* (2011); Levine, *The
+Jazz Theory Book* (1995); Lehman, *Hollywood Harmony* (2018); Lerdahl, *Tonal Pitch Space* (2001);
+Huron, "Interval-class content of equally tempered pitch-class sets", *Music Perception* 11 (1994).
diff --git a/skills/anidoodle/references/music/theory/melody.md b/skills/anidoodle/references/music/theory/melody.md
new file mode 100644
index 0000000..55012e3
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/melody.md
@@ -0,0 +1,122 @@
+# Melody: motif, contour, phrase
+
+Notation on this page: scale degrees (`1 2 3 ... 7`, `b3`, `#4`; `5,` = the octave below, `1'` = the octave
+above), durations in beats after a colon (`3:.5`). These are shapes to apply, never tunes to copy.
+`node tools/music.mjs craft <score>` measures every rule below (the **melody** line and `CRAFT melody:` findings).
+
+## 1. Start from a motif, then develop it
+
+A motif is 2-5 notes with **its own rhythm**. The rhythm is its identity: listeners recognise a
+motif by its rhythm and contour long before its exact intervals (Schoenberg 1967, ch. 2-3; Dowling 1978).
+Write the rhythm first, then the pitches.
+
+| Technique | What changes | Example (from a cell `1:.5 2:.5 3:1`) | Effect |
+|---|---|---|---|
+| Repetition | nothing | the cell again | anchors: the ear learns it |
+| Varied repetition | the last interval or note | `1 2 5` | keeps identity, adds interest |
+| Sequence | the start pitch (same shape) | `2 3 4`, then `3 4 5` | motion, rising energy; max 3 links, then break |
+| Inversion | the direction of each interval | `3 2 1` | an answer, a turn of mood |
+| Retrograde | the order | `3 2 1` with the rhythm reversed | rare, a hidden echo |
+| Augmentation | durations x2 | `1:1 2:1 3:2` | weight, arrival, the climax or the end |
+| Diminution | durations /2 | `1:.25 2:.25 3:.5` | urgency, a build |
+| Fragmentation | keep 2-3 notes, repeat them | `2 3, 2 3, 2 3` | the build before a peak |
+| Displacement | start an eighth later | `r:.5 1 2 3` | syncopation, groove, surprise |
+| Reharmonisation | the chord under it | same notes over vi instead of I | new colour, same tune |
+
+A score that works usually has **one** idea heard 6-12 times, never the same way twice, and at most a
+second idea that answers or contrasts it. `craft` reports how each phrase (or bar) relates to earlier
+ones: `exact`, `sequence`, `varied`, `new`. Aim for most phrases to return (`motif returns` >= 50 %) and
+few to be exact copies (<= 60 %; loop idioms like lo-fi and house may repeat more).
+
+## 2. Phrase and period
+
+- A **phrase** is 2 or 4 bars and ends with a cadence, a long note or a rest (Caplin 1998).
+- A **period** is two phrases: the antecedent (question) ends open, on 2, 5 or 7 over V; the
+ consequent (answer) starts the same way and ends closed, on 1 over I.
+- A **sentence** is 2 + 2 + 4: the idea, the idea again (varied or sequenced), then a continuation that
+ fragments it and speeds up the harmony into the cadence (Schoenberg 1967; Caplin 1998).
+- Question/answer between instruments is the same device: the lead asks, the counter answers
+ within one bar.
+
+## 3. Contour and climax
+
+- **Arch.** Across thousands of folk songs, the commonest phrase shape rises then falls (Huron 1996).
+ Descending phrases come second; phrases also drift down at their ends ("late-phrase declination",
+ Huron 2006).
+- **One high point per phrase group**, in the second half, often about two thirds in. The highest
+ note of the whole piece is its climax: put it on the picture's key moment, and don't reuse it
+ casually. `craft` warns when the piece peaks in its first 30 % or repeats the top note often.
+- Vary contours between phrases: a question that rises, an answer that falls.
+- In minor-key themes, lines sit lower and move in smaller intervals than in major ones (Huron 2008).
+ That is part of why they sound sad, so use it on purpose.
+
+## 4. Steps, leaps and recovery
+
+- **Mostly steps.** Small intervals dominate melodies across cultures (Vos & Troost 1989; Huron
+ 2006, "pitch proximity"). Singable tunes are roughly 60-80 % steps.
+- **A leap is an event.** Use a 4th or more to mark the motif's head or to reach the high point.
+- **Recover from leaps.** After a leap, change direction, preferably by step, to fill the gap. This
+ is statistically real ("post-skip reversal") and partly regression to the middle of the range
+ (von Hippel & Huron 2000). `craft` counts leaps that keep going the same way.
+- **Exemptions:** arpeggiating the current chord (a fanfare `1 3 5 1'`), and arpeggio or ostinato
+ idioms (music box, chiptune, synthwave, house).
+- **Avoid:** two leaps the same way that don't outline a chord; augmented 2nds and tritone leaps
+ (except as a deliberate colour); leaps over an octave in anything meant to sound sung.
+
+## 5. Range and tessitura
+
+- Keep one phrase within about an octave. Keep the whole tune within a 10th to a 12th unless the
+ instrument is built for more (piano, harp, synth).
+- Keep each part in its instrument's sweet range. `craft` checks the table in `craftTables.ts`
+ (after Adler 2016): a note outside what the instrument can physically play is the one craft error.
+- The melody sits **above** the chord voicing. A melody under the chords' top note is masked unless it
+ is louder and a different timbre (a tenor-register theme).
+
+## 6. Rhythm and melody together
+
+- Put the motif's long note where the meaning is: on the downbeat for arrival, or on a weak beat
+ (syncopated) for lift.
+- Start motifs off the downbeat (an upbeat or pickup) for forward motion. Start on it for weight.
+- Leave rests. A melody that never breathes can't phrase, and echo effects need the gaps.
+- Rhythmic contrast between phrases matters as much as pitch contrast. Change one, keep the other.
+
+## 7. Non-chord tones: where the feeling is
+
+On strong beats, use chord tones (`craft`: "strong beats on chord tones"; below 50 % the tune fights the
+harmony). Dissonance belongs in these shapes, each with its own effect (Aldwell & Schachter 2011, ch.
+9-10; Huron 2006 on tension and resolution):
+
+| Type | Shape | Effect |
+|---|---|---|
+| Passing | step, step, same direction, weak beat | flow, smoothness |
+| Neighbour | step away and back | ornament, gentle motion |
+| Appoggiatura | leap INTO the dissonance on a strong beat, resolve by step the other way | longing, the "sigh": strongest emotional pull |
+| Suspension | a note held from the previous chord, resolving down by step (4-3, 9-8, 7-6) | ache, tenderness, delayed release |
+| Anticipation | the next chord's note arrives early | eagerness, pop and jazz lift |
+| Escape | step in, leap out | a flick, playfulness |
+
+Outside common-practice idioms the added 6th and 9th count as colour tones, not dissonances (Levine 1995).
+
+## 8. Phrase endings
+
+- Answers end on 1, 3 or 5 over a stable chord. Questions end on 2, 5 or 7 (over V) or on a colour tone.
+- `craft` reports the share of phrases ending on chord tones and names a last note off the home triad.
+ An open ending is allowed where the mood asks for it (suspense, ambient, curious), and craft says so.
+
+## Checklist
+
+- [ ] One motif, rhythm first, heard 6-12 times, developed (sequence, inversion, fragmentation, augmentation).
+- [ ] Phrases in 2s and 4s. Questions end open, answers end home.
+- [ ] Arches. One climax, in the second half, on the key picture beat.
+- [ ] Mostly steps. Leaps turn back.
+- [ ] Chord tones on the beats. Appoggiaturas and suspensions where you want feeling.
+- [ ] Every part in its sweet range. The tune sits above the chords.
+
+Sources: Schoenberg, *Fundamentals of Musical Composition* (1967); Caplin, *Classical Form* (1998);
+Huron, "The Melodic Arch in Western Folksongs", *Computing in Musicology* 10 (1996); Huron, *Sweet
+Anticipation* (2006); Huron, "A comparison of average pitch height and interval size in major- and
+minor-key themes", *Empirical Musicology Review* 3 (2008); von Hippel & Huron, "Why do skips precede
+reversals?", *Music Perception* 18 (2000); Vos & Troost, "Ascending and descending melodic intervals",
+*Music Perception* 6 (1989); Dowling, "Scale and contour", *Psychological Review* 85 (1978);
+Aldwell & Schachter, *Harmony and Voice Leading* (4th ed., 2011); Levine, *The Jazz Theory Book*
+(1995); Adler, *The Study of Orchestration* (4th ed., 2016).
diff --git a/skills/anidoodle/references/music/theory/mood.md b/skills/anidoodle/references/music/theory/mood.md
new file mode 100644
index 0000000..3f8a14c
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/mood.md
@@ -0,0 +1,88 @@
+# Mood mapping: from a feeling to numbers
+
+Listeners agree on the emotion a piece *expresses* well above chance, and they agree because of a
+small set of structural cues. Those cues combine additively and redundantly: no single cue decides,
+and several pointing the same way make the emotion unmistakable (Juslin 2001, the lens model;
+Gabrielsson & Lindström 2010; Juslin & Laukka 2003). Composing a mood means aligning the cues.
+`craft`'s **mood** line checks tempo, mode family, melody register, note density, harmonic rhythm and
+(in `check`) brightness against the row for your declared mood (`tables.ts` `MOODS`).
+
+## 1. The cues, strongest first (Gabrielsson & Lindström 2010, summary of ~100 studies)
+
+| Cue | Toward happy / energetic | Toward sad / calm | Toward fear / anger |
+|---|---|---|---|
+| Tempo | fast | slow | fast (anger) or irregular (fear) |
+| Mode | major | minor | minor, chromatic, atonal |
+| Loudness | loud-moderate | soft | loud (anger), soft with big swings (fear) |
+| Register (pitch height) | high | low | low rumble or extreme high |
+| Harmony | simple, consonant | consonant or mildly dissonant | dissonant, clusters, tritones |
+| Articulation | staccato, detached | legato | sharp attacks (anger), tremolo (fear) |
+| Rhythm | regular, flowing, dotted and bouncy | regular, slow, sparse | complex, irregular, ostinato |
+| Timbre | bright, few low partials | dark, soft attacks | sharp, harsh, rough |
+| Intervals and contour | large, rising | small, falling | large jumps, chromatic steps |
+
+Also useful:
+
+- Mode and tempo alone swing happy/sad judgments strongly, with tempo usually the stronger
+ (Hevner 1935, 1937; Gagnon & Peretz 2003).
+- Arousal (calm to excited) follows tempo, loudness and density. Valence (negative to positive)
+ follows mode and consonance (Russell 1980; Schubert 2004; Eerola & Vuoskoski 2011, on film music).
+- Minor-key themes also use lower pitch and smaller intervals, like sad speech (Huron 2008).
+
+## 2. Mood table (the engine's 21 moods)
+
+Tempo, mode and register (the melody's median, MIDI note name) are the rows `craft` measures. The
+other columns are the craft to apply. "Density" is pitched note onsets per beat.
+
+| Mood | Tempo | Mode / harmony | Register | Density | Articulation | Orchestration | Dynamics |
+|---|---|---|---|---|---|---|---|
+| joy | 110-150 | major, mixolydian, pentatonic; triads, I-IV-V, bright 6ths | C5-C7 | 2-4 | staccato, bouncy dotted rhythms | mallets, plucks, music box, piano high | mf-f, steady |
+| playful | 120-160 | major, blues; quick chord changes, chromatic passing | C4-F#6 | 2-4 | staccato, rests, stops | pizzicato, mallets, woodwinds, bass hops | mf, sudden p/f |
+| tender | 60-80 | major, lydian; add9, suspensions resolving | E4-C6 | 1-2 | legato, soft attacks | piano, harp, strings, warm pad | p-mp, small swells |
+| wistful | 70-95 | dorian, major with borrowed iv | E4-D6 | 1.5-3 | legato, sighing appoggiaturas | piano, strings, music box | p-mf |
+| melancholy | 50-72 | aeolian, harmonic minor; descending bass, iv, VI | G3-G#5 | 0.75-1.5 | legato, long notes | piano low-mid, cello, strings | p-mp, long swells |
+| hopeful | 80-110 | major, melodic minor; rising sequences, IV-V-vi-I lift | C4-E6 | 1.5-3 | legato to detached | piano, strings, bells | mp rising to f |
+| curious | 80-110 | dorian, lydian, whole-tone colour | C4-C6 | 1-2 | light staccato, pizzicato | plucks, celesta, bells | p-mp |
+| tension | 90-130 | harmonic minor, phrygian; pedals, clusters, b2 | C3-C5 | 2-4 | ostinato, short, tremolo | low strings, pulse, drums | build p to f |
+| dread | 50-80 | phrygian, aeolian, locrian colour; drones, tritones | C2-C4 | 0.5-1.5 | long, slow attacks | low bowed, sub, dark piano | pp-mp, sudden f |
+| awe | 60-90 | lydian, major; chromatic mediants, open 5ths | C5-E7 | 1-3 | long, legato, swells | strings high, choir, bells, harp | p to ff over 4-8 bars |
+| triumph | 100-140 | major (or minor turning major); bVI-bVII-I | C4-F#6 | 3-6 | marcato, accents | brass, strings, drums, organ | f-ff |
+| drive | 110-140 | aeolian, dorian, mixolydian; riff harmony, pedal | C4-D6 | 4-8 | short, tight, 16ths | drums, bass, plucks, arps | f, compressed |
+| calm | 60-90 | mixolydian, pentatonic, major; slow harmonic rhythm | C4-C6 | 1-2 | legato, soft | guitar, pad, bells | p-mp, flat |
+| nostalgic | 70-95 | major with maj7 and borrowed iv | C4-C6 | 1.5-3 | relaxed, swung | e-piano, soft drums, bass | mp |
+| romantic | 60-85 | major, aeolian; suspensions, secondary dominants | C4-E6 | 1-2.5 | legato, rubato | piano, strings | p-f waves |
+| anger | 120-170 | phrygian, aeolian; power chords, dissonance | E2-C5 | 3-8 | hard accents | drums, distorted bass, brass | ff |
+| eerie | 50-90 | whole-tone, locrian, phrygian; clusters, no cadence | C3-C7 | 0.25-1 | tremolo, harmonics, glissandi | bowed, choir, celesta | pp, sudden |
+| mischief | 100-150 | blues, dorian, whole-tone; chromatic neighbours | G3-F#6 | 1.5-3 | staccato, rests, slides | woodwinds, pizzicato, mallets | p-mf, sneaky |
+| heroic | 90-130 | major, mixolydian, dorian; I-bVII-IV, rising 4ths and 5ths | G3-C6 | 1-3 | marcato, dotted | brass, strings, timpani, choir | f |
+| sensual | 65-95 | dorian, aeolian; 9ths and 11ths | G3-G#5 | 0.75-2 | legato, laid back | e-piano, bass, sax-like woodwind | mp |
+| grief | 40-62 | aeolian, harmonic minor; slow descending lines, suspensions | C3-E5 | 0.5-1 | long, legato | solo bowed, strings, piano, choir | pp-mf |
+
+Tempo and register numbers are the engine's starting rows, set from the research above and from
+listening. Where you disagree with a row for a brief, **write the brief's mood** and say why. `craft`
+only advises. The mode check passes any mode of the right family (major-third or minor-third modes),
+because the family is the emotional cue and the exact mode is colour.
+
+## 3. Use cases
+
+| Use | Length | Form | Notes |
+|---|---|---|---|
+| Product launch film | 30-60 s | intro, build, drop on the reveal, button | one motif, the climax on the logo or claim, a clean ending |
+| Explainer | 60-120 s | a steady groove bed, low melody density | leave the voice's band free (1-4 kHz): lead sparse and low-mid |
+| Site / app loop | 20-60 s | 4 or 8 bar loop, no cadence home at the end | low arousal, no sharp accents, seamless |
+| Game menu / trailer | 15-60 s | ostinato + motif, stingers on hits | heroic or playful, strong hook in 2 bars |
+| Ad (15-30 s) | 15-30 s | hook in the first 2-4 s, button ending | high arousal, bright, the brand beat on the last downbeat |
+| Meditation / sleep | 45 s+ | drone + sparse motif, slow harmonic rhythm | 50-70 bpm, legato, no percussion, open ending allowed |
+| Suspense cue | any | drone + pulse, stingers, withheld resolution | irregular accents, low register, an open end |
+
+Sources: Juslin & Sloboda (eds.), *Handbook of Music and Emotion* (2010), especially Gabrielsson &
+Lindström, "The role of structure in the musical expression of emotions", pp. 367-400; Juslin & Laukka,
+"Communication of emotions in vocal expression and music performance", *Psychological Bulletin* 129
+(2003); Juslin, "Communicating emotion in music performance" (the lens model), in Juslin & Sloboda
+(eds.), *Music and Emotion* (2001); Hevner, "The affective character of the major and minor modes",
+*American Journal of Psychology* 47 (1935), and "The affective value of pitch and tempo" 49 (1937);
+Gagnon & Peretz, "Mode and tempo relative contributions to happy-sad judgements", *Cognition and
+Emotion* 17 (2003); Russell, "A circumplex model of affect", *JPSP* 39 (1980); Schubert, "Modeling
+perceived emotion with continuous musical features", *Music Perception* 21 (2004); Eerola & Vuoskoski,
+"A comparison of the discrete and dimensional models of emotion in music", *Psychology of Music* 39
+(2011); Huron, *Empirical Musicology Review* 3 (2008).
diff --git a/skills/anidoodle/references/music/theory/rhythm.md b/skills/anidoodle/references/music/theory/rhythm.md
new file mode 100644
index 0000000..d0bd286
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/rhythm.md
@@ -0,0 +1,124 @@
+# Rhythm and groove
+
+Positions are beats in the bar (`1`, `1&` = the eighth after it, `1e&a` = sixteenths). In 6/8 and 12/8 a
+beat is a dotted quarter. `craft` measures this page on the **rhythm** line.
+
+## 1. Metric hierarchy
+
+Beats nest into levels, and a stronger level is heard as more important (Lerdahl & Jackendoff 1983;
+London 2012). `craft` weights positions this way:
+
+| Position | 4/4 | 3/4 | 6/8, 12/8 | weight |
+|---|---|---|---|---|
+| downbeat | 1 | 1 | 1 | 4 |
+| mid-bar | 3 | - | 7 (12/8) | 3 |
+| beats | 2, 4 | 2, 3 | the dotted quarters | 2 |
+| eighths | the `&`s | the `&`s | each eighth | 1 |
+| sixteenths | `e`, `a` | `e`, `a` | the sixteenths | 0 |
+
+Rules that follow from it:
+
+- Arrivals (cadences, section starts, the climax) go on downbeats.
+- Chord changes go on strong beats.
+- What sits on weak positions is motion.
+
+## 2. Syncopation
+
+A syncopation is an onset on a weak position followed by silence or a tie over a stronger one: the
+expected accent is displaced (Longuet-Higgins & Lee 1984). `craft` reports a syncopation index per
+layer: melody, bass, and kick+snare.
+
+- **The inverted U.** Medium syncopation makes people most want to move and enjoy it most. Too
+ little is stiff, too much loses the beat (Witek et al. 2014).
+- In groove idioms (lo-fi, hip-hop, house, funk, pop, jazz), `craft` warns when nothing is syncopated.
+ Anticipate the bass or a melody note by an eighth, or tie over beat 3.
+- Keep the **kick and backbeat anchored**, and syncopate on top of them. If everything is
+ syncopated, nothing is.
+
+## 3. The backbeat and core patterns
+
+| Idiom | Kick | Snare / clap | Hats |
+|---|---|---|---|
+| Rock / pop | 1, 3 (plus pushes on `2&` or `3&`) | 2, 4 | eighths |
+| Four on the floor (house, disco) | every beat | 2, 4 | off-beat `&` open hat |
+| Hip-hop / boom bap | 1, `2&`, `3&` (varies) | 2, 4, lazy (late) | swung eighths or sixteenths |
+| Half-time (trap, cinematic) | 1, `3a` | 3 | fast sixteenths and triplet rolls |
+| Lo-fi | loose 1 and `3&` | 2, 4, soft and late | swung, quiet |
+| Waltz 3/4 | 1 | 2, 3 (or brushes) | - |
+| 6/8 gallop | 1, 4 | 4 (or 2 and 5) | eighths |
+
+Write your own, and let the family be the idiom rather than the notes. `craft`'s **groove consistency**
+compares each bar's kick and snare with the section's commonest bar. Below 0.45 the groove never
+settles. Hold the kick and backbeat, and vary the hats and the fill bar.
+
+## 4. Swing and feel
+
+- **Swing ratio** = long:short eighth. 1:1 is straight, 2:1 is triplet, 3:1 is dotted.
+- Jazz drummers swing **harder at slow tempos and straighter at fast ones**: up to about 3.5:1 slow,
+ down to about 1:1 fast. The short note stays near 100 ms (Friberg & Sundström 2002).
+- The engine's `swing` is the long note's share: 0.5 straight, 0.58 is about 1.4:1, 0.67 is triplet.
+ Typical settings:
+ - lo-fi and hip-hop 0.54-0.62 (sixteenth swing);
+ - jazz 0.6-0.67 (eighths, less at fast tempos);
+ - house 0.5-0.56;
+ - rock and orchestral 0.5.
+- **Push and lay back:** hats slightly early drive, a snare 10-25 ms late relaxes (the "lazy"
+ hip-hop and lo-fi backbeat), and the kick stays on the grid. The engine's `perform` applies per-lane
+ feel. You choose the style and swing.
+
+## 5. Polyrhythm and hemiola
+
+- **Hemiola:** 3 against 2. Two bars of 3/4 regrouped as three bars of 2/4 is the classic cadence
+ approach, and it drives any ending.
+- **3 over 4:** a three-note cell in running sixteenths realigns every 3 beats. It gives motion
+ without changing the tempo, as in minimalism and tension cues.
+- **Odd meters:** 7/8 = 2+2+3, 5/4 = 3+2. Accent the group starts so the ear can count.
+
+## 6. Fills and transitions
+
+- A fill goes on the **last bar (or half bar) of a section**, never in the middle of a phrase. It ends
+ **on the next downbeat** with a crash or an arrival.
+- Build to a landing:
+ 1. density rises (eighths to sixteenths);
+ 2. the snare rolls up;
+ 3. a beat or a bar of silence (the breath) comes just before the drop.
+
+ The silence makes the landing bigger (Huron 2006, the tension-contrast effect).
+- One fill per 4-8 bars. More turns into noise.
+
+## 7. Density arcs
+
+- Section contrast is mostly density: layers in and out, and onsets per beat. `craft` prints each
+ section's onsets per beat and layer count. It warns when every section is the same, and when a
+ section repeats the previous one note for note (dead air).
+- A good arc:
+ 1. sparse intro;
+ 2. medium verse;
+ 3. the hook adds a layer;
+ 4. the breakdown thins to one or two;
+ 5. the drop brings everything;
+ 6. the outro thins again.
+
+## 8. Rhythm in the melody
+
+A line with **one repeated rhythm and a few changes** is memorable. The same pitches with a new rhythm
+are a new tune (this is why the novelty fingerprint weighs rhythm most). Vary one axis at a time.
+
+## 9. Humanize or quantize
+
+- Machines are perfectly on grid. Players deviate in **correlated** ways (drifting ahead or behind for
+ several notes, 1/f-like), and listeners prefer that to random jitter (Hennig et al. 2011).
+- Random jitter is not feel: listeners do not rate randomly microtimed grooves above quantized ones
+ (Frühauf, Kopiez & Platz 2013; Senn et al. 2016).
+- The engine: `perform` adds correlated micro-timing and per-lane feel. Grid parts (music box,
+ chiptune, drive) stay mechanical on purpose. Velocity (`@0.6`) carries accents: write strong-weak
+ patterns (ghost notes at 0.3-0.5) instead of hoping the performer invents them.
+
+Sources: Lerdahl & Jackendoff, *A Generative Theory of Tonal Music* (1983); London, *Hearing in Time*
+(2nd ed., 2012); Longuet-Higgins & Lee, "The rhythmic interpretation of monophonic music", *Music
+Perception* 1 (1984); Witek et al., "Syncopation, body-movement and pleasure in groove music", *PLoS
+ONE* 9 (2014); Friberg & Sundström, "Swing ratios and ensemble timing in jazz performance", *Music
+Perception* 19 (2002); Hennig et al., "The nature and perception of fluctuations in human musical
+rhythms", *PLoS ONE* 6 (2011); Frühauf, Kopiez & Platz, "Music on the timing grid", *Musicae
+Scientiae* 17 (2013); Senn et al., "The effect of expert performance microtiming on listeners'
+experience of groove in swing or funk music", *Frontiers in Psychology* 7 (2016); Huron, *Sweet Anticipation* (2006).
diff --git a/skills/anidoodle/references/music/theory/sound.md b/skills/anidoodle/references/music/theory/sound.md
new file mode 100644
index 0000000..635af1d
--- /dev/null
+++ b/skills/anidoodle/references/music/theory/sound.md
@@ -0,0 +1,115 @@
+# Sound theory: psychoacoustics for composing and mixing
+
+You write notes, and the engine mixes. Most "muddy", "thin" or "buried" results are decided by the
+notes: register, spacing, density and which parts overlap. This page is the physics behind those
+choices. The engine's guards and `craft` check the parts you can control from the score. The mix
+chain itself is in `render.ts` and `mixProfiles.ts` ([../sound-design.md](../sound-design.md) covers
+effects).
+
+## 1. Critical bands and roughness
+
+- The ear analyses sound in overlapping **critical bands**, about 100 Hz wide below 500 Hz and about
+ 20 % of the centre frequency above that (Zwicker 1961; the ERB is 24.7 x (4.37 f/kHz + 1) Hz,
+ Glasberg & Moore 1990).
+- Two partials inside one band **beat and roughen**. Roughness peaks near a quarter of a critical band
+ apart (Plomp & Levelt 1965).
+- Low down, a band spans many semitones, so **a third at C2 is rough while the same third at C4 is
+ sweet.**
+
+That is the physics of the **low interval limits** (the chart taught in Berklee arranging; e.g. Pease &
+Pullig 2001), the lowest bottom note for each interval before it muddies:
+
+| Interval | m2 | M2 | m3 | M3 | P4 | tritone | P5 | m6-M7 | m9 | M9 |
+|---|---|---|---|---|---|---|---|---|---|---|
+| Lowest bottom note | E3 | Eb3 | C3 | Bb2 | Bb2 | B2 | Bb1 | F2 | E2 | Eb2 |
+
+- Octaves have no limit. The chart is loose by about ±2 semitones (a concert grand gets away with
+ more), so `craft` flags intervals 3 or more semitones under their limit.
+- Fix: spread the voicing (`1-5-3'` instead of `1-3-5` in the bass), or lift the upper note an octave.
+
+## 2. Masking: why the tune gets buried
+
+- A louder sound hides a quieter one in the same critical band. Masking spreads **upward**: a loud low
+ sound masks higher sounds more than the reverse (Zwicker & Fastl 2007; Moore 2012).
+- A pad or chord stack in the melody's octave masks the melody even at a lower level. The engine's
+ masking guard requires the melody to beat every other part by 3 dB in 500 Hz-4 kHz.
+- **Composing fixes come before level fixes:**
+ - voice the chords below the tune (`craft`: "melody under chords");
+ - thin the accompaniment when the melody moves;
+ - give the lead a distinct timbre and its own octave;
+ - let counter lines answer in the rests instead of overlapping.
+- **Frequency slots** ([form.md](form.md) section 4): one owner per register at a time.
+
+## 3. Equal loudness (Fletcher-Munson / ISO 226)
+
+- Hearing is least sensitive at the extremes and most sensitive at 2-5 kHz. At low listening levels
+ the lows and highs drop away (Fletcher & Munson 1933; ISO 226:2003).
+- A bass line that is "loud enough" on studio monitors disappears on a phone speaker (the small
+ speaker rolls off below about 150-200 Hz). **Phone rule:** every low part needs harmonics above
+ 500 Hz: a bass with some drive or a pick attack, and an 808 with saturation. Octave-doubling the bass
+ line an octave up at a low level also works.
+- A quiet passage sounds thinner, not just quieter. Soft sections can take slightly more low-mid warmth.
+
+## 4. Tonal balance by genre (long-term spectrum)
+
+- Commercial mixes cluster around a smooth downward slope, about -5 dB per octave from 100 Hz to
+ 4 kHz, steeper above (Pestana et al. 2013). The shape has held across decades and genres.
+ The genres differ at the ends:
+
+| Genre | Low end | Mids | Top |
+|---|---|---|---|
+| EDM, hip-hop, trap | +3-6 dB sub (40-80 Hz), the kick and 808 dominate | scooped slightly around 300-500 Hz | bright hats |
+| Pop, rock | full, the kick and bass balanced | vocal and guitar forward at 1-4 kHz | bright |
+| Lo-fi | warm, head bump 60-90 Hz | forward low-mids | rolled off above 8-10 kHz |
+| Orchestral, acoustic | natural, less sub | wide | natural roll-off from distance and hall |
+| Ambient | soft lows, long tails | recessed | airy but gentle |
+
+- The engine's mix profiles implement these, and `check` measures the centroid for the mood. For
+ composing: **a dark mood wants lower registers and fewer bright attacks, not just a darker filter.**
+
+## 5. Stereo and depth
+
+- **Mono lows:** keep the kick, bass and anything below about 120 Hz in the centre. Low frequencies
+ carry little direction and eat headroom when spread.
+- **Width comes from difference**: different parts (or the same part voiced differently) on each side,
+ and two players with slight timing and tuning differences. One part copied to both sides is still
+ mono.
+- **The precedence (Haas) effect:** the same sound 1-30 ms later is heard as one sound from the
+ earlier side (Haas 1951; Blauert 1997). It is useful for width on doubles, and dangerous for mono
+ playback (comb filtering).
+- **Depth cues:** a far sound is quieter, darker (the air absorbs highs), wetter (a higher
+ reverb-to-direct ratio) and has softer attacks. Put the lead near and the pads far.
+
+## 6. Reverb and delay timing
+
+- **Tempo-synced delay:** a quarter note = 60,000 / bpm ms (at 90 bpm, 667 ms). A dotted eighth = 0.75 x
+ that. An eighth = 0.5 x.
+- **Pre-delay** (the gap before the reverb starts) keeps the attack dry and the part clear. 10-30 ms
+ is typical. Longer (up to a 1/32 or 1/64 note) keeps the vocal and lead forward (Izhaki 2017).
+- **Decay time to the tempo:** let the tail die before the next strong beat (a quarter to a half
+ note). Longer tails blur harmony changes. The engine's reverb guard fails a tail within 10 dB of the
+ dry sound.
+- **Slow and sparse = more space. Fast and dense = less.** Many notes plus a long hall is the "ghost"
+ wash that the ghost guard exists for.
+
+## 7. Loudness and dynamics
+
+- The engine masters to -16 LUFS (gentle) or -14 LUFS (dense), -1 dBTP, the streaming norms (AES TD1004,
+ 2015).
+- **Real dynamics are written, not mastered:** section `energy`, `dyn` and velocities. A peak is a
+ composing problem: stagger the bass under the loudest downbeat, roll the big chord, and don't double
+ the climax note in every part.
+- Perceived loudness follows density and brightness as well as level. A build can feel louder with more
+ onsets and a higher register at the same meter reading.
+
+Sources: Zwicker, "Subdivision of the audible frequency range into critical bands", *JASA* 33 (1961);
+Glasberg & Moore, "Derivation of auditory filter shapes from notched-noise data", *Hearing Research*
+47 (1990); Plomp & Levelt, "Tonal consonance and critical bandwidth", *JASA* 38 (1965); Zwicker &
+Fastl, *Psychoacoustics: Facts and Models* (3rd ed., 2007); Moore, *An Introduction to the Psychology
+of Hearing* (6th ed., 2012); Fletcher & Munson, "Loudness, its definition, measurement and
+calculation", *JASA* 5 (1933); ISO 226:2003; Pestana, Ma, Reiss, Barbosa & Black, "Spectral
+characteristics of popular commercial recordings 1950-2010", AES 135th Convention (2013); Haas, "Über
+den Einfluss eines Einfachechos auf die Hörsamkeit von Sprache", *Acustica* 1 (1951); Blauert,
+*Spatial Hearing* (1997); Izhaki, *Mixing Audio* (3rd ed., 2017); Owsinski, *The Mixing Engineer's
+Handbook* (4th ed., 2017); Katz, *Mastering Audio* (3rd ed., 2015); Pease & Pullig, *Modern Jazz
+Voicings* (2001); AES TD1004.1.15-10, "Recommendation for loudness of audio streaming and network file playback" (2015).