File: 03-exponential-ramp.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 (36 lines) | stat: -rw-r--r-- 1,297 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
32
33
34
35
36
03-exponential-ramp.py - Exponential portamento with rising and falling times.
============================================================================================================================================


The Port object is designed to lowpass filter an audio signal with
different coefficients for rising and falling signals. A lowpass
filter is a good and efficient way of creating an exponential ramp
from a signal containing abrupt changes. The rising and falling
coefficients are controlled in seconds.

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    
    # 2 seconds linear ramp starting at 0.0 and ending at 0.3.
    amp = SigTo(value=0.3, time=2.0, init=0.0)
    
    # Pick a new value four times per second.
    pick = Choice([200, 250, 300, 350, 400], freq=4)
    
    # Print the chosen frequency
    pp = Print(pick, method=1, message="Frequency")
    
    # Add an exponential portamento on an audio target and detune a second frequency.
    # Sharp attack for rising notes and long release for falling notes.
    freq = Port(pick, risetime=0.001, falltime=0.25, mul=[1, 1.005])
    # Play with portamento times.
    freq.ctrl()
    
    # Play a simple wave.
    sig = RCOsc(freq, sharp=0.7, mul=amp).out()
    
    s.gui(locals())