music.harmonic_series¶
- music.harmonic_series(partials=20)[source]¶
The first partials harmonics, in semitones above the fundamental.
The n-th partial is at
12 * log2(n), which is what this computes.HARMONIC_SERIES_AS_PRINTEDis the article’s table of the first twenty, rounded to two decimals and with one typo.- Parameters:
- partials
integer How many, from 1 upwards. The article tabulates twenty; nothing here stops at that.
- partials
- Returns:
tupleoffloatsSemitones, with the fractions that make the series inequal to any tempered scale.
- Raises:
ValueErrorIf partials is less than 1.
- Parameters:
partials (int)
- Return type:
See also
midi_to_hz_intervalturns one of these semitone counts into a ratio.
Notes
Every octave is exact – partials 1, 2, 4, 8 and 16 land on 0, 12, 24, 36 and 48 – and nothing else does. The third partial is 2 cents sharp of a tempered fifth and the seventh is 31 cents flat of a tempered minor seventh, which is the size of the disagreement between this series and the tuning of
scale().Examples
>>> [round(h, 2) for h in harmonic_series(4)] [0.0, 12.0, 19.02, 24.0] >>> round(harmonic_series(7)[-1], 2) 33.69