File: 01-flanger.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 (45 lines) | stat: -rw-r--r-- 1,696 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
37
38
39
40
41
42
43
44
45
01-flanger.py - Hand-made simple flanger.
============================================================================================================================================


A flanger is an audio effect produced by mixing two identical signals
together, one signal delayed by a small and gradually changing period.
This produces a swept comb filter effect: peaks and notches are produced
in the resulting frequency spectrum, related to each other in a linear
harmonic series. Varying the time delay causes these to sweep up and
down the frequency spectrum.

.. code-block:: python

    from pyo import *
    
    s = Server().boot()
    
    # Rich frequency spectrum as stereo input source.
    amp = Fader(fadein=0.25, mul=0.5).play()
    src = PinkNoise(amp).mix(2)
    
    # Flanger parameters                        == unit ==
    middelay = 0.005  # seconds
    
    depth = Sig(0.99)  # 0 --> 1
    depth.ctrl(title="Modulation Depth")
    lfospeed = Sig(0.2)  # Hertz
    lfospeed.ctrl(title="LFO Frequency in Hz")
    feedback = Sig(0.5, mul=0.95)  # 0 --> 1
    feedback.ctrl(title="Feedback")
    
    # LFO with adjusted output range to control the delay time in seconds.
    lfo = Sine(freq=lfospeed, mul=middelay * depth, add=middelay)
    
    # Dynamically delayed signal. The source passes through a DCBlock
    # to ensure there is no DC offset in the signal (with feedback, DC
    # offset can be fatal!).
    flg = Delay(DCBlock(src), delay=lfo, feedback=feedback)
    
    # Mix the original source with its delayed version.
    # Compress the mix to normalize the output signal.
    cmp = Compress(src + flg, thresh=-20, ratio=4).out()
    
    s.gui(locals())