Skip to main content

Module interval

Module interval 

Source
Expand description

Public interval parsing, naming and transposition helpers.

Structs§

ChromaticInterval
A signed number of semitones, fractional for microtonal intervals.
DiatonicInterval
A quality and a generic interval together: M3, -P5, dd7.
GenericInterval
A directed interval counted in scale steps: 3 is a third up, -3 a third down, 1 a unison. Zero is not an interval.
Interval
A directed musical interval with diatonic spelling and chromatic size.

Enums§

IntervalDirection
Direction of a directed interval.
Specifier
An interval quality, numbered as music21 numbers its Specifier enum.

Functions§

absolute_higher_pitch
The pitch that sounds higher: music21’s getAbsoluteHigherNote. Enharmonic equals return the first.
absolute_lower_pitch
The pitch that sounds lower: music21’s getAbsoluteLowerNote. Enharmonic equals return the first.
convert_diatonic_number_to_step
The step letter and octave of a diatonic note number, counting C0 as 1: music21’s convertDiatonicNumberToStep, so 15 is C in octave 2, 0 is B in octave -1, and -19 is D in octave -3.
convert_generic
music21’s convertGeneric for a number: the number itself, since the sign already carries the direction.
convert_semitone_to_specifier_generic
The simplest quality and generic size for a semitone count: music21’s convertSemitoneToSpecifierGeneric, so 6 is a diminished fifth and -14 a descending major ninth.
convert_semitone_to_specifier_generic_microtone
Like convert_semitone_to_specifier_generic for a fractional semitone count, returning the leftover in cents as well: music21’s convertSemitoneToSpecifierGenericMicrotone, so 2.5 is a major second and fifty cents, and -2.5 a descending minor third and fifty.
intervals_to_diatonic
Reads the quality off a generic and a chromatic interval together: music21’s intervalsToDiatonic, so a third of four semitones is major.
notes_to_chromatic
The semitone distance from one pitch to another: music21’s notesToChromatic.
notes_to_generic
The generic interval from one pitch to another, counted by staff position: music21’s notesToGeneric.
parse_specifier
Parses an interval quality from its prefix or spelled-out name: music21’s parseSpecifier, so "P", "perfect" and "Perfect" all give Specifier::Perfect.
staff_distance_to_generic_number
music21’s convertStaffDistanceToInterval: a signed count of staff steps as a signed generic interval number, so 0 is a unison, 2 a third and -1 a descending second.
written_higher_pitch
The pitch written higher on the staff, whatever it sounds like: music21’s getWrittenHigherNote, so C4 over B#3. Ties in staff position are settled by sound, and a complete tie returns the first.
written_lower_pitch
The pitch written lower on the staff: music21’s getWrittenLowerNote, so B#3 under C4.