music.consonance

music.consonance(interval_or_semitones)[source]

How the article classifies an interval.

Parameters:
interval_or_semitonesstr or integer

An interval name, or its semitone count.

Returns:
str

One of "perfect consonance", "imperfect consonance", "weak dissonance", "strong dissonance", or "context dependent" for the two the article declines to settle: the perfect fourth, “a perfect consonance when considered as an inversion of the perfect fifth and a dissonance or an imperfect consonance otherwise”, and the tritone, “consonant in some cultures”.

Raises:
ValueError

If the interval is negative, or its name is not one.

Parameters:

interval_or_semitones (str | int)

Return type:

str

See also

CONSONANCE

the classification, as a table.

Notes

A compound interval “is classified in terms of the simple interval between the same notes but in the same octave”, so a major ninth is classified as the major second it is an octave above.

Examples

>>> consonance("P5")
'perfect consonance'
>>> consonance("m2")
'strong dissonance'
>>> consonance("P4"), consonance("TT")
('context dependent', 'context dependent')