music.PrimaryTables¶
- class music.PrimaryTables(size=2048)[source]¶
Bases:
objectProvides primary tables for waveform lookup.
This class creates sine, triangle, square, and saw wave periods with a given number of samples.
- Parameters:
- size
int,optional The number of samples for each waveform table, by default 2048.
- size
- Attributes:
Examples
>>> primary_tables = PrimaryTables() >>> primary_tables.size 2048 >>> primary_tables.draw_tables()
- __init__(size=2048)[source]¶
Initialize the PrimaryTables class.
- Parameters:
- size
int,optional The number of samples for each waveform table, by default 2048.
- size
Methods
__init__([size])Initialize the PrimaryTables class.
Draw the four waveform tables on one pair of axes.
make_tables(size)Create waveform tables.
- make_tables(size)[source]¶
Create waveform tables.
- Parameters:
- size
int The number of samples for each waveform table.
- size
- draw_tables()[source]¶
Draw the four waveform tables on one pair of axes.
- Raises:
ImportErrorIf matplotlib is not installed. Install it with
pip install 'music[plot]'.
Notes
matplotlib is imported here rather than at the top of the module. It is the only thing in the package that needs it, and importing it eagerly cost about 40% of
import music’s total time – 1237 ms against 743 ms – and pulled eight further packages into every installation, for a function that only exists to look at the tables.The examples are marked
+SKIP:show()blocks on a window, so a doctest run would hang rather than fail.Examples
>>> PrimaryTables(size=64).draw_tables()