Pitch
Meantonal stores pitches as two-dimensional vectors. C₋₁ is defined to be to conform to 0 representing the MIDI value for the same pitch.
- The first component of a pitch’s vector represents increments in whole steps.
- The second component represents increments in diatonic semitones (that is, from C to D♭, not from C to C♯).
Internally, the Pitch
type is defined as a simple struct:
typedef struct { int w; int h;} Pitch;
A simple scale
Section titled “A simple scale”To help understand what this means, let’s see how we would represent the pitches of a C major scale from C₋₁ to C₀, given the familiar formula of WWHWWWH:
C₋₁ | D₋₁ | E₋₁ | F₋₁ | G₋₁ | A₋₁ | B₋₁ | C₀ |
Or, arranged on the coordinate plane:
The Meantonal grid
Section titled “The Meantonal grid”Pitches can therefore be thought of as lying on an infinite two-dimensional grid, of which an arbitrary portion is represented below as illustration.
D♭⁴₄ | E♭⁴₄ | F♭³₄ | G♭³₄ | A♭³₄ | B♭³₄ | C♭♭₅ | D♭♭₅ | E♭♭₅ |
C♭³₄ | D♭³₄ | E♭³₄ | F♭♭₄ | G♭♭₄ | A♭♭₄ | B♭♭₄ | C♭₅ | D♭₅ |
B♭³₃ | C♭♭₄ | D♭♭₄ | E♭♭₄ | F♭₄ | G♭₄ | A♭₄ | B♭₄ | C₅ |
A♭♭₃ | B♭♭₃ | C♭₄ | D♭₄ | E♭₄ | F₄ | G₄ | A₄ | B₄ |
G♭₃ | A♭₃ | B♭₃ | C₄ | D₄ | E₄ | F♯₄ | G♯₄ | A♯₄ |
F₃ | G₃ | A₃ | B₃ | C♯₄ | D♯₄ | E♯₄ | F♯♯₄ | G♯♯₄ |
E₃ | F♯₃ | G♯₃ | A♯₃ | B♯₃ | C♯♯₄ | D♯♯₄ | E♯♯₄ | F♯³₄ |
D♯₃ | E♯₃ | F♯♯₃ | G♯♯₃ | A♯♯₃ | B♯♯₃ | C♯³₄ | D♯³₄ | E♯³₄ |
C♯♯₃ | D♯♯₃ | E♯♯₃ | F♯³₃ | G♯³₃ | A♯³₃ | B♯³₃ | C♯⁴₄ | D♯⁴₄ |
In practice, Western music only generally uses accidentals up to double sharps and flats, but higher-order accidentals come for free as a result of Meantonal’s vector representation and can be useful for people working with alternative tuning systems, or in various algorithms for generating musical content that will eventually be enharmonically respelled for legibility.
Although the abstract vector space of whole steps and half steps shown above is theoretically infinite, Meantonal represents these coordinates with signed integers.
Just how much range is this, though? Do we cover as many octaves as MIDI at least?
To put things in perspective: and represent C₋₂₆ and C₂₄ and would be well-represented by the Pitch
type even if it were capped at 8-bit integers. That’s eome fifty octaves of range, or from roughly 240nHz to 264MHz.
Suffice to say: you’re not going to run out of pitches.
Parsing SPN
Section titled “Parsing SPN”Scientific pitch notation (SPN) is a common system for representing pitches in text. It consists of essentially three components:
Letter | Accidental | Octave |
---|---|---|
A | ♭ | 5 |
Meantonal constructs a pitch vector with the following formula:
Where represents the initial letter vector, selected from this table:
C | D | E | F | G | A | B |
represents the accidental, whose values are assigned as follows:
Accidental | A |
---|---|
etc. | |
♯♯ | 2 |
♯ | 1 |
♮ | 0 |
♭ | -1 |
♭♭ | -2 |
etc. |
represents the octave. Since we want to represent C₋₁, the value of is greater than the octave component of a pitch’s SPN value by 1.
Putting it all together, the pitch vector for A♭5 would be: