SPIS 2022, Breadth 08/19 (Phill)
Basic concepts
- Sound is vibration
- Electronic sound is caused by driving a speaker with a voltage
- There is some max and min voltage, which for convenience, we’ll represent
as -1 and +1.
- 0 means the speaker is at rest and silent.
- -1 means it’s stretched all the way in one direction
- +1 means it’s stretched all the way in the other
- We need to avoid going past -1 or +1
- So a sine wave is a convenient way to represent that.
Enabling Audio in a repl
To enable audio:
- On the ⋮ menu next to Files, click Show hidden files
- add
audio = true
as first line in the .replit
file
Demo of sound in a repl
https://replit.com/@PhillipConrad/audio-python-2#main.py
Attack, Decay, Sustain, Release
https://linuxaudio.github.io/libremusicproduction/html/answer/adsr-envelope.html
Sine wave to square wave
https://www.allaboutcircuits.com/textbook/alternating-current/chpt-7/square-wave-signals/
Demo of sound with Pure Python
https://github.com/spis2022/audio-plain-python
More resources
Some resources for sound/audio
Python-based (that do not depend on repl.it)
Repl.it (Python-based)
Repl.it (non-Python)
Advanced git/GitHub