Systems

class pytheory.systems.System(*, tone_names, degrees, scales=None, c_index=None, period=2.0, ratios=None)[source]

Bases: object

__init__(*, tone_names, degrees, scales=None, c_index=None, period=2.0, ratios=None)[source]
property semitones
property tones
resolve_name(name: str) str | None[source]

Resolve a note name (including flats, double sharps/flats) to the canonical name.

Handles enharmonic equivalents: - Standard names and their alternates (e.g. Bb, C#) - Double sharps (C## = D, F## = G) - Double flats (Dbb = C, Ebb = D)

Returns the primary name if found, or None if not recognized.

property scales
property modes
static generate_scale(*, tones=7, semitones=12, intervals=None, major=False, minor=False, hemitonic=False, harmonic=False, melodic=False, offset=None)[source]

Generates the primary scale for a given number of semitones/tones.

tone(name, octave=4)[source]

Create a Tone in this system. Shorthand for Tone(name, octave=octave, system=self).

Example:

>>> edo19 = TET(19)
>>> edo19.tone(5, octave=4).frequency
__repr__()[source]

Return repr(self).

pytheory.systems.TET(n, *, names=None, reference_index=0, period=2.0)[source]

Create an N-tone equal temperament system.

Each step divides the period into n equal parts. The frequency ratio between adjacent tones is period^(1/n).

For standard tunings the period is 2.0 (octave). For exotic systems like Bohlen-Pierce, set period=3.0 (tritave).

Parameters:
  • n – Number of equal divisions of the octave (e.g. 19, 24, 31, 53).

  • names – Optional list of n tone name strings. If omitted, tones are numbered "0" through "n-1".

  • reference_index – Index of the tone that corresponds to A440 (default 0, meaning tone “0” = A4 = 440 Hz).

Returns:

A System instance.

Example:

>>> edo19 = TET(19)
>>> from pytheory import Tone
>>> t = Tone("0", octave=4, system=edo19)
>>> t.frequency  # 440.0 Hz (tone 0 = A4)
440.0

>>> edo31 = TET(31)
>>> t = Tone("18", octave=4, system=edo31)
>>> t.frequency  # 18 steps above A in 31-TET