Debian Codegraph @

Resources/modules/Spectral/CrossSynth2.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase Vocoder based cross synthesis module"
4
5 Description
6
7 Performs cross-synthesis between two phase vocoder streaming objects.
8
9 The amplitudes from `Source Exciter` and `Spectral Envelope`, scaled
10 by `Crossing Index`, are applied to the frequencies of `Source Exciter`.
11
12 Sliders
13
14 # Crossing Index :
15 Morphing index between the two source's magnitudes
16 # Exc Pre Filter Freq :
17 Frequency of the pre-FFT filter
18 # Exc Pre Filter Q :
19 Q of the pre-FFT filter
20 # Dry / Wet :
21 Mix between the original signal and the processed signal
22
23 Graph Only
24
25 # Overall Amplitude :
26 The amplitude curve applied on the total duration of the performance
27
28 Popups & Toggles
29
30 # Exc Pre Filter Type :
31 Type of the pre-FFT filter
32 # FFT Size :
33 Size, in samples, of the FFT
34 # FFT Envelope :
35 Windowing shape of the FFT
36 # FFT Overlaps :
37 Number of FFT overlaping analysis
38 # Polyphony Voices :
39 Number of voices played simultaneously (polyphony),
40 only available at initialization time
41 # Polyphony Spread :
42 Pitch variation between voices (chorus),
43 only available at initialization time
44
45 """
46 def __init__(self):
47 BaseModule.__init__(self)
48 self.snd1 = self.addSampler("snd1")
49 self.snd2 = self.addSampler("snd2")
50 self.snd2_filt = Biquadx(self.snd2, freq=self.prefiltf, q=self.prefiltq, type=self.prefilttype_index, stages=2)
51
52 size = int(self.fftsize_value)
53 olaps = int(self.overlaps_value)
54 wintype = self.wtype_index
55 self.oneOverSr = 1.0 / self.sr
56
57 self.delsrc = Delay(self.snd1, delay=size*self.oneOverSr)
58
59 self.fin1 = PVAnal(self.snd1, size=size, overlaps=olaps, wintype=wintype)
60 self.fin2 = PVAnal(self.snd2_filt, size=size, overlaps=olaps, wintype=wintype)
61
62 self.cross = PVCross(self.fin2, self.fin1, self.interp)
63 self.fout = PVSynth(self.cross, wintype=wintype, mul=1)
64
65 self.fade = SigTo(value=1, time=.03, init=1)
66 self.out = Interp(self.delsrc*self.env*0.5, self.fout*self.env, self.mix, mul=self.fade)
67
68 def prefilttype(self, index, value):
69 self.snd2_filt.type = index
70
71 def fftsize(self, index, value):
72 newsize = int(value)
73 self.fade.value = 0
74 time.sleep(.05)
75 self.delsrc.delay = newsize*self.oneOverSr
76 self.fin1.size = newsize
77 self.fin2.size = newsize
78 time.sleep(.05)
79 self.fade.value = 1
80
81 def overlaps(self, index, value):
82 olaps = int(value)
83 self.fade.value = 0
84 time.sleep(.05)
85 self.fin1.overlaps = olaps
86 self.fin2.overlaps = olaps
87 time.sleep(.05)
88 self.fade.value = 1
89
90 def wtype(self, index, value):
91 self.fin1.wintype = index
92 self.fin2.wintype = index
93 self.fout.wintype = index
94
95 Interface = [ csampler(name="snd1", label="Spectral Envelope"),
96 csampler(name="snd2", label="Source Exciter"),
97 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
98 cslider(name="interp", label="Crossing Index", min=0, max=1, init=1, rel="lin", unit="x", col="red"),
99 cslider(name="prefiltf", label="Exc Pre Filter Freq", min=40, max=18000, init=150, rel="log", unit="Hz", col="green"),
100 cslider(name="prefiltq", label="Exc Pre Filter Q", min=.5, max=10, init=0.707, rel="log", col="green"),
101 cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
102 cpopup(name="prefilttype", label="Exc Pre Filter Type", init="Highpass", col="green", value=["Lowpass","Highpass","Bandpass","Bandstop"]),
103 cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
104 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
105 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
106 cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]),
107 cpoly()
108 ]
109