Repolode
kennethreitz

kennethreitz/pytheory

A Python library for music theory, composition, and audio sketching, letting you analyze chords and scales and render playable MIDI and sound from code.

Stars
1,659
Forks
84
Open issues
2
Last commit
yesterday

What is it?

PyTheory is a Python library for working with music theory and composition from code. It covers keys, chords, scales, intervals, and chord progressions, and can identify chord symbols, suggest scales for a set of notes, and find pivot chords between keys. Its output includes ASCII guitar tablature, fingering charts, and Nashville number notation.

For composition, you build a score with parts, drum patterns, arpeggios, and sections with repeats, then play it back or export it as MIDI for a DAW. The sound engine provides 56 synth waveforms, 100 drum patterns, effects such as reverb, delay, chorus, and sidechain compression, and automation of parameters over time, including LFO modulation.

The project also includes a command-line interface with a REPL, a demo track, a strobe tuner, and a browser-based studio, plus optional extras for live MIDI input and Ableton Link sync.

Key features

  • 01Analyzes chords, keys, scales, and intervals, including chord identification and progressions.
  • 02Renders chord fingerings, guitar tabs, and scale diagrams for guitar and other stringed instruments.
  • 03Builds multi-part arrangements with drum patterns, arpeggios, sections, and repeats.
  • 04Plays back generated music and exports standard MIDI files.
  • 05Offers 56 synth waveforms, effects, and parameter automation including LFO modulation.
  • 06Provides a command-line interface with a REPL, tuner, and browser studio.

Use cases

  • Exploring chord progressions and scales while learning music theory.
  • Sketching song ideas in code and exporting MIDI to a DAW for further production.
  • Generating guitar tabs or chord charts from a script.
  • Prototyping musical ideas from natural language through an AI assistant.

Quick start

  1. 1

    Install PyTheory from PyPI

    pip install pytheory
  2. 2

    Hear a generated demo track

    pytheory demo

Topics

#music-theory#music#midi#audio-synthesis#composition#guitar#sympy#scales#hacktoberfest#python

FAQ

What is pytheory?
A Python library for music theory, composition, and audio sketching, letting you analyze chords and scales and render playable MIDI and sound from code. PyTheory is a Python library for working with music theory and composition from code. It covers keys, chords, scales, intervals, and chord progressions, and can identify chord symbols, suggest scales for a set of notes, and find pivot chords between keys. Its output includes ASCII guitar tablature, fingering charts, and Nashville number notation.
Is pytheory free to use? What license does it have?
pytheory is open source under the MIT license. Check the license terms before using it in commercial products.
Is pytheory still maintained?
Actively maintained. The last commit to pytheory was on Nov 6, 2026.
What can I use pytheory for?
Exploring chord progressions and scales while learning music theory. Sketching song ideas in code and exporting MIDI to a DAW for further production. Generating guitar tabs or chord charts from a script. Prototyping musical ideas from natural language through an AI assistant.
How do I install pytheory?
Install PyTheory from PyPI: pip install pytheory Hear a generated demo track: pytheory demo
Where can I get pytheory?
The source code and installation instructions are on GitHub: https://github.com/kennethreitz/pytheory

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects

A Python-based music programming language that lets you write, analyze and export music using concise, music-theory-aware syntax and MIDI output.

Other#music#music-theory#midi
1.5K+3 this week138PythonLGPL-2.1Updated 2 months ago

A free, open-source singing synthesis editor for UTAU users, supporting UTAU voicebanks, phonemizers, and plugins on Windows, macOS, and Linux.

Productivity & Apps#singing-synthesis#utau#music
4.5K+48 this week593C#MITWell maintainedUpdated 2 days ago