A dependency-free, header-only collection of useful functions for music theory.
More...
|
| enum class | NoteName : int {
C = 0
, D = 1
, E = 2
, F = 3
,
G = 4
, A = 5
, B = 6
} |
| | The available note names in array order.
|
| |
| enum class | DiatonicMode : int {
Ionian = 0
, Dorian = 1
, Phrygian = 2
, Lydian = 3
,
Mixolydian = 4
, Aeolian = 5
, Locrian = 6
} |
| | Represents the seven standard diatonic musical modes. More...
|
| |
| enum class | ClefType {
Unknown
, G
, C
, F
,
Percussion1
, Percussion2
, Tab
, TabSerif
} |
| | Represents the possible types of clef, irrespective of octave transposition. More...
|
| |
|
| constexpr int | calcDisplacement (const Pitch &pitch) |
| | Calculates the displacement value for a spelled pitch.
|
| |
| template<typename T > |
| constexpr T | sign (T n) |
| | Calculates the sign of an integer.
|
| |
| template<typename T > |
| constexpr T | signedModulus (T n, T d) |
| | Calculates the modulus of positive and negative numbers in a predictable manner.
|
| |
| template<typename T > |
| constexpr T | positiveModulus (T n, T d, T *q=nullptr) |
| | Calculates a positive modulus in the range [0, d-1], even for negative dividends.
|
| |
| constexpr int | calcPitchClass (NoteName noteName, int alteration=0, int numberOfEdoDivisions=STANDARD_12EDO_STEPS, const std::array< int, STANDARD_DIATONIC_STEPS > &keyMap=MAJOR_KEYMAP) |
| | Calculates the pitch class of a spelled note name.
|
| |
| constexpr int | calcPitchClass (const Pitch &pitch, int numberOfEdoDivisions=STANDARD_12EDO_STEPS, const std::array< int, STANDARD_DIATONIC_STEPS > &keyMap=MAJOR_KEYMAP) |
| | Calculates the pitch class of a spelled pitch, ignoring its octave.
|
| |
| constexpr int | calc12EdoHalfstepsInInterval (int interval, int chromaticAlteration) |
| | Calculates the number of 12-EDO chromatic halfsteps in the specified interval.
|
| |
| constexpr int | calcAlterationFrom12EdoHalfsteps (int interval, int halfsteps) |
| | Calculates the alteration in chromatic halfsteps for the specified interval/halfsteps combination.
|
| |
| constexpr int | calcAlterationFromKeySigChange (int interval, int keySigChange) |
| | Determines the chromatic alteration needed for a diatonic interval to produce a desired key signature change.
|
| |
| constexpr int | calcKeySigChangeFromInterval (int interval, int chromaticAlteration) |
| | Calculates the resulting key signature change (sharps/flats) produced by a diatonic interval and chromatic alteration.
|
| |
| constexpr bool | calcTranspositionIsOctave (int displacement, int alteration) |
| | Determines if the transposition values result in trasposing by one or more octaves.
|
| |
|
|
constexpr int | STANDARD_NUMBER_OF_STAFFLINES = 5 |
| | The standard number of lines on a staff.
|
| |
|
constexpr int | STANDARD_DIATONIC_STEPS = 7 |
| | currently this is the only supported number of diatonic steps.
|
| |
|
constexpr int | STANDARD_12EDO_STEPS = 12 |
| | this can be overriden when constructing a Transposer instance.
|
| |
|
constexpr std::array< int, STANDARD_DIATONIC_STEPS > | MAJOR_KEYMAP = { 0, 2, 4, 5, 7, 9, 11 } |
| | keymap for 12-EDO major keys
|
| |
|
constexpr std::array< int, STANDARD_DIATONIC_STEPS > | MINOR_KEYMAP = { 0, 2, 3, 5, 7, 8, 10 } |
| | keymap for 12-EDO minor keys
|
| |
| constexpr std::array< std::array< int, 2 >, STANDARD_DIATONIC_STEPS > | DIATONIC_INTERVAL_ADJUSTMENTS |
| | Array of chromatic intervals. Each member array contains.
|
| |
A dependency-free, header-only collection of useful functions for music theory.
Calculates the pitch class of a spelled note name.
The pitch class is the note's chromatic position within one octave, counting from the natural note name and then applying the alteration. Enharmonics share a pitch class, so C♯ and D♭ both return 1 in 12-EDO.
keyMap gives the EDO division of each natural note name in C-first order, which is the same thing as the major scale rooted at C. It cannot be derived from numberOfEdoDivisions alone: 31-EDO places the naturals at { 0, 5, 10, 13, 18, 23, 28 }, so both values are needed, exactly as Transposer takes them. Note that a key signature's own key map is relative to its tonal center, so it suits Transposer rather than this function.
- Parameters
-
| noteName | The diatonic note name. |
| alteration | The alteration relative to the natural note name, in EDO divisions. |
| numberOfEdoDivisions | The number of divisions in the EDO. (E.g., 31-EDO would pass 31.) |
| keyMap | A 7-element map giving the EDO division of each natural note name, C first. |
- Returns
- The pitch class, in the range [0,
numberOfEdoDivisions - 1].