# music-theory (engines/adapters/domain/music-theory)

Pitch-class / theory capability pack: build scales (major, natural/harmonic/melodic minor, the 7 modes, pentatonic, blues, chromatic), spell chords (triads through 7ths, sus, add9, altered), name the...


Pitch-class / music-theory **capability pack**. Net-new pure-JS build — everything is note-name and
interval arithmetic mod 12. Zero npm deps, deterministic, one contract
(`export default { metadata, adapters }`).

## Tools (`adapters`)

| tool | args | result |
|------|------|--------|
| `scale` | `{ root, type='major' }` | note list for the scale + semitone intervals |
| `chord` | `{ root, type='maj' }` | note list + intervals for the chord |
| `interval` | `{ from, to }` | interval name (e.g. `Perfect 5th`) + semitones |
| `transpose` | `{ notes:[], semitones }` | notes moved up/down (negative = down) |
| `keySignature` | `{ key, mode='major' }` | sharp/flat count + accidentals + notes (minor keys resolve via relative major) |
| `circleOfFifths` | `{}` | the 12 keys — major, relative minor, accidentals |
| `chordProgression` | `{ key, pattern=['I','IV','V'], mode='major' }` | roman numerals → diatonic chords in key |
| `romanNumeralAnalysis` | `{ key, chords:[], mode='major' }` | reverse: chord names → roman numerals |
| `identifyChord` | `{ notes:[] }` | name the chord from a set of notes |
| `noteInfo` | `{ note }` | pitch class + enharmonic equivalents |

**Scale types:** major, minor (natural), harmonicMinor, melodicMinor, dorian, phrygian, lydian,
mixolydian, locrian, pentatonicMajor, pentatonicMinor, blues, chromatic (plus `natural`/`harmonic`/
`melodic` aliases).

**Chord types:** maj, min, dim, aug, sus2, sus4, 6, min6, maj7, min7, dom7 (`7`), dim7, min7b5
(`m7b5`), aug7, add9, 9, maj9, min9, 5 (power).

### Notes & enharmonics

Notes are represented as names (`C`, `C#`, `Db`, `D`…). Diatonic 7-note scales are spelled with
proper letter-per-degree accidentals (G major → `F#`, not `Gb`); chords and non-diatonic scales are
spelled sharp- or flat-biased from the root's own accidental. `noteInfo` returns every enharmonic
equivalent for a pitch class. Octave digits in a note name are accepted but ignored — this pack is
pitch-class only.

## DRY boundary (who owns what)

- **music-theory vs `hz`** — this pack is **pitch-class / theory only**: note names, intervals,
 scales, chords, keys. **Note<->frequency and note<->MIDI conversions live ONLY in the sibling `hz`
  pack** (`shared/engines/adapters/domain/hz`): `noteToFreq`, `freqToNote`, `midiToFreq`,
  `freqToMidi`, `cents`, `harmonics`. Never duplicate the 12-TET frequency/MIDI table here — call
  `hz` for anything involving Hz or MIDI numbers.

`adapterToServer()` (`@leumas/mcp-kit`) exposes each tool as an MCP tool + API route + form.


---
Source: shared/engines/adapters/domain/music-theory/README.md
Canonical: https://docs.leumas.tech/p/adapters/domain/music-theory
