music.midi_to_hz_interval¶
- music.midi_to_hz_interval(midi_interval)[source]¶
Converts an interval in semitones to the ratio of its frequencies.
An interval is a ratio between two frequencies, whatever they are: an octave, 12 semitones, is a ratio of 2, from 110 Hz to 220 Hz as from 440 Hz to 880 Hz. Multiply a frequency by the ratio to move it by the interval.
- Parameters:
- midi_interval
float The interval in semitones, as a difference of MIDI note numbers.
- midi_interval
- Returns:
floatThe ratio of the upper frequency to the lower,
2 ** (n / 12): a number, not a frequency in Hertz. A negative interval gives a ratio below one.
- Parameters:
midi_interval (float)
- Return type:
See also
midi_to_hzthe frequency of a MIDI note, rather than a ratio.
Examples
>>> midi_to_hz_interval(12) 2.0 >>> midi_to_hz_interval(-12) 0.5