Debian Codegraph @

pyo/examples/x07-effects/01-flanger.py

raw symbols SCIP
1 """
2 01-flanger.py - Hand-made simple flanger.
3
4 A flanger is an audio effect produced by mixing two identical signals
5 together, one signal delayed by a small and gradually changing period.
6 This produces a swept comb filter effect: peaks and notches are produced
7 in the resulting frequency spectrum, related to each other in a linear
8 harmonic series. Varying the time delay causes these to sweep up and
9 down the frequency spectrum.
10
11 """
12 from pyo import *
13
14 s = Server().boot()
15
16 # Rich frequency spectrum as stereo input source.
17 amp = Fader(fadein=0.25, mul=0.5).play()
18 src = PinkNoise(amp).mix(2)
19
20 # Flanger parameters == unit ==
21 middelay = 0.005 # seconds
22
23 depth = Sig(0.99) # 0 --> 1
24 depth.ctrl(title="Modulation Depth")
25 lfospeed = Sig(0.2) # Hertz
26 lfospeed.ctrl(title="LFO Frequency in Hz")
27 feedback = Sig(0.5, mul=0.95) # 0 --> 1
28 feedback.ctrl(title="Feedback")
29
30 # LFO with adjusted output range to control the delay time in seconds.
31 lfo = Sine(freq=lfospeed, mul=middelay * depth, add=middelay)
32
33 # Dynamically delayed signal. The source passes through a DCBlock
34 # to ensure there is no DC offset in the signal (with feedback, DC
35 # offset can be fatal!).
36 flg = Delay(DCBlock(src), delay=lfo, feedback=feedback)
37
38 # Mix the original source with its delayed version.
39 # Compress the mix to normalize the output signal.
40 cmp = Compress(src + flg, thresh=-20, ratio=4).out()
41
42 s.gui(locals())