Debian Codegraph @

Resources/modules/Spectral/Morphing.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase Vocoder based morphing module"
4
5 Description
6
7 This module performs spectral morphing between two phase vocoder analysis.
8
9 According to `Morphing Index`, the amplitudes from two PV analysis
10 are interpolated linearly while the frequencies are interpolated
11 exponentially.
12
13 Sliders
14
15 # Morphing Index :
16 Morphing index between the two sources
17 # Dry / Wet :
18 Mix between the original signal and the morphed signal
19
20 Graph Only
21
22 # Overall Amplitude :
23 The amplitude curve applied on the total duration of the performance
24
25 Popups & Toggles
26
27 # FFT Size :
28 Size, in samples, of the FFT
29 # FFT Envelope :
30 Windowing shape of the FFT
31 # FFT Overlaps :
32 Number of FFT overlaping analysis
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.snd1 = self.addSampler("snd1", amp=.7)
44 self.snd2 = self.addSampler("snd2", amp=.7)
45
46 size = int(self.fftsize_value)
47 olaps = int(self.overlaps_value)
48 wintype = self.wtype_index
49 self.oneOverSr = 1.0 / self.sr
50
51 self.delsrc = Delay(self.snd1, delay=size*self.oneOverSr)
52
53 self.fin1 = PVAnal(self.snd1, size=size, overlaps=olaps, wintype=wintype)
54 self.fin2 = PVAnal(self.snd2, size=size, overlaps=olaps, wintype=wintype)
55 self.morph = PVMorph(self.fin1, self.fin2, self.interp)
56 self.fout = PVSynth(self.morph, wintype=wintype)
57
58 self.fade = SigTo(value=1, time=.05, init=1)
59 self.out = Interp(self.delsrc*self.env*0.5, self.fout*self.env, self.mix, mul=self.fade)
60
61 def fftsize(self, index, value):
62 newsize = int(value)
63 self.fade.value = 0
64 time.sleep(.05)
65 self.delsrc.delay = newsize*self.oneOverSr
66 self.fin1.size = newsize
67 self.fin2.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.fin1.overlaps = olaps
76 self.fin2.overlaps = olaps
77 time.sleep(.05)
78 self.fade.value = 1
79
80 def wtype(self, index, value):
81 self.fin1.wintype = index
82 self.fin2.wintype = index
83 self.fout.wintype = index
84
85 Interface = [ csampler(name="snd1", label="Source 1"),
86 csampler(name="snd2", label="Source 2"),
87 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
88 cslider(name="interp", label="Morphing Index", min=0, max=1, init=0.5, rel="lin", unit="x", col="green"),
89 cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
90 cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
91 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
92 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
93 cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]),
94 cpoly()
95 ]
96