class Module(BaseModule): """ "Phase Vocoder based morphing module" Description This module performs spectral morphing between two phase vocoder analysis. According to `Morphing Index`, the amplitudes from two PV analysis are interpolated linearly while the frequencies are interpolated exponentially. Sliders # Morphing Index : Morphing index between the two sources # Dry / Wet : Mix between the original signal and the morphed signal Graph Only # Overall Amplitude : The amplitude curve applied on the total duration of the performance Popups & Toggles # FFT Size : Size, in samples, of the FFT # FFT Envelope : Windowing shape of the FFT # FFT Overlaps : Number of FFT overlaping analysis # Polyphony Voices : Number of voices played simultaneously (polyphony), only available at initialization time # Polyphony Spread : Pitch variation between voices (chorus), only available at initialization time """ def __init__(self): BaseModule.__init__(self) self.snd1 = self.addSampler("snd1", amp=.7) self.snd2 = self.addSampler("snd2", amp=.7) size = int(self.fftsize_value) olaps = int(self.overlaps_value) wintype = self.wtype_index self.oneOverSr = 1.0 / self.sr self.delsrc = Delay(self.snd1, delay=size*self.oneOverSr) self.fin1 = PVAnal(self.snd1, size=size, overlaps=olaps, wintype=wintype) self.fin2 = PVAnal(self.snd2, size=size, overlaps=olaps, wintype=wintype) self.morph = PVMorph(self.fin1, self.fin2, self.interp) self.fout = PVSynth(self.morph, wintype=wintype) self.fade = SigTo(value=1, time=.05, init=1) self.out = Interp(self.delsrc*self.env*0.5, self.fout*self.env, self.mix, mul=self.fade) def fftsize(self, index, value): newsize = int(value) self.fade.value = 0 time.sleep(.05) self.delsrc.delay = newsize*self.oneOverSr self.fin1.size = newsize self.fin2.size = newsize time.sleep(.05) self.fade.value = 1 def overlaps(self, index, value): olaps = int(value) self.fade.value = 0 time.sleep(.05) self.fin1.overlaps = olaps self.fin2.overlaps = olaps time.sleep(.05) self.fade.value = 1 def wtype(self, index, value): self.fin1.wintype = index self.fin2.wintype = index self.fout.wintype = index Interface = [ csampler(name="snd1", label="Source 1"), csampler(name="snd2", label="Source 2"), cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"), cslider(name="interp", label="Morphing Index", min=0, max=1, init=0.5, rel="lin", unit="x", col="green"), cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"), cpopup(name="fftsize", label="FFT Size", init="1024", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"), cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett", "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]), cpopup(name="overlaps", label="FFT Overlaps", init="4", col="red", value=["1", "2", "4", "8", "16"]), cpoly() ]