From 7883c978f76730cb2dc1516d4896df13ad874903 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Tue, 7 Apr 2026 10:03:52 -0400 Subject: [PATCH] =?UTF-8?q?Support=20Fretboard=20objects=20in=20to=5Ftab()?= =?UTF-8?q?=20=E2=80=94=20v0.42.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to_tab(tuning=Fretboard.guitar()) now works, along with bass, ukulele, mandolin, banjo, and any custom Fretboard with capo. Co-Authored-By: Claude Opus 4.6 (1M context) --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- pytheory/__init__.py | 2 +- pytheory/rhythm.py | 9 +++++++-- uv.lock | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 846ac19..e4fb442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to PyTheory are documented here. +## 0.42.1 + +- **Fretboard tuning support** — `to_tab()` now accepts `Fretboard` objects as + the `tuning` parameter. Works with `Fretboard.guitar()`, `Fretboard.bass()`, + `Fretboard.ukulele()`, `Fretboard.mandolin()`, `Fretboard.banjo()`, and any + custom Fretboard with capo. + ## 0.42.0 - **LilyPond export** — `Score.to_lilypond()` generates complete LilyPond source diff --git a/pyproject.toml b/pyproject.toml index 4c004e3..6527f09 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pytheory" -version = "0.42.0" +version = "0.42.1" description = "Music Theory for Humans" readme = "README.md" license = "MIT" diff --git a/pytheory/__init__.py b/pytheory/__init__.py index 1d85110..1525401 100644 --- a/pytheory/__init__.py +++ b/pytheory/__init__.py @@ -1,6 +1,6 @@ """PyTheory: Music Theory for Humans.""" -__version__ = "0.42.0" +__version__ = "0.42.1" from .tones import Tone, Interval from .systems import System, SYSTEMS, TET diff --git a/pytheory/rhythm.py b/pytheory/rhythm.py index f83373a..51f213a 100644 --- a/pytheory/rhythm.py +++ b/pytheory/rhythm.py @@ -3814,8 +3814,8 @@ class Part: Args: tuning: ``"guitar"`` (6-string standard), ``"bass"`` (4-string), - ``"drop_d"`` (guitar drop D), or a list of MIDI note numbers - for custom tuning (low string first). + ``"drop_d"`` (guitar drop D), a ``Fretboard`` object, or a + list of MIDI note numbers for custom tuning (low string first). frets: Maximum fret number (default 24). time_signature: A ``TimeSignature`` or ``None`` for 4/4. @@ -3825,6 +3825,11 @@ class Part: if isinstance(tuning, str): open_midis = list(self._TAB_TUNINGS[tuning]) labels = list(self._TAB_LABELS[tuning]) + elif hasattr(tuning, "tones"): + # Fretboard object — tones are high-to-low, reverse for low-to-high + fb_tones = list(reversed(tuning.tones)) + open_midis = [t.midi for t in fb_tones] + labels = [t.name if len(t.name) <= 2 else t.name[0] for t in fb_tones] else: open_midis = list(tuning) _note_names = ["C", "C#", "D", "D#", "E", "F", diff --git a/uv.lock b/uv.lock index a9868ce..2fc459e 100644 --- a/uv.lock +++ b/uv.lock @@ -690,7 +690,7 @@ wheels = [ [[package]] name = "pytheory" -version = "0.42.0" +version = "0.42.1" source = { editable = "." } dependencies = [ { name = "rich" },