Debian Codegraph @

Resources/modules/Time/4Delays.c5

raw
1 class Module(BaseModule):
2 """
3 "Two stereo delays with parallel or serial routing"
4
5 Description
6
7 A classical module implementing a pair of stereo delays
8 with user-defined delay time, feedback and gain. Routing
9 of delays and filters can be defined with the popup menus.
10
11 Sliders
12
13 # Delay 1 Left :
14 Delay one, left channel, delay time in seconds
15 # Delay 1 Right :
16 Delay one, right channel, delay time in seconds
17 # Delay 1 Feedback :
18 Amount of delayed signal fed back to the delay line input
19 # Delay 1 Gain :
20 Gain of the delayed signal
21 # Delay 2 Left :
22 Delay two, left channel, delay time in seconds
23 # Delay 2 Right :
24 Delay two, right channel, delay time in seconds
25 # Delay 2 Feedback :
26 Amount of delayed signal fed back to the delay line input
27 # Delay 2 Gain :
28 Gain of the delayed signal
29 # Jitter Amp :
30 Amplitude of the jitter applied on the delay times
31 # Jitter Speed :
32 Speed of the jitter applied on the delay times
33 # Filter Freq :
34 Cutoff or center frequency of the filter
35 # Filter Q :
36 Q factor of the filter
37 # Dry / Wet :
38 Mix between the original signal and the processed signals
39
40 Graph Only
41
42 # Overall Amplitude :
43 The amplitude curve applied on the total duration of the performance
44
45 Popups & Toggles
46
47 # Delay Routing :
48 Type of routing
49 # Filter Type :
50 Type of filter
51 # Filter Routing :
52 Specify if the filter is pre or post process
53 # Balance :
54 Compression mode. Off, balanced with a fixed signal
55 or balanced with the input source.
56 # Polyphony Voices :
57 Number of voices played simultaneously (polyphony),
58 only available at initialization time
59 # Polyphony Spread :
60 Pitch variation between voices (chorus),
61 only available at initialization time
62
63 """
64 def __init__(self):
65 BaseModule.__init__(self)
66 self.snd = self.addSampler("snd")
67 self.prefilt = Biquadx(self.snd, freq=self.filter, q=self.filterq, type=self.filttype_index, stages=2, mul=0.25)
68 self.filtChoice = SigTo(0, time=0.005, init=0)
69 self.toDelays = Interp(self.prefilt, self.snd, interp=self.filtChoice)
70 self.jit = Randi(min=1-self.jitamp, max=1+self.jitamp, freq=self.jitspeed, mul=[1]*4)
71 self.delay1 = Delay(self.toDelays, delay=[self.del1l*self.jit[0],self.del1r*self.jit[1]],
72 feedback=self.del1f, maxdelay=10, mul=DBToA(self.del1m))
73 self.delay2 = Delay(self.toDelays, delay=[self.del2l*self.jit[2],self.del2r*self.jit[3]],
74 feedback=self.del2f, maxdelay=10, mul=DBToA(self.del2m))
75 self.dels = self.delay1+self.delay2
76 self.postfilt = Biquadx(self.dels, freq=self.filter, q=self.filterq, type=self.filttype_index, stages=2, mul=0.25)
77 self.toOuts = Interp(self.dels, self.postfilt, interp=self.filtChoice)
78 self.deg = Interp(self.snd*0.25, self.toOuts, self.drywet, mul=self.env)
79
80 self.osc = Sine(10000,mul=.1)
81 self.balanced = Balance(self.deg, self.osc, freq=10)
82 self.out = Interp(self.deg, self.balanced)
83
84 #INIT
85 self.balance(self.balance_index, self.balance_value)
86 self.routing(self.routing_index, self.routing_value)
87 self.filtrouting(self.filtrouting_index, self.filtrouting_value)
88
89 def balance(self,index,value):
90 if index == 0:
91 self.out.interp = 0
92 elif index ==1:
93 self.out.interp = 1
94 self.balanced.input2 = self.osc
95 elif index == 2:
96 self.out.interp = 1
97 self.balanced.input2 = self.snd
98
99 def filttype(self, index, value):
100 self.prefilt.type = index
101 self.postfilt.type = index
102
103 def routing(self, index, value):
104 if index == 0:
105 self.delay2.setInput(self.delay1, 0.1)
106 self.postfilt.setInput(self.delay2, 0.1)
107 else:
108 self.delay2.setInput(self.toDelays, 0.1)
109 self.postfilt.setInput(self.dels, 0.1)
110
111 def filtrouting(self, index, value):
112 self.filtChoice.value = index
113
114 Interface = [ csampler(name="snd", label="Audio"),
115 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
116 cslider(name="del1l", label="Delay 1 Left", min=0.0001, max=10, init=0.26, gliss=0.1, rel="log", unit="sec", half=True, col="blue1"),
117 cslider(name="del2l", label="Delay 2 Left", min=0.0001, max=10, init=0.16, gliss=0.1, rel="log", unit="sec", half=True, col="green1"),
118 cslider(name="del1r", label="Delay 1 Right", min=0.0001, max=10, gliss=0.1, init=0.25, rel="log", unit="sec", half=True, col="blue2"),
119 cslider(name="del2r", label="Delay 2 Right", min=0.0001, max=10, init=0.15, gliss=0.1, rel="log", unit="sec", half=True, col="green2"),
120 cslider(name="del1f", label="Delay 1 Feedback", min=0, max=0.999, init=0.5, rel="lin", unit="x", half=True, col="blue3"),
121 cslider(name="del2f", label="Delay 2 Feedback", min=0, max=0.999, init=0.5, rel="lin", unit="x", half=True, col="green3"),
122 cslider(name="del1m", label="Delay 1 Gain", min=-48, max=18, init=0, rel="lin", unit="dB", half=True, col="blue4"),
123 cslider(name="del2m", label="Delay 2 Gain", min=-48, max=18, init=0, rel="lin", unit="dB", half=True, col="green4"),
124 cslider(name="jitamp", label="Jitter Amp", min=0.0001, max=1, init=0.1, rel="log", unit="x", col="red1", half=True),
125 cslider(name="jitspeed", label="Jitter Speed", min=0.0001, max=50, init=0.03, rel="log", unit="Hz", col="red2", half=True),
126 cslider(name="filter", label="Filter Freq", min=30, max=20000, init=15000, rel="log", unit="Hz", col="orange1"),
127 cslider(name="filterq", label="Filter Q", min=0.5, max=10, init=0.707, rel="log", unit="Q", col="orange2"),
128 cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue1"),
129 cpopup(name="routing", label="Delay Routing", init="Parallel", col="purple1", value=["Serial","Parallel"]),
130 cpopup(name="filttype", label="Filter Type", init="Lowpass", col="orange1", value=["Lowpass","Highpass","Bandpass","Bandstop"]),
131 cpopup(name="filtrouting", label="Filter Routing", init="Pre", col="orange1", value=["Pre","Post"]),
132 cpopup(name="balance", label = "Balance", init= "Off", col="blue1", value=["Off","Compress", "Source"]),
133 cpoly()
134 ]
135