Debian Codegraph @

Resources/modules/Pitch/ChordMaker.c5

raw
1 class Module(BaseModule):
2 """
3 "Sampler-based harmonizer module with multiple voices"
4
5 Description
6
7 The input sound is mixed with five real-time, non-stretching,
8 harmonization voices.
9
10 Sliders
11
12 # Transpo Voice 1 :
13 Pitch shift of the first voice
14 # Gain Voice 1 :
15 Gain of the transposed first voice
16 # Transpo Voice 2 :
17 Pitch shift of the second voice
18 # Gain Voice 2 :
19 Gain of the transposed second voice
20 # Transpo Voice 3 :
21 Pitch shift of the third voice
22 # Gain Voice 3 :
23 Gain of the transposed third voice
24 # Transpo Voice 4 :
25 Pitch shift of the fourth voice
26 # Gain Voice 4 :
27 Gain of the transposed fourth voice
28 # Transpo Voice 5 :
29 Pitch shift of the fifth voice
30 # Gain Voice 5 :
31 Gain of the transposed fifth voice
32 # Feedback :
33 Amount of transposed signal fed back into the harmonizers
34 (feedback is voice independent)
35 # Dry / Wet :
36 Mix between the original signal and the harmonized signals
37
38 Graph Only
39
40 # Overall Amplitude :
41 The amplitude curve applied on the total duration of the performance
42
43 Popups & Toggles
44
45 # Win Size :
46 Harmonizer window size in seconds
47 # Balance :
48 Compression mode. Off, balanced with a fixed signal
49 or balanced with the input source.
50 # Voice Activation (1 --> 5)
51 Mute or unmute each voice independently
52 # Polyphony Voices :
53 Number of voices played simultaneously (polyphony),
54 only available at initialization time
55 # Polyphony Spread :
56 Pitch variation between voices (chorus),
57 only available at initialization time
58
59 """
60 def __init__(self):
61 BaseModule.__init__(self)
62 self.snd = self.addSampler("snd")
63 self.mul1 = DBToA(self.gain1, mul=self.onoffv1_value)
64 self.mul2 = DBToA(self.gain2, mul=self.onoffv2_value)
65 self.mul3 = DBToA(self.gain3, mul=self.onoffv3_value)
66 self.mul4 = DBToA(self.gain4, mul=self.onoffv4_value)
67 self.mul5 = DBToA(self.gain5, mul=self.onoffv5_value)
68 self.harm1 = Harmonizer(input=self.snd, transpo=self.transp1, feedback=self.fb, winsize=float(self.winsize_value), mul=self.mul1*0.3)
69 self.harm2 = Harmonizer(input=self.snd, transpo=self.transp2, feedback=self.fb, winsize=float(self.winsize_value), mul=self.mul2*0.3)
70 self.harm3 = Harmonizer(input=self.snd, transpo=self.transp3, feedback=self.fb, winsize=float(self.winsize_value), mul=self.mul3*0.3)
71 self.harm4 = Harmonizer(input=self.snd, transpo=self.transp4, feedback=self.fb, winsize=float(self.winsize_value), mul=self.mul4*0.3)
72 self.harm5 = Harmonizer(input=self.snd, transpo=self.transp5, feedback=self.fb, winsize=float(self.winsize_value), mul=self.mul5*0.3)
73 self.harms = self.harm1+self.harm2+self.harm3+self.harm4+self.harm5
74 self.drydel = Delay(self.snd, delay=float(self.winsize_value)*0.5)
75 self.deg = Interp(self.drydel, self.harms, self.drywet, mul=self.env)
76
77 self.osc = Sine(10000,mul=.1)
78 self.balanced = Balance(self.deg, self.osc, freq=10)
79 self.out = Interp(self.deg, self.balanced)
80
81 #INIT
82 self.balance(self.balance_index, self.balance_value)
83
84 def balance(self,index,value):
85 if index == 0:
86 self.out.interp = 0
87 elif index ==1:
88 self.out.interp = 1
89 self.balanced.input2 = self.osc
90 elif index == 2:
91 self.out.interp = 1
92 self.balanced.input2 = self.snd
93
94 def winsize(self, index, value):
95 self.harm1.winsize = float(value)
96 self.harm2.winsize = float(value)
97 self.harm3.winsize = float(value)
98 self.harm4.winsize = float(value)
99 self.harm5.winsize = float(value)
100 self.drydel.delay = float(value)*0.5
101
102 def onoffv1(self, value):
103 self.mul1.mul = value
104
105 def onoffv2(self, value):
106 self.mul2.mul = value
107
108 def onoffv3(self, value):
109 self.mul3.mul = value
110
111 def onoffv4(self, value):
112 self.mul4.mul = value
113
114 def onoffv5(self, value):
115 self.mul5.mul = value
116
117 Interface = [ csampler(name="snd"),
118 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"),
119 cslider(name="transp1", label="Transpo Voice 1", min=-24, max=24, init=0, rel="lin", unit="semi", col="red1",half=True),
120 cslider(name="gain1", label="Gain Voice 1", min=-48, max=18, init=0, rel="lin", unit="dB", col="red2",half=True),
121 cslider(name="transp2", label="Transpo Voice 2", min=-24, max=24, init=3, rel="lin", unit="semi", col="purple1",half=True),
122 cslider(name="gain2", label="Gain Voice 2", min=-48, max=18, init=0, rel="lin", unit="dB", col="purple2",half=True),
123 cslider(name="transp3", label="Transpo Voice 3", min=-24, max=24, init=5, rel="lin", unit="semi", col="orange1",half=True),
124 cslider(name="gain3", label="Gain Voice 3", min=-48, max=18, init=0, rel="lin", unit="dB", col="orange2",half=True),
125 cslider(name="transp4", label="Transpo Voice 4", min=-24, max=24, init=-2, rel="lin", unit="semi", col="blue2",half=True),
126 cslider(name="gain4", label="Gain Voice 4", min=-48, max=18, init=0, rel="lin", unit="dB", col="blue3",half=True),
127 cslider(name="transp5", label="Transpo Voice 5", min=-24, max=24, init=-4, rel="lin", unit="semi", col="green1",half=True),
128 cslider(name="gain5", label="Gain Voice 5", min=-48, max=18, init=0, rel="lin", unit="dB", col="green2",half=True),
129 cslider(name="fb", label="Feedback", min=0, max=0.999, init=0, rel="lin", unit="x", col="orange1"),
130 cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue1"),
131 cpopup(name="winsize", label="Win Size", init="0.1", col="blue4", value=["0.025","0.05","0.1","0.15","0.2","0.25","0.5","0.75","1"]),
132 cpopup(name="balance", label = "Balance", init= "Off", col="blue1", value=["Off","Compress", "Source"]),
133 ctoggle(name="onoffv1", label="Voice Activation ( 1 --> 5 )", init=1, stack=True, col="green1"),
134 ctoggle(name="onoffv2", label="", init=1, stack=True, col="green1"),
135 ctoggle(name="onoffv3", label="", init=1, stack=True, col="green1"),
136 ctoggle(name="onoffv4", label="", init=1, stack=True, col="green1"),
137 ctoggle(name="onoffv5", label="", init=1, stack=True, col="green1"),
138 cpoly()
139 ]
140