Debian Codegraph @

docs/_sources/examples/06-filters/02-bandpass-filters.rst.txt

raw
1 02-bandpass-filters.py - Narrowing a bandpass filter bandwidth.
2 ============================================================================================================================================
3
4
5 This example illustrates the difference between a simple IIR second-order
6 bandpass filter and a cascade of second-order bandpass filters. A cascade
7 of four bandpass filters with a high Q can be used as a efficient resonator
8 on the signal.
9
10 .. code-block:: python
11
12 from pyo import *
13
14 s = Server().boot()
15
16 # White noise generator
17 n = Noise(0.5)
18
19 # Common cutoff frequency control
20 freq = Sig(1000)
21 freq.ctrl([SLMap(50, 5000, "lin", "value", 1000)], title="Cutoff Frequency")
22
23 # Common filter's Q control
24 q = Sig(5)
25 q.ctrl([SLMap(0.7, 20, "log", "value", 5)], title="Filter's Q")
26
27 # Second-order bandpass filter
28 bp1 = Reson(n, freq, q=q)
29 # Cascade of second-order bandpass filters
30 bp2 = Resonx(n, freq, q=q, stages=4)
31
32 # Interpolates between input objects to produce a single output
33 sel = Selector([bp1, bp2]).out()
34 sel.ctrl(title="Filter selector (0=Reson, 1=Resonx)")
35
36 # Displays the spectrum contents of the chosen source
37 sp = Spectrum(sel)
38
39 s.gui(locals())
40