| 1 |
class Module(BaseModule): |
| 2 |
""" |
| 3 |
"Arctangent distortion module with upsampling and resonant lowpass filter" |
| 4 |
|
| 5 |
Description |
| 6 |
|
| 7 |
This module applies an arctangent distortion on an upsampled signal and pass |
| 8 |
the result through a 24dB/oct lowpass resonant filter. |
| 9 |
|
| 10 |
Sliders |
| 11 |
|
| 12 |
# Pre-Filter Freq : |
| 13 |
Center frequency of the filter applied before distortion |
| 14 |
# Pre-Filter Q : |
| 15 |
Q factor of the filter applied before distortion |
| 16 |
# Pre-Gain : |
| 17 |
Gain control applied before the distortion |
| 18 |
# Drive : |
| 19 |
Amount of distortion applied on the signal |
| 20 |
# Lowpass Freq : |
| 21 |
Cutoff frequency of the 24dB/oct lowpass filter applied after distortion |
| 22 |
# Lowpass Res : |
| 23 |
Resonance factor of the 24dB/oct lowpass filter applied after distortion |
| 24 |
# Dry / Wet : |
| 25 |
Mix between the original signal and the degraded signal |
| 26 |
|
| 27 |
Graph Only |
| 28 |
|
| 29 |
# Overall Amplitude : |
| 30 |
The amplitude curve applied on the total duration of the performance |
| 31 |
|
| 32 |
Popups & Toggles |
| 33 |
|
| 34 |
# Pre Filter Type : |
| 35 |
Type of filter used before distortion |
| 36 |
# Balance : |
| 37 |
Compression mode. Off, balanced with a fixed signal |
| 38 |
or balanced with the input source. |
| 39 |
# Upsampling : |
| 40 |
The resampling factor. The process will be applied with a virtual |
| 41 |
sampling rate of the current sampling rate times this factor. |
| 42 |
# Interpolation : |
| 43 |
Defines the FIR lowpass kernel length used for interpolation and decimation. |
| 44 |
The kernel length will be the upsampling factor times this value. |
| 45 |
# Polyphony Voices : |
| 46 |
Number of voices played simultaneously (polyphony), |
| 47 |
only available at initialization time |
| 48 |
# Polyphony Spread : |
| 49 |
Pitch variation between voices (chorus), |
| 50 |
only available at initialization time |
| 51 |
|
| 52 |
""" |
| 53 |
def __init__(self): |
| 54 |
BaseModule.__init__(self) |
| 55 |
self.snd = self.addSampler("snd") |
| 56 |
self.snd_filt = Biquadx(self.snd, freq=self.prefiltf, q=self.prefiltq, |
| 57 |
type=self.prefilttype_index, stages=2) |
| 58 |
self.input = Sig(self.snd_filt, mul=DBToA(self.pregain)) |
| 59 |
self.drive = Sqrt(self.drv * 0.1 + 0.9) |
| 60 |
|
| 61 |
upfactor = int(self.factor_value) |
| 62 |
filtermode = int(self.fmode_value) |
| 63 |
|
| 64 |
server = self.input.getServer() |
| 65 |
server.beginResamplingBlock(upfactor) |
| 66 |
self.inputup = Resample(self.input, mode=filtermode) |
| 67 |
self.drvup = Resample(self.drive, mode=1) |
| 68 |
self.disto = Disto(self.inputup, drive=self.drvup, mul=0.5) |
| 69 |
server.endResamplingBlock() |
| 70 |
self.sigdown = Resample(self.disto, mode=filtermode) |
| 71 |
|
| 72 |
self.distof = MoogLP(self.sigdown, freq=self.cut, res=self.res) |
| 73 |
self.deg = Interp(self.snd, self.distof, self.drywet, mul=self.env) |
| 74 |
|
| 75 |
self.osc = Sine(10000, mul=.1) |
| 76 |
self.balanced = Balance(self.deg, self.osc, freq=10) |
| 77 |
self.out = Interp(self.deg, self.balanced) |
| 78 |
|
| 79 |
#INIT |
| 80 |
self.balance(self.balance_index, self.balance_value) |
| 81 |
|
| 82 |
def prefilttype(self, index, value): |
| 83 |
self.snd_filt.type = index |
| 84 |
|
| 85 |
def balance(self,index,value): |
| 86 |
if index == 0: |
| 87 |
self.out.interp = 0 |
| 88 |
elif index == 1: |
| 89 |
self.out.interp = 1 |
| 90 |
self.balanced.input2 = self.osc |
| 91 |
elif index == 2: |
| 92 |
self.out.interp = 1 |
| 93 |
self.balanced.input2 = self.snd |
| 94 |
|
| 95 |
Interface = [ |
| 96 |
csampler(name="snd"), |
| 97 |
cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"), |
| 98 |
cslider(name="prefiltf", label="Pre-Filter Freq", min=100, max=18000, init=250, rel="log", unit="Hz", col="green1"), |
| 99 |
cslider(name="prefiltq", label="Pre-Filter Q", min=.5, max=10, init=0.707, rel="log", col="green2"), |
| 100 |
cslider(name="pregain", label="Pre-Gain", min=-48, max=18, init=0, rel="lin", col="blue2"), |
| 101 |
cslider(name="drv", label="Drive", min=0, max=1, init=.75, rel="lin", col="purple1"), |
| 102 |
cslider(name="cut", label="Lowpass Freq", min=100, max=15000, init=5000, rel="log", col="green3"), |
| 103 |
cslider(name="res", label="Lowpass Res", min=0, max=1, init=0.5, col="green4"), |
| 104 |
cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue1"), |
| 105 |
cpopup(name="balance", label = "Balance", init= "Off", col="blue", value=["Off","Compress", "Source"]), |
| 106 |
cpopup(name="prefilttype", label="Pre-Filter Type", init="Highpass", col="green1", value=["Lowpass","Highpass","Bandpass","Bandstop"]), |
| 107 |
cpopup(name="factor", label = "Upsampling", init= "8", rate="i", col="grey", value=["2","4", "8", "16", "32"]), |
| 108 |
cpopup(name="fmode", label = "Interpolation", init= "32", rate="i", col="grey", value=["2","4", "8", "16", "32", "64", "128", "256"]), |
| 109 |
cpoly() |
| 110 |
] |