MUSX Document Model
|
A dependency-free, header-only collection of useful functions for music theory. More...
Classes | |
class | Transposer |
Provides dependency-free transposition utilities that work with any scale that has 7 diatonic steps and an equal number of divisions of the octave (EDO). The most common Western scales use 12 divisions of the octave, .i.e., 12-EDO. More... | |
Enumerations | |
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... | |
Functions | |
int | calcDisplacement (int pitchClass, int octave) |
Calculates the displacement value for a given absolute pitch class and octave. | |
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. | |
int | calc12EdoHalfstepsInInterval (int interval, int chromaticAlteration) |
Calculates the number of 12-EDO chromatic halfsteps in the specified interval. | |
int | calcAlterationFrom12EdoHalfsteps (int interval, int halfsteps) |
Calculates the alteration in chromatic halfsteps for the specified interval/halfsteps combination. | |
int | calcAlterationFromKeySigChange (int interval, int keySigChange) |
Determines the chromatic alteration needed for a diatonic interval to produce a desired key signature change. | |
Variables | |
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 >, 7 > | DIATONIC_INTERVAL_ADJUSTMENTS |
Array of diatonic intervals. Each member array contains. | |
A dependency-free, header-only collection of useful functions for music theory.
|
strong |
Represents the possible types of clef, irrespective of octave transposition.
|
strong |
Represents the seven standard diatonic musical modes.
Values correspond to their roots with no sharps or flats C (0) through B (6).
Enumerator | |
---|---|
Ionian | major |
Dorian | minor with raised 6 |
Phrygian | minor with flat 2 |
Lydian | major with raised 4 |
Mixolydian | major with flat 7 |
Aeolian | natural minor |
Locrian | diminished with flat 2 and 5 |
|
inline |
Calculates the number of 12-EDO chromatic halfsteps in the specified interval.
interval | The diatonic displacement (negative for downward intervals). |
chromaticAlteration | The chromatic halfstep alteration that defines the chromatic interval. |
|
inline |
Calculates the alteration in chromatic halfsteps for the specified interval/halfsteps combination.
interval | The diatonic displacement (negative for downward transposition). |
halfsteps | The number of 12-EDO chromatic halfsteps in the interval (negative means down). |
|
inline |
Determines the chromatic alteration needed for a diatonic interval to produce a desired key signature change.
interval | The diatonic interval (e.g. +3 for a perfect fourth up). |
keySigChange | The desired change in key signature (positive for sharps added, negative for flats). |
|
inline |
Calculates the displacement value for a given absolute pitch class and octave.
pitchClass | 0..6 corresponding to C..B |
octave | Octave 4 is the middle-C octave |
|
constexpr |
Calculates a positive modulus in the range [0, d-1], even for negative dividends.
T | An integer type. |
n | The dividend (may be negative). |
d | The modulus base (must be positive). |
q | Optional pointer to receive the quotient such that n = d * q + result. |
|
inlineconstexpr |
Calculates the sign of an integer.
n | The integer to process. |
|
constexpr |
Calculates the modulus of positive and negative numbers in a predictable manner.
T | an integer type |
n | The number (positive or negative) for which to calculate the modulus |
d | The base of the modulus. This must be a positive number. |
%
. For negative numbers, the result is -1 * (abs(n) % d)
.
|
constexpr |
Array of diatonic intervals. Each member array contains.