-
Notifications
You must be signed in to change notification settings - Fork 7
/
pv_worker3.js
47 lines (32 loc) · 1.06 KB
/
pv_worker3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// importScript("PV.js");
// importScript("jensnockert-fft.js/lib/complex.js");
// importScript("jensnockert-fft.js/lib/real.js");
var BUFFER_SIZE = 2048;
var phasevocoderL = new PhaseVocoder(BUFFER_SIZE, 44100);
phasevocoderL.init();
var phasevocoderR = new PhaseVocoder(BUFFER_SIZE, 44100);
phasevocoderR.init();
var outBufferL = [];
var outBufferR = [];
console.log("configurado");
// Parameters: alpha
onaudioprocess = function (e) {
var il = e.inputBuffers[0];
var ir = e.inputBuffers[0];
var ol = e.outputBuffers[0];
var or = e.outputBuffers[1];
var alpha = e.parameters.alpha[0];
phasevocoderL.set_alpha(alpha);
phasevocoderR.set_alpha(alpha);
do {
outBufferL = outBufferL.concat(phasevocoderL.process(il));
outBufferR = outBufferR.concat(phasevocoderR.process(ir));
} while (outBufferL.length < BUFFER_SIZE);
// console.log("done");
for (var i = 0; i < BUFFER_SIZE; i++) {
ol[i] = outBufferL.shift();
or[i] = outBufferR.shift();
// console.log([i, ol[i], or[i]]);
}
// console.log("pv_worker3");
};