Debian Codegraph @

Resources/modules/Spectral/BinWarper.c5

raw
1 class Module(BaseModule):
2 """
3 "Phase vocoder buffer with bin independent speed playback"
4
5 Description
6
7 This module pre-analyses the input sound and keeps the
8 phase vocoder frames in a buffer for the playback. User
9 has control on playback position independently for every
10 frequency bin.
11
12 Sliders
13
14 # Low Bin Speed :
15 Lowest bin speed factor
16 # High Bin Speed :
17 Highest bin speed factor
18
19 * For random distribution, these values are the
20 minimum and the maximum of the distribution.
21
22 Graph Only
23
24 # Overall Amplitude :
25 The amplitude curve applied on the total duration of the performance
26
27 Popups & Toggles
28
29 # Reset :
30 Reset pointer positions to the beginning of the buffer.
31 # Speed Distribution :
32 Speed distribution algorithm.
33 # FFT Size :
34 Size, in samples, of the FFT
35 # FFT Envelope :
36 Windowing shape of the FFT
37 # FFT Overlaps :
38 Number of FFT overlaping analysis
39 # Polyphony Voices :
40 Number of voices played simultaneously (polyphony),
41 only available at initialization time
42 # Polyphony Spread :
43 Pitch variation between voices (chorus),
44 only available at initialization time
45
46 """
47 def __init__(self):
48 BaseModule.__init__(self)
49 self.snd = self.addSampler("snd")
50 snddur = self.getSamplerDur("snd")
51 self.server.startoffset = snddur
52
53 size = int(self.fftsize_value)
54 olaps = int(self.overlaps_value)
55 wintype = self.wtype_index
56 mode = self.mode_index
57
58 self.fin = PVAnal(self.snd, size=size, overlaps=olaps, wintype=wintype)
59 self.buf = PVBufLoops(self.fin, self.low, self.high, mode, length=snddur)
60 self.fout = PVSynth(self.buf, wintype=wintype, mul=self.env)
61
62 self.fade = SigTo(value=1, time=.05, init=1)
63 self.out = Sig(self.fout, mul=self.fade)
64
65 def reset(self, value):
66 if value:
67 self.buf.reset()
68
69 def mode(self, index, value):
70 self.buf.mode = index
71
72 def wtype(self, index, value):
73 self.fin.wintype = index
74 self.fout.wintype = index
75
76 Interface = [ csampler(name="snd"),
77 cgraph(name="env", label="Overall Amplitude", func=[(0,1),(1,1)], col="blue"),
78 cslider(name="low", label="Low Bin Speed", min=0, max=2, init=0.9, rel="lin", unit="x", col="green1"),
79 cslider(name="high", label="High Bin Speed", min=0, max=2, init=1.1, rel="lin", unit="x", col="green2"),
80 cbutton(name="reset", label="Reset", col="blue2"),
81 cpopup(name="mode", label="Speed Distribution", init="Linear", col="blue2",
82 value=["Linear", "Exponential", "Logarithmic", "Random", "Rand Exp Min", "Rand Exp Max", "Rand Bi-Exp"]),
83 cpopup(name="fftsize", label="FFT Size", init="1024", rate="i", value=["16", "32", "64", "128", "256", "512", "1024", "2048", "4096", "8192"], col="red"),
84 cpopup(name="wtype", label="FFT Envelope", init="Hanning", col="red", value=["Rectangular", "Hamming", "Hanning", "Bartlett",
85 "Blackman 3", "Blackman 4", "Blackman 7", "Tuckey", "Sine"]),
86 cpopup(name="overlaps", label="FFT Overlaps", rate="i", init="4", col="red", value=["1", "2", "4", "8", "16"]),
87 cpoly()
88 ]
89