music.interval_between¶
- music.interval_between(lower, upper)[source]¶
The interval in semitones between two frequencies, rounded.
- Parameters:
- lower, upperscalar
Frequencies in Hertz. upper is expected above lower.
- Returns:
integerSemitones, to the nearest one – the frequencies of real notes are not exactly tempered, and an interval is a name for a neighbourhood rather than for one ratio.
- Raises:
ValueErrorIf either frequency is not positive, or upper is below lower.
- Parameters:
- Return type:
See also
interval_namesnames the result.
hz_to_midithe same conversion, against a fixed reference.
Examples
>>> interval_between(220.0, 330.0) # a fifth, near enough 7 >>> interval_names(interval_between(220.0, 440.0)) ('P8',)