File: 01-fixed-control.rst.txt

package info (click to toggle)
python-pyo 1.0.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,332 kB
  • sloc: python: 135,133; ansic: 127,822; javascript: 16,116; sh: 395; makefile: 388; cpp: 242
file content (31 lines) | stat: -rw-r--r-- 1,042 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
01-fixed-control.py - Number as argument.
============================================================================================================================================


Audio objects behaviour can be controlled by passing
value to their arguments at initialization time.

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    s.amp = 0.1
    
    # Sets fundamental frequency
    freq = 200
    
    # Approximates a triangle waveform by adding odd harmonics with
    # amplitude proportional to the inverse square of the harmonic number.
    h1 = Sine(freq=freq, mul=1).out()
    h2 = Sine(freq=freq * 3, phase=0.5, mul=1.0 / pow(3, 2)).out()
    h3 = Sine(freq=freq * 5, mul=1.0 / pow(5, 2)).out()
    h4 = Sine(freq=freq * 7, phase=0.5, mul=1.0 / pow(7, 2)).out()
    h5 = Sine(freq=freq * 9, mul=1.0 / pow(9, 2)).out()
    h6 = Sine(freq=freq * 11, phase=0.5, mul=1.0 / pow(11, 2)).out()
    
    # Displays the final waveform
    sp = Scope(h1 + h2 + h3 + h4 + h5 + h6)
    
    s.gui(locals())