| 1 |
class Module(BaseModule): |
| 2 |
""" |
| 3 |
"Phase Vocoder based two voices transposer" |
| 4 |
|
| 5 |
Description |
| 6 |
|
| 7 |
This module transpose the frequency components of a phase |
| 8 |
vocoder analysis. |
| 9 |
|
| 10 |
Sliders |
| 11 |
|
| 12 |
# Transpo 1 : |
| 13 |
Transposition factor of the first voice |
| 14 |
# Transpo 2 : |
| 15 |
Transposition factor of the second voice |
| 16 |
# Dry / Wet : |
| 17 |
Mix between the original signal and the delayed signals |
| 18 |
|
| 19 |
Graph Only |
| 20 |
|
| 21 |
# Overall Amplitude : |
| 22 |
The amplitude curve applied on the total duration of the performance |
| 23 |
|
| 24 |
Popups & Toggles |
| 25 |
|
| 26 |
# FFT Size : |
| 27 |
Size, in samples, of the FFT |
| 28 |
# FFT Envelope : |
| 29 |
Windowing shape of the FFT |
| 30 |
# FFT Overlaps : |
| 31 |
Number of FFT overlaping analysis |
| 32 |
# Polyphony Voices : |
| 33 |
Number of voices played simultaneously (polyphony), |
| 34 |
only available at initialization time |
| 35 |
# Polyphony Spread : |
| 36 |
Pitch variation between voices (chorus), |
| 37 |
only available at initialization time |
| 38 |
|
| 39 |
""" |
| 40 |
def __init__(self): |
| 41 |
BaseModule.__init__(self) |
| 42 |
self.snd = self.addSampler("snd") |
| 43 |
|
| 44 |
size = int(self.fftsize_value) |
| 45 |
olaps = int(self.overlaps_value) |
| 46 |
wintype = self.wtype_index |
| 47 |
self.oneOverSr = 1.0 / self.sr |
| 48 |
|
| 49 |
self.delsrc = Delay(self.snd, delay=size*self.oneOverSr) |
| 50 |
|
| 51 |
self.fin = PVAnal(self.snd, size=size, overlaps=olaps, wintype=wintype) |
| 52 |
self.tr1 = PVTranspose(self.fin, transpo=CentsToTranspo(self.transpo1)) |
| 53 |
self.tr2 = PVTranspose(self.fin, transpo=CentsToTranspo(self.transpo2)) |
| 54 |
self.fout1 = PVSynth(self.tr1, wintype=wintype) |
| 55 |
self.fout2 = PVSynth(self.tr2, wintype=wintype) |
| 56 |
self.fout = self.fout1 + self.fout2 |
| 57 |
self.fade = SigTo(value=1, time=.05, init=1) |
| 58 |
self.out = Interp(self.delsrc*0.5, self.fout*0.4, self.mix, mul=self.fade*self.env) |
| 59 |
|
| 60 |
def fftsize(self, index, value): |
| 61 |
newsize = int(value) |
| 62 |
self.fade.value = 0 |
| 63 |
time.sleep(.05) |
| 64 |
self.delsrc.delay = newsize*self.oneOverSr |
| 65 |
self.fin.size = newsize |
| 66 |
time.sleep(.05) |
| 67 |
self.fade.value = 1 |
| 68 |
|
| 69 |
def overlaps(self, index, value): |
| 70 |
olaps = int(value) |
| 71 |
self.fade.value = 0 |
| 72 |
time.sleep(.05) |
| 73 |
self.fin.overlaps = olaps |
| 74 |
time.sleep(.05) |
| 75 |
self.fade.value = 1 |
| 76 |
|
| 77 |
def wtype(self, index, value): |
| 78 |
self.fin.wintype = index |
| 79 |
self.fout.wintype = index |
| 80 |
|
| 81 |
Interface = [ csampler(name="snd"), |
| 82 |
cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"), |
| 83 |
cslider(name="transpo1", label="Transpo 1", min=-2400, max=2400, init=-200, rel="lin", unit="cts", col="green1"), |
| 84 |
cslider(name="transpo2", label="Transpo 2", min=-2400, max=2400, init=300, rel="lin", unit="cts", col="green2"), |
| 85 |
cslider(name="mix", label="Dry / Wet", min=0, max=1, init=0.5, rel="lin", unit="x", col="blue"), |
| 86 |
cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"), |
| 87 |
cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett", |
| 88 |
"Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]), |
| 89 |
cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]), |
| 90 |
cpoly() |
| 91 |
] |
| 92 |
|