| 1 |
01-fixed-control.py - Number as argument. |
| 2 |
============================================================================================================================================ |
| 3 |
|
| 4 |
|
| 5 |
Audio objects behaviour can be controlled by passing |
| 6 |
value to their arguments at initialization time. |
| 7 |
|
| 8 |
.. code-block:: python |
| 9 |
|
| 10 |
from pyo import * |
| 11 |
|
| 12 |
s = Server().boot() |
| 13 |
s.amp = 0.1 |
| 14 |
|
| 15 |
# Sets fundamental frequency |
| 16 |
freq = 200 |
| 17 |
|
| 18 |
# Approximates a triangle waveform by adding odd harmonics with |
| 19 |
# amplitude proportional to the inverse square of the harmonic number. |
| 20 |
h1 = Sine(freq=freq, mul=1).out() |
| 21 |
h2 = Sine(freq=freq * 3, phase=0.5, mul=1.0 / pow(3, 2)).out() |
| 22 |
h3 = Sine(freq=freq * 5, mul=1.0 / pow(5, 2)).out() |
| 23 |
h4 = Sine(freq=freq * 7, phase=0.5, mul=1.0 / pow(7, 2)).out() |
| 24 |
h5 = Sine(freq=freq * 9, mul=1.0 / pow(9, 2)).out() |
| 25 |
h6 = Sine(freq=freq * 11, phase=0.5, mul=1.0 / pow(11, 2)).out() |
| 26 |
|
| 27 |
# Displays the final waveform |
| 28 |
sp = Scope(h1 + h2 + h3 + h4 + h5 + h6) |
| 29 |
|
| 30 |
s.gui(locals()) |
| 31 |
|