Debian Codegraph @

doc-en/source/src/api/Interface/example1.rst

raw
1 Example 1
2 ==============================================
3
4 .. code::
5
6 # This example shows how to use the sampler to loop any soundfile from the disk.
7 # A state-variable filter is then applied on the looped sound.
8
9 class Module(BaseModule):
10 """
11 "State Variable Filter"
12
13 Description
14
15 This module implements lowpass, bandpass and highpass filters in parallel
16 and allow the user to interpolate on an axis lp -> bp -> hp.
17
18 Sliders
19
20 # Cutoff/Center Freq :
21 Cutoff frequency for lp and hp (center freq for bp)
22 # Filter Q :
23 Q factor (inverse of bandwidth) of the filter
24 # Type (lp->bp->hp) :
25 Interpolating factor between filters
26 # Dry / Wet :
27 Mix between the original and the filtered signals
28
29 Graph Only
30
31 # Overall Amplitude :
32 The amplitude curve applied on the total duration of the performance
33
34 Popups & Toggles
35
36 # Polyphony Voices :
37 Number of voices played simultaneously (polyphony),
38 only available at initialization time
39 # Polyphony Chords :
40 Pitch interval between voices (chords),
41 only available at initialization time
42
43 """
44 def __init__(self):
45 BaseModule.__init__(self)
46 self.snd = self.addSampler("snd")
47 self.dsp = SVF(self.snd, self.freq, self.q, self.type)
48 self.out = Interp(self.snd, self.dsp, self.drywet, mul=self.env)
49
50 Interface = [
51 csampler(name="snd"),
52 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"),
53 cslider(name="freq", label="Cutoff/Center Freq", min=20, max=20000, init=1000,
54 rel="log", unit="Hz", col="green1"),
55 cslider(name="q", label="Filter Q", min=0.5, max=25, init=1, rel="log",
56 unit="x", col="green2"),
57 cslider(name="type", label="Type (lp->bp->hp)", min=0, max=1, init=0.5,
58 rel="lin", unit="x", col="green3"),
59 cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin",
60 unit="x", col="blue1"),
61 cpoly()
62 ]
63