| 1 |
class Module(BaseModule): |
| 2 |
""" |
| 3 |
"Ranged filter module using lowpass and highpass filters" |
| 4 |
|
| 5 |
Description |
| 6 |
|
| 7 |
The signal is first lowpassed and then highpassed to create a bandpass |
| 8 |
filter with independant lower and higher boundaries. The user can |
| 9 |
interpolate between two such filters. |
| 10 |
|
| 11 |
Sliders |
| 12 |
|
| 13 |
# Filter 1 Limits : |
| 14 |
Range of the first filter (min = highpass, max = lowpass) |
| 15 |
# Filter 2 Limits : |
| 16 |
Range of the second filter (min = highpass, max = lowpass) |
| 17 |
# Mix : |
| 18 |
Balance between filter 1 and filter 2 |
| 19 |
|
| 20 |
Graph Only |
| 21 |
|
| 22 |
# Overall Amplitude : |
| 23 |
The amplitude curve applied on the total duration of the performance |
| 24 |
|
| 25 |
Popups & Toggles |
| 26 |
|
| 27 |
# Number of Stages : |
| 28 |
Amount of stacked biquad filters |
| 29 |
# Balance : |
| 30 |
Compression mode. Off, balanced with a fixed signal |
| 31 |
or balanced with the input source. |
| 32 |
# Polyphony Voices : |
| 33 |
Number of voices played simultaneously (polyphony), |
| 34 |
only available at initialization time |
| 35 |
# Polyphony Spread : |
| 36 |
Pitch variation between voices (chorus), |
| 37 |
only available at initialization time |
| 38 |
|
| 39 |
""" |
| 40 |
def __init__(self): |
| 41 |
BaseModule.__init__(self) |
| 42 |
self.snd = self.addSampler("snd") |
| 43 |
self.lp = Biquadx(input=self.snd, freq=self.fultrange[1], q=1, type=0, stages=int(self.filtnum_value), mul=1) |
| 44 |
self.hp = Biquadx(input=self.lp, freq=self.fultrange[0], q=1, type=1, stages=int(self.filtnum_value), mul=0.5*self.env) |
| 45 |
self.lp2 = Biquadx(input=self.snd, freq=self.filtrangeCAC[1], q=1, type=0, stages=int(self.filtnum_value), mul=1) |
| 46 |
self.hp2 = Biquadx(input=self.lp2, freq=self.filtrangeCAC[0], q=1, type=1, stages=int(self.filtnum_value), mul=0.5*self.env) |
| 47 |
|
| 48 |
#BALANCE |
| 49 |
self.osc = Sine(10000,mul=.1) |
| 50 |
self.balanced1 = Balance(self.hp, self.osc, freq=10) |
| 51 |
self.balanced2 = Balance(self.hp2, self.osc, freq=10) |
| 52 |
self.out1 = Interp(self.hp, self.balanced1) |
| 53 |
self.out2 = Interp(self.hp2, self.balanced2) |
| 54 |
self.out = Interp(self.out1, self.out2, self.mix, mul=0.5) |
| 55 |
|
| 56 |
#INIT |
| 57 |
self.balance(self.balance_index, self.balance_value) |
| 58 |
|
| 59 |
def filtnum(self, index, value): |
| 60 |
self.lp.stages = int(value) |
| 61 |
self.hp.stages = int(value) |
| 62 |
self.lp2.stages = int(value) |
| 63 |
self.hp2.stages = int(value) |
| 64 |
|
| 65 |
def balance(self,index,value): |
| 66 |
if index == 0: |
| 67 |
self.out1.interp = 0 |
| 68 |
self.out2.interp = 0 |
| 69 |
elif index ==1: |
| 70 |
self.out1.interp = 1 |
| 71 |
self.out2.interp = 1 |
| 72 |
self.balanced1.input2 = self.osc |
| 73 |
self.balanced2.input2 = self.osc |
| 74 |
elif index == 2: |
| 75 |
self.out1.interp = 1 |
| 76 |
self.out2.interp = 1 |
| 77 |
self.balanced1.input2 = self.snd |
| 78 |
self.balanced2.input2 = self.snd |
| 79 |
|
| 80 |
Interface = [ csampler(name="snd"), |
| 81 |
cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"), |
| 82 |
crange(name="fultrange", label="Filter 1 Limits", min=20, max=20000, init = [100,200], rel="log", unit="Hz", col="green1"), |
| 83 |
crange(name="filtrangeCAC", label="Filter 2 Limits", min=20, max=20000, init = [1000,2000], rel="log", unit="Hz", col="green2"), |
| 84 |
cslider(name="mix", label = "Mix", min=0,max=1,init=0.5,rel="lin", unit="%",col="blue1"), |
| 85 |
cpopup(name="filtnum", label="Number of Stages", init="4", col="orange1", value=["1","2","3","4","5","6"]), |
| 86 |
cpopup(name="balance", label = "Balance", init= "Off", col="blue1", value=["Off","Compress", "Source"]), |
| 87 |
cpoly() |
| 88 |
] |
| 89 |
|