Debian Codegraph @

Resources/modules/Spectral/SpectralFilter.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase Vocoder based filter"
4
5 Description
6
7 This module filters frequency components of a phase
8 vocoder analysed sound according to the shape drawn
9 in the grapher function.
10
11 Sliders
12
13 # Dry / Wet :
14 Mix between the original signal and the processed signal
15
16 Graph Only
17
18 # Spectral Filter :
19 Shape of the filter (amplitude of analysis bins)
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 self.oneOverSr = 1.0 / self.sr
47
48 self.delsrc = Delay(self.snd, delay=size*self.oneOverSr)
49
50 self.fin = PVAnal(self.snd, size=size, overlaps=olaps, wintype=wintype)
51 self.filt = PVFilter(self.fin, self.filter_table, mode=1)
52 self.fout = PVSynth(self.filt, wintype=wintype, mul=self.env)
53
54 self.fade = SigTo(value=1, time=.05, init=1)
55 self.out = Interp(self.delsrc*self.env, self.fout, self.mix, mul=self.fade)
56
57 def fftsize(self, index, value):
58 newsize = int(value)
59 self.fade.value = 0
60 time.sleep(.05)
61 self.delsrc.delay = newsize*self.oneOverSr
62 self.fin.size = newsize
63 time.sleep(.05)
64 self.fade.value = 1
65
66 def overlaps(self, index, value):
67 olaps = int(value)
68 self.fade.value = 0
69 time.sleep(.05)
70 self.fin.overlaps = olaps
71 time.sleep(.05)
72 self.fade.value = 1
73
74 def wtype(self, index, value):
75 self.fin.wintype = index
76 self.fout.wintype = index
77
78 Interface = [ csampler(name="snd"),
79 cgraph(name="filter_table", label="Spectral Filter", table=True, size=8192,
80 func=[(0,0),(0.05,1),(0.1,0),(0.2,0),(0.3,.7),(0.4,0),(0.5,0),(0.6,.5),(0.7,0),(1,0)], col="green"),
81 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
82 cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
83 cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
84 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
85 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
86 cpopup(name="overlaps", label="FFT Overlaps", init="4", value=["1", "2", "4", "8", "16"]),
87 cpoly()
88 ]
89