| 1 |
class Module(BaseModule): |
| 2 |
""" |
| 3 |
"AM/FM modulated filter" |
| 4 |
|
| 5 |
Description |
| 6 |
|
| 7 |
The input sound is filtered by a variable type modulated filter. |
| 8 |
Speed, depth and shape can be modified for both AM and FM modulators. |
| 9 |
|
| 10 |
Sliders |
| 11 |
|
| 12 |
# Filter Mean Freq : |
| 13 |
Mean frequency of the filter |
| 14 |
# Resonance : |
| 15 |
Q factor of the filter |
| 16 |
# AM Depth : |
| 17 |
Amplitude of the amplitude modulator |
| 18 |
# AM Freq : |
| 19 |
Speed, in Hz, of the amplitude modulator |
| 20 |
# FM Depth : |
| 21 |
Amplitude of the frequency modulator |
| 22 |
# FM Freq : |
| 23 |
Speed, in Hz, of the frequency modulator |
| 24 |
# Mod Sharpness : |
| 25 |
Sharpness of waveforms used as modulators |
| 26 |
# Dry / Wet : |
| 27 |
Mix between the original signal and the filtered signal |
| 28 |
|
| 29 |
Graph Only |
| 30 |
|
| 31 |
# Overall Amplitude : |
| 32 |
The amplitude curve applied on the total duration of the performance |
| 33 |
|
| 34 |
Popups & Toggles |
| 35 |
|
| 36 |
# Filter Type : |
| 37 |
Type of filter |
| 38 |
# AM Mod Type : |
| 39 |
Shape of the amplitude modulator |
| 40 |
# FM Mod Type : |
| 41 |
Shape of the frequency modulator |
| 42 |
# Balance : |
| 43 |
Compression mode. Off, balanced with a fixed signal |
| 44 |
or balanced with the input source. |
| 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.lfomodAM = LFO(freq=self.modfreqAM, sharp=self.modSharp, type=self.modtypeAM_index, mul=0.5, add=0.5) |
| 57 |
self.lfomodFM = LFO(freq=self.modfreqFM, sharp=self.modSharp, type=self.modtypeFM_index, mul=0.5, add=0.5) |
| 58 |
self.filt = Biquadx(input=self.snd, freq=self.centerfreq*(self.lfomodFM*(self.moddepthFM*2)+(1-self.moddepthFM))+50, q=self.filterq, |
| 59 |
type=self.filttype_index, stages=2, mul=0.7 *(self.lfomodAM*self.moddepthAM+(1-self.moddepthAM))) |
| 60 |
self.deg = Interp(self.snd, self.filt, self.drywet, mul=self.env) |
| 61 |
|
| 62 |
self.osc = Sine(10000,mul=.1) |
| 63 |
self.balanced = Balance(self.deg, self.osc, freq=10) |
| 64 |
self.out = Interp(self.deg, self.balanced) |
| 65 |
|
| 66 |
#INIT |
| 67 |
self.balance(self.balance_index, self.balance_value) |
| 68 |
|
| 69 |
def filttype(self, index, value): |
| 70 |
self.filt.type = index |
| 71 |
|
| 72 |
def modtypeFM(self, index, value): |
| 73 |
self.lfomodFM.type = (index - 1) % 8 |
| 74 |
|
| 75 |
def modtypeAM(self, index, value): |
| 76 |
self.lfomodAM.type = (index - 1) % 8 |
| 77 |
|
| 78 |
def balance(self,index,value): |
| 79 |
if index == 0: |
| 80 |
self.out.interp = 0 |
| 81 |
elif index == 1: |
| 82 |
self.out.interp = 1 |
| 83 |
self.balanced.input2 = self.osc |
| 84 |
elif index == 2: |
| 85 |
self.out.interp = 1 |
| 86 |
self.balanced.input2 = self.snd |
| 87 |
|
| 88 |
Interface = [ csampler(name="snd"), |
| 89 |
cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"), |
| 90 |
cslider(name="centerfreq", label="Filter Mean Freq", min=20, max=20000, init=2000, rel="log", unit="Hz", col="green1"), |
| 91 |
cslider(name="filterq", label="Resonance", min=0.5, max=10, init=0.707, rel="lin", unit="Q", col="green2"), |
| 92 |
cslider(name="moddepthAM", label="AM Depth", min=0.001, max=1, init=0.5, rel="lin", unit="x", col="red1", half=True), |
| 93 |
cslider(name="moddepthFM", label="FM Depth", min=0.001, max=1, init=0.85, rel="lin", unit="x", col="purple1", half=True), |
| 94 |
cslider(name="modfreqAM", label="AM Freq", min=0.01, max=2000, init=1, rel="log", unit="Hz", col="red2", half=True), |
| 95 |
cslider(name="modfreqFM", label="FM Freq", min=0.01, max=2000, init=10, rel="log", unit="Hz", col="purple2", half=True), |
| 96 |
cslider(name="modSharp", label="Mod Sharpness", min=0, max=1, init=0.5, rel="lin", unit="x", col="orange1"), |
| 97 |
cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue1"), |
| 98 |
cpopup(name="filttype", label="Filter Type", init="Bandpass", col="green1", value=["Lowpass","Highpass","Bandpass","Bandstop"]), |
| 99 |
cpopup(name="modtypeAM", label="AM Mod Type", init="Sine", col="red1", value=["Sine", "Saw Up", "Saw Down", "Square", "Triangle", "Pulse", "Bipolar Pulse", |
| 100 |
"SAH"]), |
| 101 |
cpopup(name="modtypeFM", label="FM Mod Type", init="Sine", col="purple1", value=["Sine", "Saw Up", "Saw Down", "Square", "Triangle", "Pulse", "Bipolar Pulse", |
| 102 |
"SAH"]), |
| 103 |
cpopup(name="balance", label = "Balance", init= "Off", col="blue1", value=["Off","Compress", "Source"]), |
| 104 |
|
| 105 |
cpoly() |
| 106 |
] |
| 107 |
|