mirror of
https://github.com/kennethreitz/pytheory.git
synced 2026-06-05 14:50:18 +00:00
9da3ac8b28
- circle_of_fifths.py — visualize keys around the circle - chord_identifier.py — identify chords from notes and fingerings - key_explorer.py — explore keys, signatures, progressions, borrowed chords - temperament_comparison.py — compare equal, Pythagorean, and meantone - chord_tension.py — analyze tension, consonance, and voice leading - world_scales.py — scales from 6 musical traditions - fretboard_explorer.py — instruments, tunings, capo transposition - midi_converter.py — MIDI ↔ note ↔ frequency reference - progression_writer.py — famous progressions, Nashville numbers, random generation - interval_trainer.py — interval names, songs, and consonance ranking - overtone_series.py — harmonics and why chords sound good - key_detection.py — detect keys from melodies and chord progressions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
"""Visualize the circle of fifths with key signatures."""
|
|
|
|
from pytheory import Tone, Key
|
|
|
|
c = Tone.from_string("C4", system="western")
|
|
|
|
print("╔══════════════════════════════════════════════╗")
|
|
print("║ THE CIRCLE OF FIFTHS ║")
|
|
print("╠══════════════════════════════════════════════╣")
|
|
print("║ Key Sig Accidentals ║")
|
|
print("╠══════════════════════════════════════════════╣")
|
|
|
|
for tone in c.circle_of_fifths():
|
|
key = Key(tone.name, "major")
|
|
sig = key.signature
|
|
relative = key.relative
|
|
|
|
if sig["sharps"]:
|
|
mark = f'{sig["sharps"]}#'
|
|
elif sig["flats"]:
|
|
mark = f'{sig["flats"]}b'
|
|
else:
|
|
mark = "--"
|
|
|
|
accidentals = ", ".join(sig["accidentals"]) if sig["accidentals"] else "none"
|
|
print(f"║ {tone.name:3s} {mark:3s} {accidentals:20s} rel: {relative.tonic_name} {relative.mode:5s} ║")
|
|
|
|
print("╚══════════════════════════════════════════════╝")
|
|
|
|
# Show that 12 fifths returns to the start
|
|
print()
|
|
print("Proof: 12 perfect fifths cycle through all 12 tones")
|
|
names = [t.name for t in c.circle_of_fifths()]
|
|
print(f" {' → '.join(names)} → {names[0]}")
|