class Module(BaseModule): """ "Spectral gate (Phase Vocoder)" Description For each frequency band of a phase vocoder analysis, if the amplitude of the bin falls below a given threshold, it is attenuated according to the `Gate Attenuation` parameter. Sliders # Gate Threshold : dB value at which the gate becomes active # Gate Attenuation : Gain in dB of the gated 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.snd = self.addSampler("snd") size = int(self.fftsize_value) olaps = int(self.overlaps_value) wintype = self.wtype_index self.fin = PVAnal(self.snd, size=size, overlaps=olaps, wintype=wintype) self.gate = PVGate(self.fin, thresh=self.gthresh, damp=DBToA(self.gatt)) self.fout = PVSynth(self.gate, wintype=wintype, mul=self.env) self.fade = SigTo(value=1, time=.05, init=1) self.out = Sig(self.fout, mul=self.fade) def fftsize(self, index, value): newsize = int(value) self.fade.value = 0 time.sleep(.05) self.fin.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.fin.overlaps = olaps time.sleep(.05) self.fade.value = 1 def wtype(self, index, value): self.fin.wintype = index self.fout.wintype = index Interface = [ csampler(name="snd"), cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"), cslider(name="gthresh", label="Gate Threshold", min=-120, max=0, init=-30, rel="lin", unit="db", col="orange"), cslider(name="gatt", label="Gate Attenuation", min=-120, max=0, init=-120, rel="lin", unit="db", col="purple1"), 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() ]