Debian Codegraph @

Resources/modules/Pitch/Harmonizer.c5

raw
1 class Module(BaseModule):
2 """
3 "Two voices harmonization module"
4
5 Description
6
7 This module implements a two voices harmonization with independent feedback.
8
9 Sliders
10
11 # Transpo Voice 1 :
12 Pitch shift of the first voice
13 # Transpo Voice 2 :
14 Pitch shift of the second voice
15 # Feedback :
16 Amount of transposed signal fed back into the harmonizers (feedback is voice independent)
17 # Harm1 / Harm2 :
18 Mix between the first and the second harmonized signals
19 # Dry / Wet :
20 Mix between the original signal and the harmonized signals
21
22 Graph Only
23
24 # Overall Amplitude :
25 The amplitude curve applied on the total duration of the performance
26
27 Popups & Toggles
28
29 # Win Size Voice 1 :
30 Window size of the first harmonizer (delay) in second
31 # Win Size Voice 2 :
32 Window size of the second harmonizer (delay) in second
33 # Polyphony Voices :
34 Number of voices played simultaneously (polyphony),
35 only available at initialization time
36 # Polyphony Spread :
37 Pitch variation between voices (chorus),
38 only available at initialization time
39
40 """
41 def __init__(self):
42 BaseModule.__init__(self)
43 self.snd = self.addSampler("snd")
44 self.ws1 = float(self.winsize_value)
45 self.ws2 = float(self.winsize2_value)
46 self.avg_winsize = (self.ws1 + self.ws2) * 0.5
47 self.snd_del = Delay(self.snd, self.avg_winsize)
48 self.harm1 = Harmonizer(input=self.snd, transpo=self.transp1, feedback=self.fb, winsize=float(self.winsize_value), mul=.5)
49 self.harm2 = Harmonizer(input=self.snd, transpo=self.transp2, feedback=self.fb, winsize=float(self.winsize2_value), mul=.5)
50 self.harms = self.harm1 + (self.harm2 - self.harm1) * self.mix
51 self.dcb = DCBlock(self.harms)
52 self.out = Interp(self.snd_del, self.dcb, self.drywet, mul=self.env)
53
54 def winsize(self, index, value):
55 self.harm1.winsize = float(value)
56 self.ws1 = float(value)
57 self.avg_winsize = (self.ws1 + self.ws2) * 0.5
58 self.snd_del.delay = self.avg_winsize
59
60 def winsize2(self, index, value):
61 if index == 9:
62 self.harm2.winsize = float(self.winsize_value)+0.01
63 self.ws2 = float(self.winsize_value)+0.01
64 else:
65 self.harm2.winsize = float(value)
66 self.ws2 = float(value)
67 self.avg_winsize = (self.ws1 + self.ws2) * 0.5
68 self.snd_del.delay = self.avg_winsize
69
70 Interface = [ csampler(name="snd"),
71 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue1"),
72 cslider(name="transp1", label="Transpo Voice 1", min=-36, max=36, init=-7, rel="lin", unit="semi", col="red1"),
73 cslider(name="transp2", label="Transpo Voice 2", min=-36, max=36, init=3, rel="lin", unit="semi", col="red2"),
74 cslider(name="fb", label="Feedback", min=0, max=0.999, init=0, rel="lin", unit="x", col="orange1"),
75 cslider(name="mix", label="Harm1 / Harm2", min=0, max=1, init=.5, rel="lin", unit="x", col="green1"),
76 cslider(name="drywet", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue1"),
77 cpopup(name="winsize", label="Win Size Voice 1", init="0.1", col="red1",
78 value=["0.025","0.05","0.1","0.15","0.2","0.25","0.5","0.75","1"]),
79 cpopup(name="winsize2", label="Win Size Voice 2", init="0.1", col="red2",
80 value=["0.025","0.05","0.1","0.15","0.2","0.25","0.5","0.75","1","Voice 1 + 0.01"]),
81 cpoly()
82 ]