diff --git a/.gitignore b/.gitignore index 900e769..b59488a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ t2.py __pycache__ pytheory.egg-info docs/_build +docs/_static/audio/*.wav diff --git a/docs/_templates/audio.html b/docs/_templates/audio.html new file mode 100644 index 0000000..66214d7 --- /dev/null +++ b/docs/_templates/audio.html @@ -0,0 +1,4 @@ + diff --git a/docs/generate_audio.py b/docs/generate_audio.py new file mode 100644 index 0000000..73f7086 --- /dev/null +++ b/docs/generate_audio.py @@ -0,0 +1,281 @@ +"""Generate audio samples for documentation. + +Renders code examples from the docs as WAV files so they can be +embedded as play_pattern(Pattern.preset("salsa"), repeats=4, bpm=180) play_pattern(Pattern.preset("afrobeat"), repeats=8, bpm=110) @@ -458,6 +462,10 @@ West African-style break). score = Score("4/4", bpm=120) score.drums("djembe", repeats=8, fill="djembe call", fill_every=4) +.. raw:: html + + + Metal Kit ~~~~~~~~~ @@ -548,6 +556,10 @@ voice with per-player timing tendencies and micro pitch drift. # Or use patterns score.drums("drumline", repeats=4) +.. raw:: html + + + **Sympathetic resonance:** The marching snare builds up snare wire buzz as hits accumulate, and the buzz decays during rests — just like a real drum. diff --git a/docs/guide/sequencing.rst b/docs/guide/sequencing.rst index 3b178be..58c56f7 100644 --- a/docs/guide/sequencing.rst +++ b/docs/guide/sequencing.rst @@ -431,6 +431,10 @@ Pass ``articulation=`` to ``Part.add()``: piano.add("G4", Duration.QUARTER, articulation="accent") # louder piano.add("C5", Duration.HALF, articulation="fermata") # held longer +.. raw:: html + + + What each articulation does: - **staccato** — plays ~40% of the note duration with a quick fade-out. Short and detached. @@ -467,6 +471,10 @@ of notes instead of setting each one manually. piano.dynamics(["C4","E4","G4","C5"], Duration.QUARTER, velocities=[50, 80, 110, 90]) +.. raw:: html + + + Four methods: - **crescendo()** — linear velocity ramp from ``start_vel`` to ``end_vel``. @@ -548,6 +556,12 @@ Each ensemble voice gets a consistent timing personality (some rush, some drag) plus small per-note wobble, and slightly different tuning. The result sounds like a real section — together but alive. +Solo snare, then an 8-player section plays the same pattern: + +.. raw:: html + + + Swing and Groove ---------------- @@ -663,6 +677,10 @@ Four interpolation curves: # Smooth reverb wash fading in and settling pad.ramp(over=Duration.WHOLE * 4, curve="ease_in_out", reverb=0.6) +.. raw:: html + + + ``ramp()`` generates automation points every quarter-beat by default. Set ``resolution=0.125`` for smoother curves (every 32nd note), or ``resolution=1.0`` for lighter automation (every beat).