Debian Codegraph @

Resources/modules/Spectral/SpectralGate.c5

raw
1 class Module(BaseModule):
2 """
3 "Spectral gate (Phase Vocoder)"
4
5 Description
6
7 For each frequency band of a phase vocoder analysis, if the amplitude
8 of the bin falls below a given threshold, it is attenuated according
9 to the `Gate Attenuation` parameter.
10
11 Sliders
12
13 # Gate Threshold :
14 dB value at which the gate becomes active
15 # Gate Attenuation :
16 Gain in dB of the gated signal
17
18 Graph Only
19
20 # Overall Amplitude :
21 The amplitude curve applied on the total duration of the performance
22
23 Popups & Toggles
24
25 # FFT Size :
26 Size, in samples, of the FFT
27 # FFT Envelope :
28 Windowing shape of the FFT
29 # FFT Overlaps :
30 Number of FFT overlaping analysis
31 # Polyphony Voices :
32 Number of voices played simultaneously (polyphony),
33 only available at initialization time
34 # Polyphony Spread :
35 Pitch variation between voices (chorus),
36 only available at initialization time
37
38 """
39 def __init__(self):
40 BaseModule.__init__(self)
41 self.snd = self.addSampler("snd")
42
43 size = int(self.fftsize_value)
44 olaps = int(self.overlaps_value)
45 wintype = self.wtype_index
46
47 self.fin = PVAnal(self.snd, size=size, overlaps=olaps, wintype=wintype)
48 self.gate = PVGate(self.fin, thresh=self.gthresh, damp=DBToA(self.gatt))
49 self.fout = PVSynth(self.gate, wintype=wintype, mul=self.env)
50
51 self.fade = SigTo(value=1, time=.05, init=1)
52 self.out = Sig(self.fout, mul=self.fade)
53
54 def fftsize(self, index, value):
55 newsize = int(value)
56 self.fade.value = 0
57 time.sleep(.05)
58 self.fin.size = newsize
59 time.sleep(.05)
60 self.fade.value = 1
61
62 def overlaps(self, index, value):
63 olaps = int(value)
64 self.fade.value = 0
65 time.sleep(.05)
66 self.fin.overlaps = olaps
67 time.sleep(.05)
68 self.fade.value = 1
69
70 def wtype(self, index, value):
71 self.fin.wintype = index
72 self.fout.wintype = index
73
74 Interface = [ csampler(name="snd"),
75 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
76 cslider(name="gthresh", label="Gate Threshold", min=-120, max=0, init=-30, rel="lin", unit="db", col="orange"),
77 cslider(name="gatt", label="Gate Attenuation", min=-120, max=0, init=-120, rel="lin", unit="db", col="purple1"),
78 cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
79 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
80 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
81 cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]),
82 cpoly()
83 ]