music.pitch_to_freq

music.pitch_to_freq(start_freq=220.0, semitones=(0, 7, 7, 4, 7, 0))[source]

Generates a list of frequencies based on a list of semitones and a starting frequency.

This function calculates a list of frequencies based on the given list of semitones and a starting frequency. Each semitone value represents the number of semitones above or below the starting frequency.

Parameters:
start_freqfloat, optional

The starting frequency in Hertz, by default 220.

semitoneslist, optional

The list of semitone offsets relative to the starting frequency, by default [0, 7, 7, 4, 7, 0].

Returns:
list

A list of frequencies calculated from the given semitones and starting frequency.

Parameters:
Return type:

list[float]

Examples

>>> pitch_to_freq(semitones=(0, 7, 12))  # a fifth, then an octave
[220.0, 329.6275569128699, 440.0]
>>> len(pitch_to_freq())  # the default is (0, 7, 7, 4, 7, 0)
6
>>> pitch_to_freq(start_freq=440, semitones=[0, 12, 12, 12])
[440.0, 880.0, 880.0, 880.0]