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
Install PyTheory from PyPI
pip install pytheory - 2
Hear a generated demo track
pytheory demo
Topics
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
Self-hostable, web-based guitar and bass tab viewer and player with audio sync, similar to Songsterr.
A Web Audio framework for building interactive music and synthesizers in the browser, with DAW-style transport scheduling.
Free, open-source DJ software for performing live mixes on Linux, Windows and macOS.
A free, open-source singing synthesis editor for UTAU users, supporting UTAU voicebanks, phonemizers, and plugins on Windows, macOS, and Linux.
A command-line music library manager that catalogs your collection and automatically corrects its metadata using MusicBrainz.