Debian Codegraph @

Resources/modules/Resonators&Verbs/DetunedResonators.c5

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