Debian Codegraph @

Resources/modules/Spectral/SpectralDelay.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase vocoder spectral delay"
4
5 Description
6
7 This module applies different delay times and feedbacks for
8 each bin of a phase vocoder analysis. Delay times and
9 feedbacks are specified via grapher functions.
10
11 Sliders
12
13 # Max Delay :
14 Maximum delay time per bin. Used to allocate memories.
15 only available at initialization time
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 # Bin Delays :
24 Controls the delay time for every bin,
25 from left (low freq) to right (high freq) on the graph
26 # Bin Feedbacks :
27 Controls the feedback factor for every bin, from left to right on the graph
28
29 Popups & Toggles
30
31 # FFT Size :
32 Size, in samples, of the FFT
33 # FFT Envelope :
34 Windowing shape of the FFT
35 # FFT Overlaps :
36 Number of FFT overlaping analysis
37 # Polyphony Voices :
38 Number of voices played simultaneously (polyphony),
39 only available at initialization time
40 # Polyphony Spread :
41 Pitch variation between voices (chorus),
42 only available at initialization time
43
44 """
45 def __init__(self):
46 BaseModule.__init__(self)
47 self.snd = self.addSampler("snd")
48
49 self.size = int(self.fftsize_value)
50 self.olaps = int(self.overlaps_value)
51 wintype = self.wtype_index
52 self.oneOverSr = 1.0 / self.sr
53 frames = int(self.maxd.get() * self.sr / (self.size / self.olaps))
54
55 self.dtab = DataTable(size=8192)
56 self.tabscl = TableScale(self.delays, self.dtab, mul=frames)
57
58 self.delsrc = Delay(self.snd, delay=self.size*self.oneOverSr)
59
60 self.fin = PVAnal(self.snd, size=self.size, overlaps=self.olaps, wintype=wintype)
61 self.dls = PVDelay(self.fin, self.dtab, self.feeds, maxdelay=self.maxd.get(), mode=1)
62 self.fout = PVSynth(self.dls, wintype=wintype, mul=self.env)
63
64 self.fade = SigTo(value=1, time=.05, init=1)
65 self.out = Interp(self.delsrc*self.env, self.fout, self.mix, mul=self.fade)
66
67 def fftsize(self, index, value):
68 self.size = int(value)
69 self.fade.value = 0
70 time.sleep(.05)
71 self.delsrc.delay = self.size*self.oneOverSr
72 self.fin.size = self.size
73 frames = int(self.maxd.get() * self.sr / (self.size / self.olaps))
74 self.tabscl.mul = frames
75 time.sleep(.05)
76 self.fade.value = 1
77
78 def overlaps(self, index, value):
79 self.olaps = int(value)
80 self.fade.value = 0
81 time.sleep(.05)
82 self.fin.overlaps = self.olaps
83 frames = int(self.maxd.get() * self.sr / (self.size / self.olaps))
84 self.tabscl.mul = frames
85 time.sleep(.05)
86 self.fade.value = 1
87
88 def wtype(self, index, value):
89 self.fin.wintype = index
90 self.fout.wintype = index
91
92 def maxd_up(self, value):
93 pass
94
95 Interface = [ csampler(name="snd"),
96 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
97 cgraph(name="delays", label="Bin Delays", table=True, size=8192, func=[(0,0),(1,0.5)], col="green"),
98 cgraph(name="feeds", label="Bin Feedbacks", table=True, size=8192, func=[(0,0.25),(1,0.25)], col="orange"),
99 cslider(name="maxd", label="Max delay", min=0.1, max=20, init=5, rel="lin", unit="secs", up=True),
100 cslider(name="mix", label="Dry / Wet", min=0, max=1, init=1, rel="lin", unit="x", col="blue"),
101 cpopup(name="fftsize", label="FFT Size", init="1024", value=["64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
102 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
103 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
104 cpopup(name="overlaps", label="FFT Overlaps", init="4", value=["1", "2", "4", "8", "16"]),
105 cpoly()
106 ]
107