Debian Codegraph @

Resources/modules/Resonators&Verbs/Resonators.c5

raw
1 import random
2 class Module(BaseModule):
3 """
4 "Eight resonators with jitter control"
5
6 Description
7
8 This module implements a resonator (waveguide) bank with random controls.
9
10 This waveguide model consists of one delay-line with a simple
11 lowpass filtering and lagrange interpolation.
12
13 Sliders
14
15 # Pitch Offset :
16 Base pitch of all the resonators
17 # Amp Random Amp :
18 Amplitude of the jitter applied on the resonators amplitude
19 # Amp Random Speed :
20 Frequency of the jitter applied on the resonators amplitude
21 # Pitch Random Amp :
22 Amplitude of the jitter applied on the resonators frequency
23 # Pitch Random Speed :
24 Frequency of the jitter applied on the resonators frequency
25 # Pitch Voice 1 :
26 Pitch of the first resonator
27 # Pitch Voice 2 :
28 Pitch of the second resonator
29 # Pitch Voice 3 :
30 Pitch of the third resonator
31 # Pitch Voice 4 :
32 Pitch of the fourth resonator
33 # Pitch Voice 5 :
34 Pitch of the fifth resonator
35 # Pitch Voice 6 :
36 Pitch of the sixth resonator
37 # Pitch Voice 7 :
38 Pitch of the seventh resonator
39 # Pitch Voice 8 :
40 Pitch of the eigth resonator
41 # Feedback :
42 Amount of resonators fed back in the resonators
43 # Dry / Wet :
44 Mix between the original signal and the resonators
45
46 Graph Only
47
48 # Overall Amplitude :
49 The amplitude curve applied on the total duration of the performance
50
51 Popups & Toggles
52
53 # Voice Activation ( 1 --> 8 ) :
54 Mute or unmute each of the eigth voices independently
55 # Polyphony Voices :
56 Number of voices played simultaneously (polyphony),
57 only available at initialization time
58 # Polyphony Spread :
59 Pitch variation between voices (chorus),
60 only available at initialization time
61
62 """
63 def __init__(self):
64 BaseModule.__init__(self)
65 self.snd = self.addSampler("snd")
66 chnls = len(self.snd)
67 num = 8 * chnls
68 self.defamp = Sig([0.005 for i in range(num)])
69 self.ra = Randi(min=1-self.rndamp, max=1+self.rndamp, freq=self.rndspeed*[random.uniform(.75,1.25) for i in range(num)])
70 self.rf = Randi(min=1-self.rnddelamp, max=1+self.rnddelamp, freq=self.rnddelspeed*[random.uniform(.95,1.05) for i in range(num)])
71 self.off_transpo = CentsToTranspo(self.offset)
72 self.frs = self.duplicate([self.voice1, self.voice2, self.voice3, self.voice4, self.voice5, self.voice6, self.voice7, self.voice8], chnls)
73 self.freqs = MToF(self.frs, mul=self.off_transpo)
74 self.all_freqs = self.freqs*self.rf
75 self.wgs = Waveguide(input=self.snd*0.05, freq=self.all_freqs, dur=60*self.fb, minfreq=20, mul=self.ra*self.defamp)
76 self.deg = Interp(self.snd, self.wgs.mix(chnls), self.drywet, mul=self.env)
77
78 self.osc = Sine(10000,mul=.1)
79 self.balanced = Balance(self.deg, self.osc, freq=10)
80 self.out = Interp(self.deg, self.balanced)
81
82 #INIT
83 self.balance(self.balance_index, self.balance_value)
84 self.onoffv1(self.onoffv1_value)
85 self.onoffv2(self.onoffv2_value)
86 self.onoffv3(self.onoffv3_value)
87 self.onoffv4(self.onoffv4_value)
88 self.onoffv5(self.onoffv5_value)
89 self.onoffv6(self.onoffv6_value)
90 self.onoffv7(self.onoffv7_value)
91 self.onoffv8(self.onoffv8_value)
92
93 def balance(self,index,value):
94 if index == 0:
95 self.out.interp = 0
96 elif index ==1:
97 self.out.interp = 1
98 self.balanced.input2 = self.osc
99 elif index == 2:
100 self.out.interp = 1
101 self.balanced.input2 = self.snd
102
103 def onoff(self, i, value):
104 l = self.defamp.value
105 l[i*2:i*2+2] = [value, value]
106 self.defamp.value = l
107
108 def onoffv1(self, value):
109 self.onoff(0, value)
110
111 def onoffv2(self, value):
112 self.onoff(1, value)
113
114 def onoffv3(self, value):
115 self.onoff(2, value)
116
117 def onoffv4(self, value):
118 self.onoff(3, value)
119
120 def onoffv5(self, value):
121 self.onoff(4, value)
122
123 def onoffv6(self, value):
124 self.onoff(5, value)
125
126 def onoffv7(self, value):
127 self.onoff(6, value)
128
129 def onoffv8(self, value):
130 self.onoff(7, value)
131
132 Interface = [ csampler(name="snd"),
133 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
134 cslider(name="offset", label="Pitch Offset", min=-2400, max=2400, init=0, rel="lin", unit="cnts", col="blue"),
135 cslider(name="voice1", label="Pitch Voice 1", min=1, max=130, init=60, rel="lin", unit="semi", half=True, col="green2"),
136 cslider(name="voice2", label="Pitch Voice 2", min=1, max=130, init=72, rel="lin", unit="semi", half=True, col="green2"),
137 cslider(name="voice3", label="Pitch Voice 3", min=1, max=130, init=84, rel="lin", unit="semi", half=True, col="green2"),
138 cslider(name="voice4", label="Pitch Voice 4", min=1, max=130, init=96, rel="lin", unit="semi", half=True, col="green2"),
139 cslider(name="voice5", label="Pitch Voice 5", min=1, max=130, init=48, rel="lin", unit="semi", half=True, col="green2"),
140 cslider(name="voice6", label="Pitch Voice 6", min=1, max=130, init=67, rel="lin", unit="semi", half=True, col="green2"),
141 cslider(name="voice7", label="Pitch Voice 7", min=1, max=130, init=36, rel="lin", unit="semi", half=True, col="green2"),
142 cslider(name="voice8", label="Pitch Voice 8", min=1, max=130, init=87, rel="lin", unit="semi", half=True, col="green2"),
143 cslider(name="rndamp", label="Amp Rand Amp", min=0, max=1, init=0, rel="lin", unit="x", col="blue4", half=True),
144 cslider(name="rnddelamp", label="Pitch Rand Amp", min=0, max=0.25, init=0, rel="lin", unit="x", col="blue2", half=True),
145 cslider(name="rndspeed", label="Amp Rand Speed", min=0.001, max=100, init=0.25, rel="log", unit="Hz", col="blue4", half=True),
146 cslider(name="rnddelspeed", label="Pitch Rand Speed", min=0.001, max=100, init=6, rel="log", unit="Hz", col="blue2", half=True),
147 cslider(name="fb", label="Feedback", min=0.01, max=0.999, init=0.95, rel="lin", unit="x", col="red"),
148 cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
149 cpopup(name="balance", label = "Balance", init= "Off", col="blue", value=["Off","Compress", "Source"]),
150 ctoggle(name="onoffv1", label="Voice Activation / 1 > 8", init=1, stack=True, col="green2"),
151 ctoggle(name="onoffv2", label="", init=1, stack=True, col="green2"),
152 ctoggle(name="onoffv3", label="", init=1, stack=True, col="green2"),
153 ctoggle(name="onoffv4", label="", init=1, stack=True, col="green2"),
154 ctoggle(name="onoffv5", label="", init=1, stack=True, col="green2"),
155 ctoggle(name="onoffv6", label="", init=1, stack=True, col="green2"),
156 ctoggle(name="onoffv7", label="", init=1, stack=True, col="green2"),
157 ctoggle(name="onoffv8", label="", init=1, stack=True, col="green2"),
158 cpoly()
159 ]
160