Debian Codegraph @

Resources/modules/Filters/BrickWall.c5

raw
1 class Module(BaseModule):
2 """
3 "Convolution brickwall lowpass/highpass/bandpass/bandstop filter"
4
5 Description
6
7 Convolution filter with a user-defined length sinc kernel. This
8 kind of filters are very CPU expensive but can give quite good
9 stopband attenuation.
10
11 Sliders
12
13 # Cutoff Frequency :
14 Cutoff frequency, in Hz, of the filter.
15 # Bandwidth :
16 Bandwith, in Hz, of the filter.
17 Used only by bandpass and pnadstop filters.
18 # Filter Order :
19 Number of points of the filter kernel. A longer kernel means
20 a sharper attenuation (and a higher CPU cost). This value is
21 only available at initialization time.
22
23 Graph Only
24
25 # Overall Amplitude :
26 The amplitude curve applied on the total duration of the performance
27
28 Popups & Toggles
29
30 # Filter Type :
31 Type of the filter (lowpass, highpass, bandpass, bandstop)
32 # Balance :
33 Compression mode. Off, balanced with a fixed signal
34 or balanced with the input source.
35 # Polyphony Voices :
36 Number of voices played simultaneously (polyphony),
37 only available at initialization time
38 # Polyphony Spread :
39 Pitch variation between voices (chorus),
40 only available at initialization time
41
42 """
43 def __init__(self):
44 BaseModule.__init__(self)
45 self.snd = self.addSampler("snd")
46 self.deg = IRWinSinc(self.snd, freq=self.freq, bw=self.bw, type=self.type_index, order=int(self.order.get()), mul=self.env)
47
48 #BALANCE
49 self.osc = Sine(10000, mul=.1)
50 self.balanced = Balance(self.deg, self.osc, freq=10)
51 self.out = Interp(self.deg, self.balanced)
52
53 #INIT
54 self.balance(self.balance_index, self.balance_value)
55
56 def balance(self,index,value):
57 if index == 0:
58 self.out.interp = 0
59 elif index ==1:
60 self.out.interp = 1
61 self.balanced.input2 = self.osc
62 elif index == 2:
63 self.out.interp = 1
64 self.balanced.input2 = self.snd
65
66 def type(self, index, value):
67 self.deg.type = index
68
69 def order_up(self, value):
70 pass
71
72 Interface = [
73 csampler(name="snd"),
74 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"),
75 cslider(name="freq", label="Cutoff Frequency", min=20, max=18000, init=1000, rel="log", unit="Hz", col="green1"),
76 cslider(name="bw", label="Bandwidth", min=20, max=18000, init=1000, rel="log", unit="Hz", col="green2"),
77 cslider(name="order", label="Filter Order", min=32, max=1024, init=256, res="int", rel="lin", up=True, col="grey"),
78 cpopup(name="type", label="Filter Type", value=["Lowpass", "Highpass","Bandstop","Bandpass"], init="Lowpass", col="green1"),
79 cpopup(name="balance", label = "Balance", init= "Off", col="blue1", value=["Off","Compress", "Source"]),
80 cpoly()
81 ]
82