photons.audio module
Play WAV tones.
- class photons.audio.Theme(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumShort theme clips to play as a WAV file.
- MARIO = 'mario'
Mario completes a level.
- TETRIS = 'tetris'
The Tetris theme.
- CONTRA = 'contra'
The Jungle theme from Contra.
- class photons.audio.Song(sample_rate=44100, tempo=100)[source]
Bases:
objectCreate a song.
- Parameters:
- add(duration, left=None, right=None, volume=0.5)[source]
Add a rest, note or chord to the song.
- Parameters:
duration (
float) – The number of seconds the note will play for, or, the number of seconds to rest.left (
str|list[str]) – The name(s) of the note(s) to add to the left channel (e.g., ‘A4’ or [‘C4’, ‘G3’, ‘E3’] for a chord). Do not specify a value to add a rest.right (
str|list[str]) – The name(s) of the note(s) to add to the right channel (e.g., ‘C3’). If not specified then equals the left channel.volume (
float) – The amplitude of the sine wave. Should be between 0 and 1.
- Return type: