Skip to main content

A simple Python library for generating music chords and scales.

Project description

theory_snake 🐍🎶

A lightweight Python library for music theory. Easily generate scales, build chords, and handle note transformations with a simple, intuitive API.


🚀 Installation

Install theory_snake via pip:

pip install theory_snake

🎹 Features & Usage

1. Scales

Generate full scales by providing a root note and the scale type.

Python

from theory_snake.scale_builder import build_scale

# Generate a C Major Scale
c_major = build_scale("C", "major")
print(c_major)
# Output: ['C', 'D', 'E', 'F', 'G', 'A', 'B']

# Generate an A Minor Scale
a_minor = build_scale("A", "minor")
print(a_minor)

2. Chords

Construct triads quickly using the chord builder.

Python

from theory_snake.chord_builder import build_chord

# Build a G Major triad
g_major = build_chord("G", "major")
print(g_major)
# Output: ['G', 'B', 'D']

# Build a D Minor triad
d_minor = build_chord("D", "minor")
print(d_minor)

3. Note Utilities

Handle accidentals and note naming conventions efficiently.

Python

from theory_snake.note_utils import get_sharp, get_flat

print(get_sharp("C")) # "C#"
print(get_flat("B"))  # "Bb"

4. Constants

Access raw music theory data like intervals and formulas. Note: These must be imported explicitly from the consts module.

Python

from theory_snake import consts

# Access raw semitone formulas
print(consts.CHORD_FORMULAS['major']) # [0, 4, 7]

5. Guitar Utils (module)

The guitar_utils module provides helpers for working with guitar-specific abstractions like tunings, strings, fretboards and finding chord shapes on a fretboard.

Quick examples

from theory_snake import guitar_utils
from theory_snake.chord_builder import build_chord

# Get a standard 6-string tuning (or pass a custom tuning like "E A D G B E" or "E,A,D,G,B,E")
tuning = guitar_utils.select_tuning("Standard")

# Build a full fretboard (each open string -> list of fretted notes)
fretboard = guitar_utils.build_fretboard(tuning)

# Build a single guitar string from its open note
e_string = guitar_utils.build_guitar_string("E")

# Build chord notes (uses the chord builder in the main package)
g_major_notes = build_chord("G", "major")

# Find a simple fingering on the fretboard for the chord notes
guitar_chord_shape = guitar_utils.make_guitar_chord(fretboard, g_major_notes)
print(guitar_chord_shape)
# Example output: {'E': 3, 'A': 2, 'D': 0, 'G': 0, 'B': 0}

Notes

  • select_tuning(tuning) accepts a key from the library's common tunings (e.g. "Standard") or a custom comma/space-separated list of open-string notes.
  • build_guitar_string(open_note) returns a list of notes across frets for that string.
  • build_fretboard(tuning) returns a mapping of each open string -> its fretted-note list.
  • make_guitar_chord(fret_board, chord_notes) returns a mapping from string (open-note key used in the fretboard) to the fret index for the first matching chord tone found on that string.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

theory_snake-0.2.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

theory_snake-0.2.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file theory_snake-0.2.1.tar.gz.

File metadata

  • Download URL: theory_snake-0.2.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for theory_snake-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d37a4c7097634402366a2c8d2f31c357c5ec6cbea5f1f820516e2fa9f1ce8d03
MD5 340bfbd19c7c6514060ba5e5810eb3f6
BLAKE2b-256 a6d3f16e9cb422eea9cb6163240ed0ab974ab51499a95865bc5c58f68ce6f92b

See more details on using hashes here.

File details

Details for the file theory_snake-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: theory_snake-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for theory_snake-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d4ff8bea93864608aa2b4c2fe36389deda2881e155469b4c8b87d3dbabfa965
MD5 16ad2e7d17964595b800375f180a5bd9
BLAKE2b-256 39ac880f991a81cbefbb8d4bdbe6943a57516e81f260f3c2c435a09b6fc0ad66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page