> ## Documentation Index
> Fetch the complete documentation index at: https://pkhambat.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Key and mode

> key and mode: the root that degrees and numerals count from, and how the music is written.

`key` is a note and `mode` is a setting of its own, so `set key E` then `set mode minor` is E minor. Each keeps the other: after `set mode minor`, a later `set key G` is G minor. On a [`with`](https://pkhambat.mintlify.site/language/settings#with), a block plays in another key.

Degrees and Roman numerals count on the key's own scale, the mode's. In D minor, `iii` is F and `vi` is Bb; in D dorian, `vi` is B; in D major, `iii` is F#. So the same line in another mode sounds in that mode: change `set mode` and the notes change with it. A `b` or `#` in front moves a degree or numeral a semitone off the scale, as minor's raised seventh is `#vii`. The modes are `major`, `minor`, `dorian`, `phrygian`, `lydian`, `mixolydian`, `locrian`, `harmonicMinor`, `melodicMinor` and `wholeTone`. Each has one name: Ionian is `major` and Aeolian is `minor`. The mode also gives the sheet its key signature (D dorian has none, A mixolydian two sharps; harmonic and melodic minor take natural minor's signature and write their raised notes as accidentals, and whole tone takes major's) and how accidentals are spelt.

```composer-nb theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
chords chart = i ii|iii iv|v vi|vii i'|vii vi|v iv|iii ii|i

with key D, mode dorian { play piano: chords chart }
with key D, mode minor { play piano: chords chart }
with key D, mode major { play piano: chords chart }
```

A lowercase numeral in a chart is the chord the scale has on that degree, so one chart goes up the scale and back down in every mode, and each mode makes its own chords. In D dorian they are Dm Em F G Am Bdim C: the `iv`, G, is major, where natural minor has Gm. In D minor the same chart plays Dm Edim F Gm Am Bb C, and in D major D Em F#m G A Bm C#dim. A quality after the numeral says the chord outright instead: `iv` is a major chord on the 4th degree whatever the mode, and a plain lowercase numeral takes the scale's own fifth, so `vii` is diminished in major. The [grooves](https://composer-nb.vercel.app/grooves/) have the same walk in each mode, lydian to wholeTone.

Harmonic minor is minor with a raised 7th, melodic minor (its ascending form) is minor with a raised 6th and 7th, and whole tone is six notes a whole step apart, so its degrees are `i` to `vi` and a `vii` is an error. The chart above in D harmonic minor plays Dm Edim Faug Gm A Bb C#dim, and in melodic minor Dm Em Faug G A Bdim C#dim.

```composer-nb theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/composer-nb.json"]}}
chords chart = i ii|iii iv|v vi|vii i'|vii vi|v iv|iii ii|i

with key D, mode harmonicMinor { play piano: chords chart }
with key D, mode melodicMinor { play piano: chords chart }
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.