Files
pytheory/docs/guide/playback.rst
kennethreitz 4a77f9163e Add Sphinx documentation with alabaster theme
- User guide: quickstart, tones, scales, chords, fretboard, playback
- API reference: autodoc for all modules
- alabaster theme with Napoleon for Google/NumPy docstrings
- Update project description in pyproject.toml
- Add sphinx to docs dependency group

Build with: uv run --group docs sphinx-build -b html docs docs/_build/html

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 05:47:20 -04:00

61 lines
1.4 KiB
ReStructuredText

Audio Playback
==============
PyTheory can synthesize and play tones and chords through your speakers.
.. note::
Audio playback requires `PortAudio <http://www.portaudio.com/>`_ to be
installed on your system. On macOS: ``brew install portaudio``.
On Ubuntu: ``apt install libportaudio2``.
Playing a Tone
--------------
.. code-block:: python
from pytheory import Tone, play
a4 = Tone.from_string("A4", system="western")
play(a4, t=1_000) # Play A440 for 1 second
Playing a Chord
---------------
.. code-block:: python
from pytheory import Chord, Tone, play
c_major = Chord(tones=[
Tone.from_string("C4", system="western"),
Tone.from_string("E4", system="western"),
Tone.from_string("G4", system="western"),
])
play(c_major, t=2_000) # Play for 2 seconds
Waveform Types
--------------
Choose between sine, sawtooth, and triangle wave synthesis:
.. code-block:: python
from pytheory import play, Synth, Tone
tone = Tone.from_string("C4", system="western")
play(tone, synth=Synth.SINE) # Smooth, pure tone
play(tone, synth=Synth.SAW) # Bright, buzzy
play(tone, synth=Synth.TRIANGLE) # Softer than sawtooth
Temperaments
------------
Play in different tuning systems:
.. code-block:: python
play(tone, temperament="equal") # Default, modern tuning
play(tone, temperament="pythagorean") # Ancient Greek tuning
play(tone, temperament="meantone") # Renaissance tuning