| 1 |
import random |
| 2 |
class Module(BaseModule): |
| 3 |
""" |
| 4 |
"Multiple waveguide models module" |
| 5 |
|
| 6 |
Description |
| 7 |
|
| 8 |
Resonators whose frequencies are controlled with an expansion expression. |
| 9 |
|
| 10 |
freq[i] = BaseFreq * pow(WGExpansion, i) |
| 11 |
|
| 12 |
Sliders |
| 13 |
|
| 14 |
# Base Freq : |
| 15 |
Base pitch of the waveguides |
| 16 |
# WG Expansion : |
| 17 |
Spread between waveguides |
| 18 |
# WG Feedback : |
| 19 |
Length of the waveguides |
| 20 |
# Filter Cutoff : |
| 21 |
Center frequency of the filter |
| 22 |
# Filter Q : |
| 23 |
Q (resonance) of the filter |
| 24 |
# Amp Dev Amp : |
| 25 |
Amplitude of the jitter applied on the waveguides amplitude |
| 26 |
# Amp Dev Speed : |
| 27 |
Frequency of the jitter applied on the waveguides amplitude |
| 28 |
# Freq Dev Amp : |
| 29 |
Amplitude of the jitter applied on the waveguides pitch |
| 30 |
# Freq Dev Speed : |
| 31 |
Frequency of the jitter applied on the waveguides pitch |
| 32 |
# Dry / Wet : |
| 33 |
Mix between the original signal and the waveguides |
| 34 |
|
| 35 |
Graph Only |
| 36 |
|
| 37 |
# Overall Amplitude : |
| 38 |
The amplitude curve applied on the total duration of the performance |
| 39 |
|
| 40 |
Popups & Toggles |
| 41 |
|
| 42 |
# Filter Type : |
| 43 |
Type of the post-process filter |
| 44 |
# Balance : |
| 45 |
Compression mode. Off, balanced with a fixed signal |
| 46 |
or balanced with the input source. |
| 47 |
# Polyphony Voices : |
| 48 |
Number of voices played simultaneously (polyphony), |
| 49 |
only available at initialization time |
| 50 |
# Polyphony Spread : |
| 51 |
Pitch variation between voices (chorus), |
| 52 |
only available at initialization time |
| 53 |
|
| 54 |
""" |
| 55 |
def __init__(self): |
| 56 |
BaseModule.__init__(self) |
| 57 |
self.snd = self.addSampler("snd") |
| 58 |
chnls = len(self.snd) |
| 59 |
num = 8 * chnls |
| 60 |
self.ra = Randi(min=1-self.dev, max=1+self.dev, freq=self.speed*[random.uniform(0.85,1.15) for i in range(num)], mul=0.03) |
| 61 |
self.rf = Randi(min=1-self.fdev, max=1+self.fdev, freq=self.fspeed*[random.uniform(0.97,1.03) for i in range(num)]) |
| 62 |
self.voices = [self.basefreq*Pow(self.exp, i) for i in range(num)] |
| 63 |
self.frs = self.duplicate(self.voices, chnls) |
| 64 |
self.wgs = Waveguide(input=self.snd, freq=Dummy(self.frs)*self.rf, dur=60*self.fb, minfreq=10, mul=self.ra) |
| 65 |
self.wgsm = self.wgs.mix(chnls) |
| 66 |
self.biquad = Biquadx(self.wgsm, freq=self.filter, q=self.filterq, type=self.filttype_index, stages=2, mul=0.4) |
| 67 |
self.deg = Interp(self.snd, self.biquad, self.drywet, mul=self.env) |
| 68 |
|
| 69 |
self.osc = Sine(10000,mul=.1) |
| 70 |
self.balanced = Balance(self.deg, self.osc, freq=10) |
| 71 |
self.out = Interp(self.deg, self.balanced) |
| 72 |
|
| 73 |
#INIT |
| 74 |
self.balance(self.balance_index, self.balance_value) |
| 75 |
|
| 76 |
def balance(self,index,value): |
| 77 |
if index == 0: |
| 78 |
self.out.interp = 0 |
| 79 |
elif index ==1: |
| 80 |
self.out.interp = 1 |
| 81 |
self.balanced.input2 = self.osc |
| 82 |
elif index == 2: |
| 83 |
self.out.interp = 1 |
| 84 |
self.balanced.input2 = self.snd |
| 85 |
|
| 86 |
def filttype(self, index, value): |
| 87 |
self.biquad.type = index |
| 88 |
|
| 89 |
Interface = [ csampler(name="snd"), |
| 90 |
cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"), |
| 91 |
cslider(name="basefreq", label="Base Freq", min=10, max=1000, init=40, rel="log", unit="Hz", col="blue"), |
| 92 |
cslider(name="exp", label="WG Expansion", min=0, max=4, init=1.33, rel="lin", unit="x", col="blue4"), |
| 93 |
cslider(name="fb", label="WG Feedback", min=0, max=0.999, init=0.95, rel="lin", unit="x", col="blue4"), |
| 94 |
cslider(name="filter", label="Filter Cutoff", min=50, max=20000, init=20000, rel="log", unit="Hz", col="green1"), |
| 95 |
cslider(name="filterq", label="Filter Q", min=0.5, max=10, init=0.7, rel="log", unit="x", col="green2"), |
| 96 |
cslider(name="dev", label="Amp Dev Amp", min=0.001, max=1, init=0.01, rel="log", unit="x", col="purple2", half = True), |
| 97 |
cslider(name="fdev", label="Freq Dev Amp", min=0.001, max=1, init=0.01, rel="log", unit="x", col="purple1", half = True), |
| 98 |
cslider(name="speed", label="Amp Dev Speed", min=0.01, max=120, init=1, rel="log", unit="Hz", col="purple2", half = True), |
| 99 |
cslider(name="fspeed", label="Freq Dev Speed", min=0.01, max=120, init=1, rel="log", unit="Hz", col="purple1", half = True), |
| 100 |
cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"), |
| 101 |
cpopup(name="filttype", label="Filter Type", init="Lowpass", col="green1", value=["Lowpass","Highpass","Bandpass","Bandstop"]), |
| 102 |
cpopup(name="balance", label = "Balance", init= "Off", col="blue", value=["Off","Compress", "Source"]), |
| 103 |
cpoly() |
| 104 |
] |
| 105 |
|