Debian Codegraph @

Resources/modules/Spectral/AddResynth.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase vocoder additive resynthesis"
4
5 Description
6
7 This module uses the magnitudes and true frequencies of a
8 phase vocoder analysis to control amplitudes and frequencies
9 envelopes of an oscillator bank.
10
11 Sliders
12
13 # Transpo :
14 Transposition factor
15 # Num of Oscs :
16 Number of oscillators used to synthesize the sound
17 # First bin :
18 First synthesized bin
19 # Increment :
20 Step between synthesized bins
21 # Dry / Wet :
22 Mix between the original signal and the processed signal
23
24 Graph Only
25
26 # Overall Amplitude :
27 The amplitude curve applied on the total duration of the performance
28
29 Popups & Toggles
30
31 # FFT Size :
32 Size, in samples, of the FFT
33 # FFT Envelope :
34 Windowing shape of the FFT
35 # FFT Overlaps :
36 Number of FFT overlaping analysis
37 # Polyphony Voices :
38 Number of voices played simultaneously (polyphony),
39 only available at initialization time
40 # Polyphony Spread :
41 Pitch variation between voices (chorus),
42 only available at initialization time
43
44 """
45 def __init__(self):
46 BaseModule.__init__(self)
47 self.snd = self.addSampler("snd")
48
49 size = int(self.fftsize_value)
50 olaps = int(self.overlaps_value)
51 wintype = self.wtype_index
52 self.oneOverSr = 1.0 / self.sr
53
54 self.delsrc = Delay(self.snd, delay=size*self.oneOverSr)
55
56 self.fin = PVAnal(self.snd, size=size, overlaps=olaps, wintype=wintype)
57 self.fout = PVAddSynth(self.fin, pitch=self.transpo, num=int(self.num.get()),
58 first=int(self.first.get()), inc=int(self.inc.get()))
59 self.fade = SigTo(value=1, time=.05, init=1)
60 self.out = Interp(self.delsrc*0.7, self.fout, self.mix, mul=self.fade*self.env)
61
62 def fftsize(self, index, value):
63 newsize = int(value)
64 self.fade.value = 0
65 time.sleep(.05)
66 self.delsrc.delay = newsize*self.oneOverSr
67 self.fin.size = newsize
68 time.sleep(.05)
69 self.fade.value = 1
70
71 def overlaps(self, index, value):
72 olaps = int(value)
73 self.fade.value = 0
74 time.sleep(.05)
75 self.fin.overlaps = olaps
76 time.sleep(.05)
77 self.fade.value = 1
78
79 def wtype(self, index, value):
80 self.fin.wintype = index
81
82 def num_up(self, value):
83 self.fout.num = int(value)
84
85 def first_up(self, value):
86 self.fout.first = int(value)
87
88 def inc_up(self, value):
89 self.fout.inc = int(value)
90
91 Interface = [ csampler(name="snd"),
92 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
93 cslider(name="transpo", label="Transpo", min=0.25, max=4, init=1, rel="lin", unit="x", col="green1"),
94 cslider(name="num", label="Num of Oscs", min=1, max=500, init=100, rel="lin", res="int", unit="x", up=True),
95 cslider(name="first", label="First bin", min=0, max=50, init=0, rel="lin", res="int", unit="x", up=True),
96 cslider(name="inc", label="Increment", min=1, max=25, init=1, rel="lin", res="int", unit="x", up=True),
97 cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
98 cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
99 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
100 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
101 cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]),
102 cpoly()
103 ]
104