Compare commits

..

26 Commits

Author SHA1 Message Date
kennethreitz 1ed90c72d6 Fix scale_diagram enharmonic matching — v0.43.1
Scale notes spelled with flats (e.g. the Eb blue note in the blues
scale) were silently dropped from scale_diagram() because the fretboard
spells that pitch as D#, so the string comparison never matched. Match
notes enharmonically via the system's canonical name and display them
using the scale's own spelling. Pre-existing bug (also in 0.42.x),
surfaced while flipping the docs for the low-to-high release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 11:44:46 -04:00
kennethreitz 41e8404624 docs: flip remaining guides to low-to-high fingerings (v0.43.0 follow-up)
The v0.43.0 commit updated fretboard.rst and chords.rst but missed the
fingering/tab examples in quickstart, cookbook, and nashville-blues-tabs.
Update those Fingering reprs and fb.tab()/scale_diagram blocks to the new
low-to-high default, and fix the "Reading Tab Notation" prose (chord tab
now lists strings low-to-high; high_to_low=True restores the old layout).

Part.to_tab() examples are unchanged (orientation-agnostic, high-on-top).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 11:40:46 -04:00
kennethreitz 6c83dbe5aa Low-to-high fingerings by default (high_to_low opt-out) — v0.43.0
Fretboard string lists and Fingering positions/string-names now read
low-to-high (lowest-pitched string first), matching how chord diagrams
and tablature are conventionally written. Pass high_to_low=True to any
fretboard constructor to restore the pre-0.43 high-to-low behavior.

Design: each board keeps a private canonical (high-to-low) tone store
so the fingering scorer and GUITAR_OVERRIDES table stay untouched; a
single _orient() helper re-orients at the user-facing boundary (and,
being self-inverse, also canonicalizes custom tuning/position input).
Fingering carries its own orientation flag and presents oriented
positions/names via properties. The fingering cache key now includes
orientation so the two orderings don't collide.

to_tab() and Part.strum() now sort by pitch internally, so their output
is identical regardless of board orientation.

- All 25 instrument presets gain a high_to_low param, routed through a
  canonical build path.
- Tests updated for the new default; added orientation-specific tests.
- Docs/examples flipped to low-to-high; chord_charts.py example now uses
  the built-in Fingering.tab() instead of a hand-rolled renderer.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 10:42:11 -04:00
kennethreitz b3f3e985b4 Document missing API features across guides
- chords: open_voicing() alongside other voicings, normal_form() in
  pitch class sets section
- tones: is_natural, is_sharp, is_flat accidental properties
- scales: Key.seventh() for individual degrees, expanded
  Scale.recommend() explanation of how ranking works

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 17:33:47 -04:00
kennethreitz c1925af69d Add Nashville numbers, blues scales, and tablature guide
New documentation section covering the Nashville number system,
blues scale theory, and tablature export — topics that were
previously scattered across cookbook and fretboard docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 16:11:29 -04:00
kennethreitz 7883c978f7 Support Fretboard objects in to_tab() — v0.42.1
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) <noreply@anthropic.com>
2026-04-07 10:03:52 -04:00
kennethreitz 36d558573c Remove worktree submodules, add to gitignore
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 10:02:17 -04:00
kennethreitz 1e2f09e2ab LilyPond, MusicXML, and tablature export — v0.42.0
Three new export methods on Score:
- to_lilypond() — complete LilyPond source files for PDF engraving
- to_musicxml() — MusicXML 4.0 for MuseScore/Sibelius/Finale
- to_tab() — ASCII guitar/bass tablature (also on Part)

All three handle multi-part scores, bass clef detection, tied notes
across barlines, chords, and drum tone filtering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 10:02:09 -04:00
kennethreitz 9404afc1f3 Document ABC notation export in playback guide
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:59:46 -04:00
kennethreitz 72aa097552 Tie long notes across barlines in to_abc() — v0.41.4
Notes longer than one measure are split into tied pieces so abcjs
can render them correctly (e.g. 16-beat choir drone becomes four
tied whole notes).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:57:23 -04:00
kennethreitz 5ebf0bdd97 Skip unpitched parts in to_abc(), fix 'pitch is undefined' — v0.41.3
Parts with only drum tones or rests are excluded from ABC output.
Chords correctly recognized as pitched content.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:47:44 -04:00
kennethreitz 1d897c6609 Auto bass clef detection in to_abc() — v0.41.2
Parts with average note octave below C4 get clef=bass automatically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:43:51 -04:00
kennethreitz 4113aad5d0 Fix to_abc() crash on parts with drum tones — v0.41.1
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:40:07 -04:00
kennethreitz 6ecef688e1 ABC notation export via Score.to_abc() — v0.41.0
New method converts scores to ABC notation with support for multi-voice,
chords, rests, accidentals, and all durations. Pass html=True for a
self-contained HTML page with abcjs sheet music rendering.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:37:56 -04:00
kennethreitz fcc5db8e3d Add Score.to_abc() for ABC notation export with optional HTML rendering
Supports multi-voice scores, chords, rests, accidentals, and all durations.
Pass html=True to get a self-contained page using abcjs for sheet music.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 07:31:02 -04:00
kennethreitz 9de113b6e7 Add sound examples for hard sync, ring mod, wavefold, drift, karplus-strong, mellotron docs
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 14:04:37 -04:00
kennethreitz 0b98f7bd77 Mellotron, hard sync, ring mod, wavefold, drift synths + analog presets — v0.40.9
Five new synth waveforms: tape-replay Mellotron (strings/flute/choir
tapes with wow, flutter, saturation, 8s fadeout), hard sync oscillator,
ring modulation, wavefolding, and analog drift VCO with pitch
instability. 14 new instrument presets for Score.part(). Synth kwargs
now pass through play()/save()/_render(). 808 bass envelope fixed
from pluck to piano.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 23:14:18 -04:00
kennethreitz e0a1ce9d18 Fix hold() inflating Part.total_beats and Score.duration_ms — v0.40.8
Note.beats now returns 0.0 for held notes (_hold=True), matching the
renderer which already skipped advancing the beat position. Previously
every hold() call added its full duration to the part's total, causing
duration reports to be 2-3x too long on tracks with drone notes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 13:27:08 -04:00
kennethreitz de7575fe0a Expose rhodes, wurlitzer, vibraphone, pipe organ, choir in Synth enum — v0.40.7
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 01:59:11 -04:00
kennethreitz 665a6f5de5 Remove lowpass/vel_to_filter from sax presets, let wave shape its own tone — v0.40.6
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 00:44:01 -04:00
kennethreitz 63362df697 Saxophone synth overhaul: reed clipping, formants, breath noise — v0.40.5
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 00:38:10 -04:00
kennethreitz 755b33a63b Fix test: update Synth enum count 42 → 46
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 07:12:43 -04:00
kennethreitz 40901d603d Multi-stage distortion: preamp, power amp, asymmetric clipping — v0.40.4
Single tanh was too mild. Now chains preamp gain → power amp clip →
asymmetric rectifier sag for proper overdrive/fuzz character.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 07:08:10 -04:00
kennethreitz 9b3cbd9065 Add crotales, tingsha, rain stick, ocean drum, cabasa, wind chimes, finger cymbal — v0.40.3
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 14:50:03 -04:00
kennethreitz 0911947971 v0.40.2 — dial back master compressor
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 04:43:53 -04:00
kennethreitz c2f748d5f3 Dial back master compressor: raise threshold, cap makeup gain
Threshold 0.5 → 0.7 so more dynamics survive. Makeup gain capped
at 3x so sparse arrangements (solo singing bowl, etc.) don't get
over-amplified to clipping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 04:42:52 -04:00
118 changed files with 3597 additions and 411 deletions
+1
View File
@@ -7,3 +7,4 @@ t2.py
__pycache__
pytheory.egg-info
docs/_build
.claude/worktrees/
+159
View File
@@ -2,6 +2,165 @@
All notable changes to PyTheory are documented here.
## 0.43.1
- **Fix `Fretboard.scale_diagram()` enharmonic matching.** Scale notes
spelled with flats (e.g. the `Eb` blue note in the blues scale) were
silently omitted from the diagram, because the fretboard spells that
pitch as `D#`. Notes are now matched enharmonically (by pitch) and
displayed using the scale's own spelling.
## 0.43.0
- **BREAKING — fingerings now read low-to-high by default.** `Fretboard`
string lists and `Fingering` positions/string-names now run from the
**lowest-pitched string first** (e.g. standard guitar reads `E A D G B E`),
matching how chord diagrams and tablature are conventionally written.
Previously they ran high-to-low (`E B G D A E`). This affects
`Fretboard.tones`, iteration over a fretboard, `repr`, `chord()`, `tab()`,
`chart()`, and `fingering()` output.
To restore the pre-0.43 high-to-low behavior, pass **`high_to_low=True`**
to any fretboard constructor — `Fretboard.guitar(high_to_low=True)`,
`Fretboard(tones=..., high_to_low=True)`, and likewise on every instrument
preset (`bass`, `ukulele`, `mandolin`, … `keyboard`).
The flip also applies to **input**: a custom tuning tuple passed to
`Fretboard.guitar(...)` and manual fret positions passed to
`fingering(*positions)` are now read in the board's orientation
(low-to-high by default).
`to_tab()` and `Part.strum()` are unaffected — they sort by pitch
internally and produce identical output regardless of orientation.
## 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
files with multi-staff scores, key/time signatures, tempo markings, and
automatic bass clef detection. Output can be compiled to publication-quality
PDFs with LilyPond.
- **MusicXML export** — `Score.to_musicxml()` generates MusicXML 4.0 documents
that can be opened in MuseScore, Sibelius, Finale, and any notation software.
Includes proper ties, chords, clef detection, and tempo/time signature metadata.
- **Guitar/bass tablature** — `Part.to_tab()` and `Score.to_tab()` generate ASCII
tablature. Supports guitar (6-string), bass (4-string), drop D, and custom
tunings. Automatically maps notes to the best string/fret positions.
## 0.41.4
- **Fix** — `to_abc()` now ties long notes across barlines instead of emitting
oversized durations that abcjs can't render (e.g. 16-beat notes become four
tied whole notes).
## 0.41.3
- **Fix** — `to_abc()` now skips parts with only drum tones or rests (no pitched
notes), fixing "pitch is undefined" errors in abcjs. Chords are correctly
recognized as pitched content.
## 0.41.2
- **Auto bass clef** — `to_abc()` detects low-register parts (808, bass, timpani)
and assigns `clef=bass` automatically based on average note octave.
## 0.41.1
- **Fix** — `to_abc()` no longer crashes on parts containing drum tones.
## 0.41.0
- **ABC notation export** — `Score.to_abc()` converts scores to ABC notation
strings. Supports multi-voice scores (via `V:` directives), chords, rests,
accidentals, and all standard durations. Pass `html=True` to get a
self-contained HTML page that renders sheet music in the browser via abcjs.
## 0.40.9
- **Mellotron synth** — tape-replay keyboard with wow/flutter, tape saturation,
bandwidth limiting, hiss, and 8-second tape fadeout. Three tape banks via the
`tape` parameter: `"strings"` (default), `"flute"`, and `"choir"`.
- **Analog oscillator synths** — four new waveform generators for fat, alive,
analog-style sounds:
- `Synth.HARD_SYNC` — slave oscillator hard-synced to a master (Prophet-5
leads). `slave_ratio` parameter controls harmonic content.
- `Synth.RING_MOD` — two oscillators multiplied for metallic, bell-like
inharmonic tones. `mod_ratio` parameter.
- `Synth.WAVEFOLD` — west coast wavefolding (Buchla-style). `folds` parameter
sweeps from warm to gnarly.
- `Synth.DRIFT` — analog VCO with pitch drift, jitter, and noise floor.
`shape` parameter (`"saw"`, `"square"`, `"triangle"`, `"pulse"`) and
`drift_amount` for instability level.
- **Synth kwargs passthrough** — `play()`, `save()`, and `_render()` now accept
`**synth_kw` for forwarding parameters to synth wave functions (e.g.
`play(tone, synth=Synth.MELLOTRON, tape="choir")`).
- **14 new instrument presets** — `mellotron`, `mellotron_strings`,
`mellotron_flute`, `mellotron_choir`, `sync_lead`, `sync_lead_bright`,
`ring_mod_bell`, `ring_mod_metallic`, `wavefold_warm`, `wavefold_gnarly`,
`drift_saw`, `drift_square`, `analog_pad`, `analog_bass`.
- **808 bass envelope fix** — changed from `pluck` (zero sustain, wrong for 808)
to `piano` (sharp attack with long decay tail).
## 0.40.8
- **Fix hold() inflating duration** — `Note.beats` was returning the full
duration for held notes (`_hold=True`), causing `Part.total_beats` and
`Score.duration_ms` to overcount. A part with `hold(Sa, WHOLE * 4)` followed
by `add(Pa, QUARTER)` would report 17 beats instead of 1. Now held notes
return 0 beats, matching the renderer which already skipped advancing the
timeline for held notes.
## 0.40.7
- **Expose missing Synth enum entries** — rhodes, wurlitzer, vibraphone,
pipe organ, and choir wave functions were already implemented but not
accessible via the Synth enum. Now available as `Synth.RHODES`,
`Synth.WURLITZER`, `Synth.VIBRAPHONE`, `Synth.PIPE_ORGAN`, `Synth.CHOIR`.
## 0.40.6
- **Saxophone presets cleaned up** — removed lowpass filters and vel_to_filter
from all sax instrument presets (saxophone, alto_sax, tenor_sax, bari_sax).
The saxophone wave function already shapes its own spectrum; the extra
filters were dulling the tone.
## 0.40.5
- **Saxophone synth overhaul** — reed nonlinearity (asymmetric soft clipping),
conical bore formant resonances, breath noise with attack envelope, separate
reed buzz, key click transient, and sub-harmonic warmth. Vibrato dialed back
to subtle, delayed onset.
## 0.40.4
- **Distortion overhaul** — multi-stage clipping (preamp → power amp →
asymmetric rectifier) replaces single-stage tanh. Crunch, distorted,
orange crunch, and metal guitar presets now sound properly driven.
## 0.40.3
- **Crotales synth** — tuned bronze discs with long ring and bright harmonics
- **Tingsha synth** — paired Tibetan cymbals with beating from two detuned discs
- **Rain stick** — cascading pebbles (steep and slow/shallow variants)
- **Ocean drum** — steel beads rolling inside a frame drum, surf wash
- **Cabasa** — metal bead chain on cylinder, bright metallic scrape
- **Wind chimes** — multiple suspended metal tubes ringing at random offsets
- **Finger cymbal** — single zill tap, bright metallic ping
- `crotales`, `tingsha`, `singing_bowl`, `singing_bowl_ring` instrument presets
- Audio demos in docs for all new sounds
## 0.40.2
- **Master compressor dialed back** — threshold raised from 0.5 to 0.7,
makeup gain capped at 3x. Sparse arrangements no longer get
over-amplified to clipping.
## 0.40.1
- **Singing bowl synth** — two variants: strike (mallet hit with chirp
+207
View File
@@ -0,0 +1,207 @@
"""Demo the 5 new synths: Mellotron, Hard Sync, Ring Mod, Wavefold, Drift.
Each synth gets a short musical phrase — not just a scale run — with
reverb and rhythmic variety to show off its character.
"""
from pytheory import Score, Duration, play_score
EIGHTH = Duration.EIGHTH
QUARTER = Duration.QUARTER
HALF = Duration.HALF
DOTTED_Q = Duration.DOTTED_QUARTER
WHOLE = Duration.WHOLE
# ── Mellotron Strings ────────────────────────────────────────────────────────
# Strawberry Fields vibes — slow, haunted, with rests that breathe.
print("=== MELLOTRON STRINGS ===")
s = Score("4/4", bpm=72)
p = s.part("tape", instrument="mellotron_strings",
reverb=0.45, reverb_type="cathedral", reverb_decay=2.0)
p.add("G4", HALF).add("B4", QUARTER).add("D5", QUARTER)
p.add("C5", DOTTED_Q).add("B4", EIGHTH).add("A4", HALF)
p.rest(QUARTER)
p.add("G4", DOTTED_Q).add("F#4", EIGHTH).add("G4", WHOLE)
play_score(s)
# ── Mellotron Flute ──────────────────────────────────────────────────────────
# Lonely, breathy, with space between phrases.
print("\n=== MELLOTRON FLUTE ===")
s = Score("3/4", bpm=84)
p = s.part("flute", instrument="mellotron_flute",
reverb=0.5, reverb_type="taj_mahal", reverb_decay=2.5)
p.add("E5", HALF).add("D5", QUARTER)
p.add("C5", DOTTED_Q).add("B4", EIGHTH).rest(QUARTER)
p.add("A4", HALF).add("G4", QUARTER)
p.add("A4", HALF).rest(QUARTER)
p.add("E5", QUARTER).add("D5", QUARTER).add("C5", QUARTER)
p.add("B4", HALF + QUARTER)
play_score(s)
# ── Mellotron Choir ──────────────────────────────────────────────────────────
# Ghostly pad — slow chords, big reverb.
print("\n=== MELLOTRON CHOIR ===")
s = Score("4/4", bpm=60)
p = s.part("choir", instrument="mellotron_choir",
reverb=0.6, reverb_type="cathedral", reverb_decay=3.0)
p.add("C4", WHOLE)
p.add("E4", HALF).add("G4", HALF)
p.add("A4", DOTTED_Q).add("G4", EIGHTH).add("F4", HALF)
p.add("E4", WHOLE)
play_score(s)
# ── Hard Sync Lead ───────────────────────────────────────────────────────────
# Aggressive, punchy — fast 16ths and syncopation.
print("\n=== HARD SYNC LEAD ===")
s = Score("4/4", bpm=128)
p = s.part("sync", instrument="sync_lead",
reverb=0.25, reverb_type="plate")
p.add("E4", EIGHTH).add("E4", EIGHTH).rest(EIGHTH).add("G4", EIGHTH)
p.add("A4", QUARTER).add("G4", EIGHTH).add("E4", EIGHTH)
p.add("D4", EIGHTH).rest(EIGHTH).add("E4", EIGHTH).add("G4", EIGHTH)
p.add("A4", HALF)
p.rest(QUARTER).add("B4", EIGHTH).add("A4", EIGHTH)
p.add("G4", QUARTER).add("E4", QUARTER).add("D4", HALF)
play_score(s)
# ── Hard Sync Bright ─────────────────────────────────────────────────────────
# Higher slave ratio — more harmonics, screaming lead.
print("\n=== HARD SYNC BRIGHT ===")
s = Score("4/4", bpm=138)
p = s.part("sync2", instrument="sync_lead_bright",
reverb=0.2, reverb_type="plate")
p.add("A4", EIGHTH).add("C5", EIGHTH).add("D5", QUARTER)
p.rest(EIGHTH).add("E5", EIGHTH).add("D5", EIGHTH).add("C5", EIGHTH)
p.add("A4", QUARTER).rest(QUARTER).add("G4", EIGHTH).add("A4", EIGHTH)
p.add("C5", HALF)
play_score(s)
# ── Ring Mod Bell ────────────────────────────────────────────────────────────
# Shimmery, metallic — sparse hits with long reverb tail.
print("\n=== RING MOD BELL ===")
s = Score("4/4", bpm=66)
p = s.part("bell", instrument="ring_mod_bell",
reverb=0.6, reverb_type="cave", reverb_decay=3.0)
p.add("C5", HALF).rest(QUARTER).add("G4", QUARTER)
p.rest(HALF).add("E5", HALF)
p.add("D5", QUARTER).rest(QUARTER).add("C5", HALF)
p.rest(WHOLE)
p.add("G4", QUARTER).add("A4", QUARTER).add("C5", HALF)
play_score(s)
# ── Ring Mod Metallic ────────────────────────────────────────────────────────
# Alien, inharmonic — atonal stabs.
print("\n=== RING MOD METALLIC ===")
s = Score("4/4", bpm=100)
p = s.part("metal", instrument="ring_mod_metallic",
reverb=0.4, reverb_type="parking_garage", reverb_decay=2.0)
p.add("F4", EIGHTH).rest(EIGHTH).add("Ab4", EIGHTH).add("F4", EIGHTH)
p.rest(QUARTER).add("Db5", QUARTER).rest(QUARTER)
p.add("C5", EIGHTH).add("Ab4", EIGHTH).rest(QUARTER).add("F4", HALF)
p.rest(HALF).add("Db5", QUARTER).add("C5", QUARTER)
play_score(s)
# ── Wavefold Warm ────────────────────────────────────────────────────────────
# Gentle folds — round and musical, like a filtered saw with overtones.
print("\n=== WAVEFOLD WARM ===")
s = Score("4/4", bpm=108)
p = s.part("fold", instrument="wavefold_warm",
reverb=0.3, reverb_type="plate")
p.add("A3", QUARTER).add("C4", QUARTER).add("E4", QUARTER).add("A4", QUARTER)
p.add("G4", DOTTED_Q).add("E4", EIGHTH).add("C4", HALF)
p.add("D4", QUARTER).add("F4", QUARTER).add("A4", HALF)
p.add("G4", WHOLE)
play_score(s)
# ── Wavefold Gnarly ──────────────────────────────────────────────────────────
# Cranked folds — buzzy, aggressive, with syncopation.
print("\n=== WAVEFOLD GNARLY ===")
s = Score("4/4", bpm=130)
p = s.part("gnarly", instrument="wavefold_gnarly",
reverb=0.2, reverb_type="spring")
p.add("E3", EIGHTH).add("E3", EIGHTH).rest(EIGHTH).add("G3", EIGHTH)
p.add("A3", EIGHTH).rest(EIGHTH).add("B3", EIGHTH).add("A3", EIGHTH)
p.add("E3", QUARTER).add("G3", EIGHTH).add("A3", EIGHTH).add("B3", QUARTER)
p.rest(QUARTER)
p.add("E4", EIGHTH).add("D4", EIGHTH).add("B3", QUARTER).add("A3", HALF)
play_score(s)
# ── Drift Saw ────────────────────────────────────────────────────────────────
# Warm, alive analog saw — the Minimoog pad.
print("\n=== DRIFT SAW (vintage VCO) ===")
s = Score("4/4", bpm=88)
p = s.part("drift", instrument="drift_saw",
reverb=0.35, reverb_type="taj_mahal", reverb_decay=2.0)
p.add("D4", HALF).add("F4", HALF)
p.add("A4", DOTTED_Q).add("G4", EIGHTH).add("F4", QUARTER).rest(QUARTER)
p.add("D4", QUARTER).add("E4", QUARTER).add("F4", HALF)
p.add("D4", WHOLE)
play_score(s)
# ── Drift Square ─────────────────────────────────────────────────────────────
# Hollow, wobbly — 8-bit with analog soul.
print("\n=== DRIFT SQUARE ===")
s = Score("4/4", bpm=110)
p = s.part("dsq", instrument="drift_square",
reverb=0.25, reverb_type="plate")
p.add("C4", EIGHTH).add("E4", EIGHTH).add("G4", QUARTER).add("E4", QUARTER)
p.rest(QUARTER)
p.add("A4", EIGHTH).add("G4", EIGHTH).add("E4", QUARTER).add("C4", HALF)
p.add("D4", QUARTER).add("F4", EIGHTH).add("G4", EIGHTH).add("A4", HALF)
p.add("G4", WHOLE)
play_score(s)
# ── Analog Pad ───────────────────────────────────────────────────────────────
# Slow, drifting chords — Juno-style lushness.
print("\n=== ANALOG PAD ===")
s = Score("4/4", bpm=70)
p = s.part("pad", instrument="analog_pad",
reverb=0.5, reverb_type="taj_mahal", reverb_decay=3.0)
p.add("A3", WHOLE)
p.add("C4", HALF).add("E4", HALF)
p.add("F4", WHOLE)
p.add("E4", HALF).add("D4", HALF)
p.add("C4", WHOLE)
play_score(s)
# ── Analog Bass ──────────────────────────────────────────────────────────────
# Tight, punchy — Moog bass with filter sweep.
print("\n=== ANALOG BASS ===")
s = Score("4/4", bpm=120)
p = s.part("bass", instrument="analog_bass",
reverb=0.1, reverb_type="plate")
p.add("E2", EIGHTH).add("E2", EIGHTH).rest(EIGHTH).add("G2", EIGHTH)
p.add("A2", QUARTER).rest(QUARTER)
p.add("E2", EIGHTH).rest(EIGHTH).add("B2", EIGHTH).add("A2", EIGHTH)
p.add("G2", QUARTER).add("E2", QUARTER).rest(HALF)
p.add("E2", EIGHTH).add("E2", EIGHTH).add("G2", EIGHTH).add("A2", EIGHTH)
p.add("B2", QUARTER).add("A2", QUARTER).add("E2", HALF)
play_score(s)
print("\nDone!")
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+126
View File
@@ -850,6 +850,56 @@ def gen_synth_ukulele():
p.strum(ch, Duration.WHOLE, velocity=72)
render("synth_ukulele", score)
def gen_synth_hard_sync():
score = Score("4/4", bpm=120)
p = score.part("demo", instrument="sync_lead_bright", volume=0.5)
for n in ["C4", "E4", "G4", "C5", "G4", "E4", "C4", "E4"]:
p.add(n, Duration.QUARTER, velocity=90)
render("synth_hard_sync", score)
def gen_synth_ring_mod():
score = Score("4/4", bpm=90)
p = score.part("demo", instrument="ring_mod_bell", volume=0.5)
for n in ["C5", "E5", "G5", "C6", "G5", "E5", "C5", "E5"]:
p.add(n, Duration.QUARTER, velocity=80)
render("synth_ring_mod", score)
def gen_synth_wavefold():
score = Score("4/4", bpm=110)
p = score.part("demo", instrument="wavefold_warm", volume=0.5)
for n in ["C4", "E4", "G4", "C5", "G4", "E4", "C4", "E4"]:
p.add(n, Duration.QUARTER, velocity=85)
render("synth_wavefold", score)
def gen_synth_drift():
score = Score("4/4", bpm=90)
p = score.part("demo", instrument="drift_saw", volume=0.5, reverb=0.35,
reverb_type="taj_mahal")
for n in ["C4", "E4", "G4", "C5", "G4", "E4", "C4", "E4"]:
p.add(n, Duration.HALF, velocity=75)
render("synth_drift", score)
def gen_synth_karplus():
score = Score("4/4", bpm=100)
p = score.part("demo", synth="pluck_synth", envelope="none",
volume=0.5, reverb=0.2)
for n in ["C4", "E4", "G4", "C5", "G4", "E4", "C4", "E4"]:
p.add(n, Duration.QUARTER, velocity=85)
render("synth_karplus", score)
def gen_synth_mellotron():
score = Score("4/4", bpm=80)
p = score.part("demo", instrument="mellotron_flute", volume=0.5)
for n in ["C4", "E4", "G4", "C5"]:
p.add(n, Duration.WHOLE, velocity=75)
render("synth_mellotron", score)
def gen_synth_granular():
score = Score("4/4", bpm=80)
p = score.part("demo", instrument="granular_pad", volume=0.5, reverb=0.4)
@@ -858,6 +908,68 @@ def gen_synth_granular():
render("synth_granular", score)
def gen_synth_crotales():
score = Score("4/4", bpm=60)
p = score.part("demo", synth="crotales_synth", envelope="none",
volume=0.5, reverb=0.3)
for n in ["C6", "E6", "G6", "C7", "G6", "E6", "C6"]:
p.add(n, Duration.HALF, velocity=80)
render("synth_crotales", score)
def gen_synth_tingsha():
score = Score("4/4", bpm=40)
p = score.part("demo", synth="tingsha_synth", envelope="none",
volume=0.5, reverb=0.4)
for n in ["E5", "A5", "E6", "A5"]:
p.add(n, Duration.WHOLE, velocity=75)
render("synth_tingsha", score)
def gen_rainstick():
score = Score("4/4", bpm=60)
p = score.part("demo", synth="sine", volume=1.0)
p.hit(DrumSound.RAINSTICK, Duration.WHOLE * 3, velocity=90)
render("rainstick", score)
def gen_rainstick_slow():
score = Score("4/4", bpm=60)
p = score.part("demo", synth="sine", volume=1.0)
p.hit(DrumSound.RAINSTICK_SLOW, Duration.WHOLE * 4, velocity=85)
render("rainstick_slow", score)
def gen_ocean_drum():
score = Score("4/4", bpm=60)
p = score.part("demo", synth="sine", volume=1.0)
p.hit(DrumSound.OCEAN_DRUM, Duration.WHOLE * 3, velocity=85)
render("ocean_drum", score)
def gen_cabasa():
score = Score("4/4", bpm=100)
p = score.part("demo", synth="sine", volume=1.0)
for _ in range(16):
p.hit(DrumSound.CABASA, Duration.EIGHTH, velocity=100)
render("cabasa", score)
def gen_wind_chimes():
score = Score("4/4", bpm=60)
p = score.part("demo", synth="sine", volume=1.0)
p.hit(DrumSound.WIND_CHIMES, Duration.WHOLE * 3, velocity=85)
render("wind_chimes", score)
def gen_finger_cymbal():
score = Score("4/4", bpm=80)
p = score.part("demo", synth="sine", volume=1.0)
for _ in range(8):
p.hit(DrumSound.FINGER_CYMBAL, Duration.QUARTER, velocity=85)
render("finger_cymbal", score)
def gen_synth_singing_bowl_strike():
score = Score("4/4", bpm=40)
p = score.part("demo", synth="singing_bowl_strike_synth", envelope="none",
@@ -1077,9 +1189,23 @@ GENERATORS = [
gen_synth_banjo,
gen_synth_mandolin,
gen_synth_ukulele,
gen_synth_hard_sync,
gen_synth_ring_mod,
gen_synth_wavefold,
gen_synth_drift,
gen_synth_karplus,
gen_synth_mellotron,
gen_synth_granular,
gen_synth_crotales,
gen_synth_tingsha,
gen_synth_singing_bowl_strike,
gen_synth_singing_bowl_ring,
gen_rainstick,
gen_rainstick_slow,
gen_ocean_drum,
gen_cabasa,
gen_wind_chimes,
gen_finger_cymbal,
gen_arpeggio,
gen_legato_glide,
gen_acid_house,
+27 -3
View File
@@ -94,11 +94,11 @@ PyTheory includes 144 pre-built chords (12 roots x 12 qualities):
>>> fb = Fretboard.guitar()
>>> fb.chord("C")
Fingering(e=0, B=1, G=0, D=2, A=3, E=x)
Fingering(E=x, A=3, D=2, G=0, B=1, e=0)
>>> fb.chord("Am")
Fingering(e=0, B=1, G=2, D=2, A=0, E=x)
Fingering(E=x, A=0, D=2, G=2, B=1, e=0)
>>> fb.chord("G7")
Fingering(e=1, B=0, G=0, D=0, A=2, E=3)
Fingering(E=3, A=2, D=0, G=0, B=0, e=1)
You can also build chords directly with ``Chord.from_name()``:
@@ -503,9 +503,16 @@ are standard arranging techniques for spreading chord tones across registers:
>>> cmaj7 = Chord.from_symbol("Cmaj7")
>>> cmaj7.close_voicing()
<Chord C major 7th>
>>> cmaj7.open_voicing()
<Chord C major 7th>
>>> cmaj7.drop2()
<Chord C major 7th>
``open_voicing()`` takes the close voicing and raises every other
non-root tone by an octave, spreading the chord across two octaves.
The result is a wider, more spacious sound — common in orchestral
writing and piano ballads where you want the harmony to breathe.
Chord Extensions
----------------
@@ -596,6 +603,23 @@ music that doesn't follow traditional harmony, this is the tool.
Major and minor triads share the same prime form — they're inversions
of each other in pitch class space.
The **normal form** is the intermediate step — the most compact ascending
arrangement of pitch classes before transposition. It preserves the
actual pitch classes (not transposed to 0), so it tells you which
specific notes are in the set:
.. code-block:: pycon
>>> Chord.from_tones("C", "E", "G").normal_form
(0, 4, 7)
>>> Chord.from_tones("A", "C", "E").normal_form
(9, 0, 4)
Normal form keeps the original pitch classes; prime form transposes to 0
for comparison. Use ``normal_form`` when you care about which notes,
``prime_form`` when you care about the abstract shape.
.. code-block:: pycon
>>> Chord.from_tones("C", "E", "G").forte_number
+6 -6
View File
@@ -111,19 +111,19 @@ Generate fingerings for guitar and ukulele with
>>> fb = Fretboard.guitar()
>>> fb.chord("C")
Fingering(e=0, B=1, G=0, D=2, A=3, E=x)
Fingering(E=x, A=3, D=2, G=0, B=1, e=0)
>>> fb.chord("G")
Fingering(e=3, B=0, G=0, D=0, A=2, E=3)
Fingering(E=3, A=2, D=0, G=0, B=0, e=3)
>>> fb.chord("Am")
Fingering(e=0, B=1, G=2, D=2, A=0, E=x)
Fingering(E=x, A=0, D=2, G=2, B=1, e=0)
>>> fb.chord("D")
Fingering(e=2, B=3, G=2, D=0, A=x, E=x)
Fingering(E=x, A=x, D=0, G=2, B=3, e=2)
>>> uke = Fretboard.ukulele()
>>> uke.chord("C")
Fingering(A=3, E=0, C=0, G=0)
Fingering(G=0, C=0, E=0, A=3)
>>> uke.chord("G")
Fingering(A=2, E=3, C=2, G=0)
Fingering(G=0, C=2, E=3, A=2)
Explore an Interval
-------------------

Some files were not shown because too many files have changed in this diff Show More