Debian Codegraph @

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

raw
1 Example 2
2 ==============================================
3
4 .. code::
5
6 # This example shows how to load a sound in a table (RAM) in order to apply
7 # non-streaming effects. Here a frequency self-modulated reader is used to
8 # create new harmonics, in a way similar to waveshaping distortion.
9
10 class Module(BaseModule):
11 """
12 "Self-modulated frequency sound looper"
13
14 Description
15
16 This module loads a sound in a table and apply a frequency self-modulated
17 playback of the content. A Frequency self-modulation occurs when the
18 output sound of the playback is used to modulate the reading pointer speed.
19 That produces new harmonics in a way similar to waveshaping distortion.
20
21 Sliders
22
23 # Transposition :
24 Transposition, in cents, of the input sound
25 # Feedback :
26 Amount of self-modulation in sound playback
27 # Filter Frequency :
28 Frequency, in Hertz, of the filter
29 # Filter Q :
30 Q of the filter (inverse of the bandwidth)
31
32 Graph Only
33
34 # Overall Amplitude :
35 The amplitude curve applied on the total duration of the performance
36
37 Popups & Toggles
38
39 # Filter Type :
40 Type of the filter
41 # Polyphony Voices :
42 Number of voices played simultaneously (polyphony),
43 only available at initialization time
44 # Polyphony Chords :
45 Pitch interval between voices (chords),
46 only available at initialization time
47
48 """
49 def __init__(self):
50 BaseModule.__init__(self)
51 self.snd = self.addFilein("snd")
52 self.trfactor = CentsToTranspo(self.transpo, mul=self.polyphony_spread)
53 self.freq = Sig(self.trfactor, mul=self.snd.getRate())
54 self.dsp = OscLoop(self.snd, self.freq, self.feed*0.0002,
55 mul=self.polyphony_scaling * 0.5)
56 self.mix = self.dsp.mix(self.nchnls)
57 self.out = Biquad(self.mix, freq=self.filt_f, q=self.filt_q,
58 type=self.filt_t_index, mul=self.env)
59
60 def filt_t(self, index, value):
61 self.out.type = index
62
63 Interface = [
64 cfilein(name="snd"),
65 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"),
66 cslider(name="transpo", label="Transposition", min=-4800, max=4800, init=0,
67 unit="cnts", col="red1"),
68 cslider(name="feed", label="Feedback", min=0, max=1, init=0.25, unit="x",
69 col="purple1"),
70 cslider(name="filt_f", label="Filter Frequency", min=20, max=18000,
71 init=10000, rel="log", unit="Hz", col="green1"),
72 cslider(name="filt_q", label="Filter Q", min=0.5, max=25, init=1,
73 rel="log", unit="x", col="green2"),
74 cpopup(name="filt_t", label="Filter Type", init="Lowpass",
75 value=["Lowpass", "Highpass", "Bandpass", "Bandreject"], col="green1"),
76 cpoly()
77 ]
78