Debian Codegraph @

Resources/modules/Spectral/CrossSynth.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase Vocoder based cross synthesis module"
4
5 Description
6
7 Multiplication of magnitudes from two phase vocoder streaming objects.
8
9 Sliders
10
11 # Exciter Pre Filter Freq :
12 Frequency of the pre-FFT filter
13 # Exciter Pre Filter Q :
14 Q of the pre-FFT filter
15 # Dry / Wet :
16 Mix between the original signal and the processed signal
17
18 Graph Only
19
20 # Overall Amplitude :
21 The amplitude curve applied on the total duration of the performance
22
23 Popups & Toggles
24
25 # Exc Pre Filter Type :
26 Type of the pre-FFT filter
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")
44 self.snd2 = self.addSampler("snd2")
45 self.snd2_filt = Biquadx(self.snd2, freq=self.prefiltf, q=self.prefiltq, type=self.prefilttype_index, stages=2)
46
47 size = int(self.fftsize_value)
48 olaps = int(self.overlaps_value)
49 wintype = self.wtype_index
50 self.oneOverSr = 1.0 / self.sr
51
52 self.delsrc = Delay(self.snd1, delay=size*self.oneOverSr)
53
54 self.fin1 = PVAnal(self.snd1, size=size, overlaps=olaps, wintype=wintype)
55 self.fin2 = PVAnal(self.snd2_filt, size=size, overlaps=olaps, wintype=wintype)
56
57 self.cross = PVMult(self.fin1, self.fin2)
58 self.fout = PVSynth(self.cross, wintype=wintype, mul=4)
59
60 self.fade = SigTo(value=1, time=.03, init=1)
61 self.out = Interp(self.delsrc*self.env*0.5, self.fout*self.env, self.mix, mul=self.fade)
62
63 def prefilttype(self, index, value):
64 self.snd2_filt.type = index
65
66 def fftsize(self, index, value):
67 newsize = int(value)
68 self.fade.value = 0
69 time.sleep(.05)
70 self.delsrc.delay = newsize*self.oneOverSr
71 self.fin1.size = newsize
72 self.fin2.size = newsize
73 time.sleep(.05)
74 self.fade.value = 1
75
76 def overlaps(self, index, value):
77 olaps = int(value)
78 self.fade.value = 0
79 time.sleep(.05)
80 self.fin1.overlaps = olaps
81 self.fin2.overlaps = olaps
82 time.sleep(.05)
83 self.fade.value = 1
84
85 def wtype(self, index, value):
86 self.fin1.wintype = index
87 self.fin2.wintype = index
88 self.fout.wintype = index
89
90 Interface = [ csampler(name="snd1", label="Spectral Envelope"),
91 csampler(name="snd2", label="Source Exciter"),
92 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
93 cslider(name="prefiltf", label="Exc Pre Filter Freq", min=40, max=18000, init=150, rel="log", unit="Hz", col="green"),
94 cslider(name="prefiltq", label="Exc Pre Filter Q", min=.5, max=10, init=0.707, rel="log", col="green"),
95 cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
96 cpopup(name="prefilttype", label="Exc Pre Filter Type", init="Highpass", col="green", value=["Lowpass","Highpass","Bandpass","Bandstop"]),
97 cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
98 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
99 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
100 cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]),
101 cpoly()
102 ]
103