@buffered-audio/nodes 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1825 -26
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7,11 +7,1807 @@ import { EventEmitter } from 'events';
|
|
|
7
7
|
import { spawn } from 'child_process';
|
|
8
8
|
import { createRequire } from 'module';
|
|
9
9
|
|
|
10
|
+
var __create = Object.create;
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
};
|
|
11
19
|
var __export = (target, all) => {
|
|
12
20
|
for (var name in all)
|
|
13
21
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
22
|
};
|
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(from))
|
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
28
|
+
}
|
|
29
|
+
return to;
|
|
30
|
+
};
|
|
31
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
32
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
33
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
34
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
35
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
36
|
+
__defProp(target, "default", { value: mod, enumerable: true }) ,
|
|
37
|
+
mod
|
|
38
|
+
));
|
|
39
|
+
|
|
40
|
+
// ../../node_modules/wavefile/dist/wavefile.js
|
|
41
|
+
var require_wavefile = __commonJS({
|
|
42
|
+
"../../node_modules/wavefile/dist/wavefile.js"(exports$1, module) {
|
|
43
|
+
try {
|
|
44
|
+
if (!Uint8Array.prototype.slice) Object.defineProperty(Uint8Array.prototype, "slice", { value: function(begin, end) {
|
|
45
|
+
return new Uint8Array(Array.prototype.slice.call(this, begin, end));
|
|
46
|
+
} });
|
|
47
|
+
} catch (err) {
|
|
48
|
+
}
|
|
49
|
+
var ka = "function" == typeof Object.create ? Object.create : function(n) {
|
|
50
|
+
function m() {
|
|
51
|
+
}
|
|
52
|
+
m.prototype = n;
|
|
53
|
+
return new m();
|
|
54
|
+
};
|
|
55
|
+
var D;
|
|
56
|
+
if ("function" == typeof Object.setPrototypeOf) D = Object.setPrototypeOf;
|
|
57
|
+
else {
|
|
58
|
+
a: {
|
|
59
|
+
la = { D: true }, N = {};
|
|
60
|
+
try {
|
|
61
|
+
N.__proto__ = la;
|
|
62
|
+
K = N.D;
|
|
63
|
+
break a;
|
|
64
|
+
} catch (n) {
|
|
65
|
+
}
|
|
66
|
+
K = false;
|
|
67
|
+
}
|
|
68
|
+
D = K ? function(n, m) {
|
|
69
|
+
n.__proto__ = m;
|
|
70
|
+
if (n.__proto__ !== m) throw new TypeError(n + " is not extensible");
|
|
71
|
+
return n;
|
|
72
|
+
} : null;
|
|
73
|
+
}
|
|
74
|
+
var K;
|
|
75
|
+
var la;
|
|
76
|
+
var N;
|
|
77
|
+
var O = D;
|
|
78
|
+
function P(n, m) {
|
|
79
|
+
n.prototype = ka(m.prototype);
|
|
80
|
+
n.prototype.constructor = n;
|
|
81
|
+
if (O) O(n, m);
|
|
82
|
+
else for (var l in m) if ("prototype" != l) if (Object.defineProperties) {
|
|
83
|
+
var p = Object.getOwnPropertyDescriptor(m, l);
|
|
84
|
+
p && Object.defineProperty(n, l, p);
|
|
85
|
+
} else n[l] = m[l];
|
|
86
|
+
}
|
|
87
|
+
var ma = "function" == typeof Object.defineProperties ? Object.defineProperty : function(n, m, l) {
|
|
88
|
+
n != Array.prototype && n != Object.prototype && (n[m] = l.value);
|
|
89
|
+
};
|
|
90
|
+
var na = "undefined" != typeof window && window === exports$1 ? exports$1 : "undefined" != typeof global && null != global ? global : exports$1;
|
|
91
|
+
function Q(n, m) {
|
|
92
|
+
if (m) {
|
|
93
|
+
for (var l = na, p = n.split("."), y = 0; y < p.length - 1; y++) {
|
|
94
|
+
var v = p[y];
|
|
95
|
+
v in l || (l[v] = {});
|
|
96
|
+
l = l[v];
|
|
97
|
+
}
|
|
98
|
+
p = p[p.length - 1];
|
|
99
|
+
y = l[p];
|
|
100
|
+
v = m(y);
|
|
101
|
+
v != y && null != v && ma(l, p, { configurable: true, writable: true, value: v });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
Q("Object.is", function(n) {
|
|
105
|
+
return n ? n : function(m, l) {
|
|
106
|
+
return m === l ? 0 !== m || 1 / m === 1 / l : m !== m && l !== l;
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
Q("Array.prototype.includes", function(n) {
|
|
110
|
+
return n ? n : function(m, l) {
|
|
111
|
+
var p = this;
|
|
112
|
+
p instanceof String && (p = String(p));
|
|
113
|
+
var y = p.length, v = l || 0;
|
|
114
|
+
for (0 > v && (v = Math.max(v + y, 0)); v < y; v++) {
|
|
115
|
+
var w = p[v];
|
|
116
|
+
if (w === m || Object.is(w, m)) return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
Q("String.prototype.codePointAt", function(n) {
|
|
122
|
+
return n ? n : function(m) {
|
|
123
|
+
if (null == this) throw new TypeError("The 'this' value for String.prototype.codePointAt must not be null or undefined");
|
|
124
|
+
var l = this.length;
|
|
125
|
+
m = Number(m) || 0;
|
|
126
|
+
if (0 <= m && m < l) {
|
|
127
|
+
m |= 0;
|
|
128
|
+
var p = this.charCodeAt(m);
|
|
129
|
+
if (55296 > p || 56319 < p || m + 1 === l) return p;
|
|
130
|
+
m = this.charCodeAt(m + 1);
|
|
131
|
+
return 56320 > m || 57343 < m ? p : 1024 * (p - 55296) + m + 9216;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
var oa = "function" == typeof Object.assign ? Object.assign : function(n, m) {
|
|
136
|
+
for (var l = 1; l < arguments.length; l++) {
|
|
137
|
+
var p = arguments[l];
|
|
138
|
+
if (p) for (var y in p) Object.prototype.hasOwnProperty.call(p, y) && (n[y] = p[y]);
|
|
139
|
+
}
|
|
140
|
+
return n;
|
|
141
|
+
};
|
|
142
|
+
Q("Object.assign", function(n) {
|
|
143
|
+
return n || oa;
|
|
144
|
+
});
|
|
145
|
+
var V = exports$1;
|
|
146
|
+
function W(n) {
|
|
147
|
+
function m(a) {
|
|
148
|
+
var b = l.call(this) || this;
|
|
149
|
+
a && b.fromBuffer(a);
|
|
150
|
+
return b;
|
|
151
|
+
}
|
|
152
|
+
function l() {
|
|
153
|
+
return w.apply(this, arguments) || this;
|
|
154
|
+
}
|
|
155
|
+
function p(a, b, c) {
|
|
156
|
+
for (var d = [], e = 0; e < a; e++) d.push(this.b({ pa: b, oa: c, Q: 0.5 / Math.sin(Math.PI / (2 * a) * (e + 0.5)) }));
|
|
157
|
+
this.a = [];
|
|
158
|
+
for (a = 0; a < d.length; a++) this.a[a] = { Ka: d[a].A[0], La: d[a].A[1], Ma: d[a].A[2], Ha: d[a].D[0], Ia: d[a].D[1], k: d[a].k, z: [0, 0] };
|
|
159
|
+
}
|
|
160
|
+
function y(a, b, c) {
|
|
161
|
+
c = 2 * Math.PI * c / b;
|
|
162
|
+
b = 0;
|
|
163
|
+
this.a = [];
|
|
164
|
+
for (var d = 0; d <= a; d++) 0 === d - a / 2 ? this.a[d] = c : (this.a[d] = Math.sin(c * (d - a / 2)) / (d - a / 2), this.a[d] *= 0.54 - 0.46 * Math.cos(2 * Math.PI * d / a)), b += this.a[d];
|
|
165
|
+
for (c = 0; c <= a; c++) this.a[c] /= b;
|
|
166
|
+
this.z = this.b();
|
|
167
|
+
}
|
|
168
|
+
function v(a, b, c) {
|
|
169
|
+
this.C = a;
|
|
170
|
+
this.l = (a - 1) / b;
|
|
171
|
+
this.M = this.I;
|
|
172
|
+
"point" === c.method ? this.M = this.H : "linear" === c.method ? this.M = this.G : "cubic" === c.method && (this.M = this.B);
|
|
173
|
+
this.J = 1 - Math.max(0, Math.min(1, c.tension || 0));
|
|
174
|
+
this.v = c.sincFilterSize || 1;
|
|
175
|
+
this.F = pa(c.sincWindow || qa);
|
|
176
|
+
}
|
|
177
|
+
function w() {
|
|
178
|
+
return C.apply(this, arguments) || this;
|
|
179
|
+
}
|
|
180
|
+
function C() {
|
|
181
|
+
return t.apply(this, arguments) || this;
|
|
182
|
+
}
|
|
183
|
+
function t() {
|
|
184
|
+
var a = q.call(this) || this;
|
|
185
|
+
a.bitDepth = "0";
|
|
186
|
+
a.f = { h: 0, o: false };
|
|
187
|
+
a.G = { 4: 17, 8: 1, "8a": 6, "8m": 7, 16: 1, 24: 1, 32: 1, "32f": 3, 64: 3 };
|
|
188
|
+
return a;
|
|
189
|
+
}
|
|
190
|
+
function q() {
|
|
191
|
+
return u.apply(this, arguments) || this;
|
|
192
|
+
}
|
|
193
|
+
function u() {
|
|
194
|
+
var a = B.call(this) || this;
|
|
195
|
+
a.Z.push("RF64");
|
|
196
|
+
a.fmt = { chunkId: "", chunkSize: 0, audioFormat: 0, numChannels: 0, sampleRate: 0, byteRate: 0, blockAlign: 0, bitsPerSample: 0, cbSize: 0, validBitsPerSample: 0, dwChannelMask: 0, subformat: [] };
|
|
197
|
+
a.fact = { chunkId: "", chunkSize: 0, dwSampleLength: 0 };
|
|
198
|
+
a.cue = { chunkId: "", chunkSize: 0, dwCuePoints: 0, points: [] };
|
|
199
|
+
a.smpl = {
|
|
200
|
+
chunkId: "",
|
|
201
|
+
chunkSize: 0,
|
|
202
|
+
dwManufacturer: 0,
|
|
203
|
+
dwProduct: 0,
|
|
204
|
+
dwSamplePeriod: 0,
|
|
205
|
+
dwMIDIUnityNote: 0,
|
|
206
|
+
dwMIDIPitchFraction: 0,
|
|
207
|
+
dwSMPTEFormat: 0,
|
|
208
|
+
dwSMPTEOffset: 0,
|
|
209
|
+
dwNumSampleLoops: 0,
|
|
210
|
+
dwSamplerData: 0,
|
|
211
|
+
loops: []
|
|
212
|
+
};
|
|
213
|
+
a.bext = { chunkId: "", chunkSize: 0, description: "", originator: "", originatorReference: "", originationDate: "", originationTime: "", timeReference: [0, 0], version: 0, UMID: "", loudnessValue: 0, loudnessRange: 0, maxTruePeakLevel: 0, maxMomentaryLoudness: 0, maxShortTermLoudness: 0, reserved: "", codingHistory: "" };
|
|
214
|
+
a.iXML = { chunkId: "", chunkSize: 0, value: "" };
|
|
215
|
+
a.ds64 = {
|
|
216
|
+
chunkId: "",
|
|
217
|
+
chunkSize: 0,
|
|
218
|
+
riffSizeHigh: 0,
|
|
219
|
+
riffSizeLow: 0,
|
|
220
|
+
dataSizeHigh: 0,
|
|
221
|
+
dataSizeLow: 0,
|
|
222
|
+
originationTime: 0,
|
|
223
|
+
sampleCountHigh: 0,
|
|
224
|
+
sampleCountLow: 0
|
|
225
|
+
};
|
|
226
|
+
a.data = { chunkId: "", chunkSize: 0, samples: new Uint8Array(0) };
|
|
227
|
+
a.LIST = [];
|
|
228
|
+
a.junk = { chunkId: "", chunkSize: 0, chunkData: [] };
|
|
229
|
+
a._PMX = { chunkId: "", chunkSize: 0, value: "" };
|
|
230
|
+
a.g = { h: 16, o: false, O: false, R: false };
|
|
231
|
+
return a;
|
|
232
|
+
}
|
|
233
|
+
function B() {
|
|
234
|
+
this.container = "";
|
|
235
|
+
this.chunkSize = 0;
|
|
236
|
+
this.format = "";
|
|
237
|
+
this.Y = null;
|
|
238
|
+
this.c = 0;
|
|
239
|
+
this.a = { h: 32, o: false };
|
|
240
|
+
this.Z = ["RIFF", "RIFX"];
|
|
241
|
+
}
|
|
242
|
+
function H(a, b) {
|
|
243
|
+
this.offset = Math.ceil((a + b) / 8);
|
|
244
|
+
this.b = a;
|
|
245
|
+
this.c = b;
|
|
246
|
+
this.a = (1 << a - 1) - 1;
|
|
247
|
+
this.f = Math.pow(2, this.a + 1);
|
|
248
|
+
this.g = a + b;
|
|
249
|
+
this.j = Math.pow(2, -(8 * this.offset - 1 - a));
|
|
250
|
+
}
|
|
251
|
+
function F(a, b) {
|
|
252
|
+
this.h = a;
|
|
253
|
+
this.offset = Math.ceil(a / 8);
|
|
254
|
+
this.max = Math.pow(2, a) - 1;
|
|
255
|
+
this.min = 0;
|
|
256
|
+
this.S = this.a;
|
|
257
|
+
if (void 0 === b ? 0 : b) this.max = Math.pow(2, a) / 2 - 1, this.min = -this.max - 1, this.S = this.f;
|
|
258
|
+
}
|
|
259
|
+
function ra(a) {
|
|
260
|
+
for (var b = new Uint8Array(256), c = 0; 64 > c; c++) b["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charCodeAt(c)] = c;
|
|
261
|
+
c = 0.75 * a.length;
|
|
262
|
+
"=" === a[a.length - 1] && (c--, "=" === a[a.length - 2] && c--);
|
|
263
|
+
c = new Uint8Array(c);
|
|
264
|
+
for (var d = 0, e = 0; d < a.length; d += 4) {
|
|
265
|
+
var f = b[a.charCodeAt(d)], g = b[a.charCodeAt(d + 1)], k = b[a.charCodeAt(d + 2)], r = b[a.charCodeAt(d + 3)];
|
|
266
|
+
c[e++] = f << 2 | g >> 4;
|
|
267
|
+
c[e++] = (g & 15) << 4 | k >> 2;
|
|
268
|
+
c[e++] = (k & 3) << 6 | r & 63;
|
|
269
|
+
}
|
|
270
|
+
return c;
|
|
271
|
+
}
|
|
272
|
+
function sa(a, b) {
|
|
273
|
+
return a = 0 < a ? parseInt(a / b.ea * b.ca, 10) : parseInt(a / b.fa * b.da, 10);
|
|
274
|
+
}
|
|
275
|
+
function ta(a, b) {
|
|
276
|
+
return parseInt(0 < a ? a * b.ca : a * b.da, 10);
|
|
277
|
+
}
|
|
278
|
+
function ua(a, b) {
|
|
279
|
+
return 0 < a ? a / b.ea : a / b.fa;
|
|
280
|
+
}
|
|
281
|
+
function va(a, b) {
|
|
282
|
+
function c(d) {
|
|
283
|
+
return d;
|
|
284
|
+
}
|
|
285
|
+
a != b && (c = ["32f", "64"].includes(a) ? ta : ["32f", "64"].includes(b) ? ua : sa);
|
|
286
|
+
return c;
|
|
287
|
+
}
|
|
288
|
+
function X(a) {
|
|
289
|
+
if ("32f" != a && "64" != a && ("8" > parseInt(a, 10) || "53" < parseInt(a, 10))) throw Error("Invalid bit depth.");
|
|
290
|
+
}
|
|
291
|
+
function Y(a, b, c) {
|
|
292
|
+
if ("8" == a) {
|
|
293
|
+
a = c ? -128 : 128;
|
|
294
|
+
c = 0;
|
|
295
|
+
for (var d = b.length; c < d; c++) b[c] = b[c] += a;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
function wa(a) {
|
|
299
|
+
for (var b = { index: 0, i: 0, step: 7 }, c = new Uint8Array(a.length), d = [], e = 0, f = 0, g = 0, k = a.length; g < k; g++) 0 == g % 505 && 0 != g && (c.set(xa(d, b), e), e += 256, d = [], f++), d.push(a[g]);
|
|
300
|
+
a = a.length / 2;
|
|
301
|
+
a % 2 && a++;
|
|
302
|
+
return c.slice(0, a + 512 + 4 * f);
|
|
303
|
+
}
|
|
304
|
+
function ya(a, b) {
|
|
305
|
+
b = void 0 === b ? 256 : b;
|
|
306
|
+
for (var c = { index: 0, i: 0, step: 7 }, d = new Int16Array(2 * a.length), e = [], f = 0, g = 0, k = a.length; g < k; g++) {
|
|
307
|
+
if (0 == g % b && 0 != g) {
|
|
308
|
+
var r = c, z3 = e[1] << 8 | e[0];
|
|
309
|
+
r.i = 32768 < z3 ? z3 - 65536 : z3;
|
|
310
|
+
r.index = e[2];
|
|
311
|
+
r.step = R[r.index];
|
|
312
|
+
z3 = [r.i, r.i];
|
|
313
|
+
for (var I = 4, za = e.length; I < za; I++) {
|
|
314
|
+
var Z = e[I], aa = Z >> 4;
|
|
315
|
+
z3.push(ba(aa << 4 ^ Z, r));
|
|
316
|
+
z3.push(ba(aa, r));
|
|
317
|
+
}
|
|
318
|
+
e = z3;
|
|
319
|
+
d.set(e, f);
|
|
320
|
+
f += e.length;
|
|
321
|
+
e = [];
|
|
322
|
+
}
|
|
323
|
+
e.push(a[g]);
|
|
324
|
+
}
|
|
325
|
+
return d;
|
|
326
|
+
}
|
|
327
|
+
function xa(a, b) {
|
|
328
|
+
var c = a[0];
|
|
329
|
+
S(c, b);
|
|
330
|
+
var d = [];
|
|
331
|
+
d.push(c & 255);
|
|
332
|
+
d.push(c >> 8 & 255);
|
|
333
|
+
d.push(b.index);
|
|
334
|
+
d.push(0);
|
|
335
|
+
c = 3;
|
|
336
|
+
for (var e = a.length; c < e; c += 2) {
|
|
337
|
+
var f = S(a[c], b), g = S(a[c + 1], b);
|
|
338
|
+
d.push(g << 4 | f);
|
|
339
|
+
}
|
|
340
|
+
return d;
|
|
341
|
+
}
|
|
342
|
+
function S(a, b) {
|
|
343
|
+
var c = a - b.i;
|
|
344
|
+
if (0 <= c) var d = 0;
|
|
345
|
+
else d = 8, c = -c;
|
|
346
|
+
var e = R[b.index], f = e >> 3;
|
|
347
|
+
c > e && (d |= 4, c -= e, f += e);
|
|
348
|
+
e >>= 1;
|
|
349
|
+
c > e && (d |= 2, c -= e, f += e);
|
|
350
|
+
e >>= 1;
|
|
351
|
+
c > e && (d |= 1, f += e);
|
|
352
|
+
c = d;
|
|
353
|
+
b.i = c & 8 ? b.i - f : b.i + f;
|
|
354
|
+
-32768 > b.i ? b.i = -32768 : 32767 < b.i && (b.i = 32767);
|
|
355
|
+
b.index += ca[c & 7];
|
|
356
|
+
0 > b.index ? b.index = 0 : 88 < b.index && (b.index = 88);
|
|
357
|
+
return d;
|
|
358
|
+
}
|
|
359
|
+
function ba(a, b) {
|
|
360
|
+
var c = 0;
|
|
361
|
+
a & 4 && (c += b.step);
|
|
362
|
+
a & 2 && (c += b.step >> 1);
|
|
363
|
+
a & 1 && (c += b.step >> 2);
|
|
364
|
+
c += b.step >> 3;
|
|
365
|
+
a & 8 && (c = -c);
|
|
366
|
+
b.i += c;
|
|
367
|
+
32767 < b.i ? b.i = 32767 : -32767 > b.i && (b.i = -32767);
|
|
368
|
+
b.index += ca[a];
|
|
369
|
+
0 > b.index ? b.index = 0 : 88 < b.index && (b.index = 88);
|
|
370
|
+
b.step = R[b.index];
|
|
371
|
+
return b.i;
|
|
372
|
+
}
|
|
373
|
+
function Aa(a) {
|
|
374
|
+
for (var b = new Uint8Array(a.length), c = 0, d = a.length; c < d; c++) {
|
|
375
|
+
var e = c;
|
|
376
|
+
var f = a[c];
|
|
377
|
+
f = -32768 == f ? -32767 : f;
|
|
378
|
+
var g = ~f >> 8 & 128;
|
|
379
|
+
g || (f *= -1);
|
|
380
|
+
32635 < f && (f = 32635);
|
|
381
|
+
if (256 <= f) {
|
|
382
|
+
var k = Ba[f >> 8 & 127];
|
|
383
|
+
f = k << 4 | f >> k + 3 & 15;
|
|
384
|
+
} else f >>= 4;
|
|
385
|
+
b[e] = f ^ g ^ 85;
|
|
386
|
+
}
|
|
387
|
+
return b;
|
|
388
|
+
}
|
|
389
|
+
function Ca(a) {
|
|
390
|
+
for (var b = new Int16Array(a.length), c = 0, d = a.length; c < d; c++) {
|
|
391
|
+
var e = c, f = a[c], g = 0;
|
|
392
|
+
f ^= 85;
|
|
393
|
+
0 !== (f & 128) && (f &= -129, g = -1);
|
|
394
|
+
var k = ((f & 240) >> 4) + 4;
|
|
395
|
+
f = 4 != k ? 1 << k | (f & 15) << k - 4 | 1 << k - 5 : f << 1 | 1;
|
|
396
|
+
b[e] = -8 * (0 === g ? f : -f);
|
|
397
|
+
}
|
|
398
|
+
return b;
|
|
399
|
+
}
|
|
400
|
+
function Da(a) {
|
|
401
|
+
for (var b = new Uint8Array(a.length), c = 0, d = a.length; c < d; c++) {
|
|
402
|
+
var e = c, f = a[c];
|
|
403
|
+
var g = f >> 8 & 128;
|
|
404
|
+
0 != g && (f = -f);
|
|
405
|
+
f += 132;
|
|
406
|
+
32635 < f && (f = 32635);
|
|
407
|
+
var k = Ea[f >> 7 & 255];
|
|
408
|
+
b[e] = ~(g | k << 4 | f >> k + 3 & 15);
|
|
409
|
+
}
|
|
410
|
+
return b;
|
|
411
|
+
}
|
|
412
|
+
function Fa(a) {
|
|
413
|
+
for (var b = new Int16Array(a.length), c = 0, d = a.length; c < d; c++) {
|
|
414
|
+
var e = c, f = a[c];
|
|
415
|
+
f = ~f;
|
|
416
|
+
var g = f >> 4 & 7;
|
|
417
|
+
g = Ga[g] + ((f & 15) << g + 3);
|
|
418
|
+
0 != (f & 128) && (g = -g);
|
|
419
|
+
b[e] = g;
|
|
420
|
+
}
|
|
421
|
+
return b;
|
|
422
|
+
}
|
|
423
|
+
function da(a, b, c, d) {
|
|
424
|
+
d = void 0 === d ? a.length : d;
|
|
425
|
+
for (c = void 0 === c ? 0 : c; c < d; c += b) {
|
|
426
|
+
var e = a, f = b, g = c;
|
|
427
|
+
f--;
|
|
428
|
+
for (var k = 0; k < f; k++) {
|
|
429
|
+
var r = e[g + k];
|
|
430
|
+
e[g + k] = e[g + f];
|
|
431
|
+
e[g + f] = r;
|
|
432
|
+
f--;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
function T(a, b, c) {
|
|
437
|
+
c = void 0 === c ? 0 : c;
|
|
438
|
+
for (var d = 0, e = a.length; d < e; ) {
|
|
439
|
+
var f = a.codePointAt(d);
|
|
440
|
+
if (128 > f) b[c] = f, c++;
|
|
441
|
+
else {
|
|
442
|
+
var g = 0, k = 0;
|
|
443
|
+
2047 >= f ? (g = 1, k = 192) : 65535 >= f ? (g = 2, k = 224) : 1114111 >= f && (g = 3, k = 240, d++);
|
|
444
|
+
b[c] = (f >> 6 * g) + k;
|
|
445
|
+
for (c++; 0 < g; ) b[c] = 128 | f >> 6 * (g - 1) & 63, c++, g--;
|
|
446
|
+
}
|
|
447
|
+
d++;
|
|
448
|
+
}
|
|
449
|
+
return c;
|
|
450
|
+
}
|
|
451
|
+
function U(a) {
|
|
452
|
+
var b = Math.floor(a);
|
|
453
|
+
a -= b;
|
|
454
|
+
return 0.5 > a ? b : 0.5 < a ? b + 1 : b % 2 ? b + 1 : b;
|
|
455
|
+
}
|
|
456
|
+
function G(a, b, c) {
|
|
457
|
+
c = void 0 === c ? a.length : c;
|
|
458
|
+
var d = void 0 === b ? 0 : b;
|
|
459
|
+
c = void 0 === c ? a.length : c;
|
|
460
|
+
b = "";
|
|
461
|
+
for (d = void 0 === d ? 0 : d; d < c; ) {
|
|
462
|
+
var e = 128, f = 191, g = false, k = a[d++];
|
|
463
|
+
if (0 <= k && 127 >= k) b += String.fromCharCode(k);
|
|
464
|
+
else {
|
|
465
|
+
var r = 0;
|
|
466
|
+
194 <= k && 223 >= k ? r = 1 : 224 <= k && 239 >= k ? (r = 2, 224 === a[d] && (e = 160), 237 === a[d] && (f = 159)) : 240 <= k && 244 >= k ? (r = 3, 240 === a[d] && (e = 144), 244 === a[d] && (f = 143)) : g = true;
|
|
467
|
+
k &= (1 << 8 - r - 1) - 1;
|
|
468
|
+
for (var z3 = 0; z3 < r; z3++) {
|
|
469
|
+
if (a[d] < e || a[d] > f) g = true;
|
|
470
|
+
k = k << 6 | a[d] & 63;
|
|
471
|
+
d++;
|
|
472
|
+
}
|
|
473
|
+
g ? b += String.fromCharCode(65533) : 65535 >= k ? b += String.fromCharCode(k) : (k -= 65536, b += String.fromCharCode((k >> 10 & 1023) + 55296, (k & 1023) + 56320));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return b;
|
|
477
|
+
}
|
|
478
|
+
function x(a) {
|
|
479
|
+
var b = [];
|
|
480
|
+
T(a, b);
|
|
481
|
+
return b;
|
|
482
|
+
}
|
|
483
|
+
function L(a, b, c, d) {
|
|
484
|
+
d = void 0 === d ? 0 : d;
|
|
485
|
+
b = b || {};
|
|
486
|
+
for (var e = ea(b.h, b.R, b.O), f = Math.ceil(b.h / 8), g = 0, k = d, r = a.length; g < r; g++) d = e.ga(c, a[g], d);
|
|
487
|
+
b.o && da(c, f, k, d);
|
|
488
|
+
return d;
|
|
489
|
+
}
|
|
490
|
+
function E(a, b, c, d, e) {
|
|
491
|
+
d = void 0 === d ? 0 : d;
|
|
492
|
+
e = void 0 === e ? a.length : e;
|
|
493
|
+
b = b || {};
|
|
494
|
+
var f = ea(b.h, b.R, b.O);
|
|
495
|
+
e -= (e - d) % f.offset;
|
|
496
|
+
b.o ? (a = new Uint8Array(a), b.o && da(a, f.offset, d, e), fa(a, c, d, e, f)) : fa(a, c, d, e, f);
|
|
497
|
+
}
|
|
498
|
+
function h(a, b) {
|
|
499
|
+
var c = [];
|
|
500
|
+
L([a], b, c, 0);
|
|
501
|
+
return c;
|
|
502
|
+
}
|
|
503
|
+
function M(a, b, c) {
|
|
504
|
+
c = void 0 === c ? 0 : c;
|
|
505
|
+
var d = [];
|
|
506
|
+
E(a, b, d, c, c + Math.ceil(b.h / 8));
|
|
507
|
+
return d[0];
|
|
508
|
+
}
|
|
509
|
+
function fa(a, b, c, d, e) {
|
|
510
|
+
for (var f = e.offset, g = 0; c < d; c += f, g++) b[g] = e.S(a, c);
|
|
511
|
+
}
|
|
512
|
+
function ea(a, b, c) {
|
|
513
|
+
return b && 32 == a ? new H(
|
|
514
|
+
8,
|
|
515
|
+
23
|
|
516
|
+
) : b && 64 == a ? new H(11, 52) : new F(a, c);
|
|
517
|
+
}
|
|
518
|
+
function A(a, b) {
|
|
519
|
+
for (var c = x(a), d = c.length; d < b; d++) c.push(0);
|
|
520
|
+
return c;
|
|
521
|
+
}
|
|
522
|
+
function qa(a) {
|
|
523
|
+
return Math.exp(-a / 2 * a / 2);
|
|
524
|
+
}
|
|
525
|
+
function pa(a) {
|
|
526
|
+
return function(b) {
|
|
527
|
+
return (0 === b ? 1 : Math.sin(Math.PI * b) / (Math.PI * b)) * a(b);
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function ha(a, b, c, d) {
|
|
531
|
+
d = (void 0 === d ? null : d) || {};
|
|
532
|
+
var e = new Float64Array(a.length * ((c - b) / b + 1));
|
|
533
|
+
d.method = d.method || "cubic";
|
|
534
|
+
var f = new v(a.length, e.length, { method: d.method, tension: d.tension || 0, sincFilterSize: d.sincFilterSize || 6, sincWindow: d.sincWindow || void 0, clip: d.clip || "mirror" });
|
|
535
|
+
void 0 === d.LPF && (d.LPF = Ha[d.method]);
|
|
536
|
+
if (d.LPF) {
|
|
537
|
+
d.LPFType = d.LPFType || "IIR";
|
|
538
|
+
var g = Ia[d.LPFType];
|
|
539
|
+
if (c > b) {
|
|
540
|
+
b = new g(d.LPForder || ia[d.LPFType], c, b / 2);
|
|
541
|
+
c = 0;
|
|
542
|
+
for (d = e.length; c < d; c++) e[c] = b.filter(f.M(c, a));
|
|
543
|
+
b.reset();
|
|
544
|
+
for (a = e.length - 1; 0 <= a; a--) e[a] = b.filter(e[a]);
|
|
545
|
+
} else {
|
|
546
|
+
b = new g(d.LPForder || ia[d.LPFType], b, c / 2);
|
|
547
|
+
c = 0;
|
|
548
|
+
for (d = a.length; c < d; c++) a[c] = b.filter(a[c]);
|
|
549
|
+
b.reset();
|
|
550
|
+
for (c = a.length - 1; 0 <= c; c--) a[c] = b.filter(a[c]);
|
|
551
|
+
ja(a, e, f);
|
|
552
|
+
}
|
|
553
|
+
} else ja(a, e, f);
|
|
554
|
+
return e;
|
|
555
|
+
}
|
|
556
|
+
function ja(a, b, c) {
|
|
557
|
+
for (var d = 0, e = b.length; d < e; d++) b[d] = c.M(
|
|
558
|
+
d,
|
|
559
|
+
a
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
function J(a, b) {
|
|
563
|
+
var c = a / b;
|
|
564
|
+
c % 2 && c++;
|
|
565
|
+
return c;
|
|
566
|
+
}
|
|
567
|
+
var ca = [-1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8], R = [7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767], Ba = [
|
|
568
|
+
1,
|
|
569
|
+
1,
|
|
570
|
+
2,
|
|
571
|
+
2,
|
|
572
|
+
3,
|
|
573
|
+
3,
|
|
574
|
+
3,
|
|
575
|
+
3,
|
|
576
|
+
4,
|
|
577
|
+
4,
|
|
578
|
+
4,
|
|
579
|
+
4,
|
|
580
|
+
4,
|
|
581
|
+
4,
|
|
582
|
+
4,
|
|
583
|
+
4,
|
|
584
|
+
5,
|
|
585
|
+
5,
|
|
586
|
+
5,
|
|
587
|
+
5,
|
|
588
|
+
5,
|
|
589
|
+
5,
|
|
590
|
+
5,
|
|
591
|
+
5,
|
|
592
|
+
5,
|
|
593
|
+
5,
|
|
594
|
+
5,
|
|
595
|
+
5,
|
|
596
|
+
5,
|
|
597
|
+
5,
|
|
598
|
+
5,
|
|
599
|
+
5,
|
|
600
|
+
6,
|
|
601
|
+
6,
|
|
602
|
+
6,
|
|
603
|
+
6,
|
|
604
|
+
6,
|
|
605
|
+
6,
|
|
606
|
+
6,
|
|
607
|
+
6,
|
|
608
|
+
6,
|
|
609
|
+
6,
|
|
610
|
+
6,
|
|
611
|
+
6,
|
|
612
|
+
6,
|
|
613
|
+
6,
|
|
614
|
+
6,
|
|
615
|
+
6,
|
|
616
|
+
6,
|
|
617
|
+
6,
|
|
618
|
+
6,
|
|
619
|
+
6,
|
|
620
|
+
6,
|
|
621
|
+
6,
|
|
622
|
+
6,
|
|
623
|
+
6,
|
|
624
|
+
6,
|
|
625
|
+
6,
|
|
626
|
+
6,
|
|
627
|
+
6,
|
|
628
|
+
6,
|
|
629
|
+
6,
|
|
630
|
+
6,
|
|
631
|
+
6,
|
|
632
|
+
7,
|
|
633
|
+
7,
|
|
634
|
+
7,
|
|
635
|
+
7,
|
|
636
|
+
7,
|
|
637
|
+
7,
|
|
638
|
+
7,
|
|
639
|
+
7,
|
|
640
|
+
7,
|
|
641
|
+
7,
|
|
642
|
+
7,
|
|
643
|
+
7,
|
|
644
|
+
7,
|
|
645
|
+
7,
|
|
646
|
+
7,
|
|
647
|
+
7,
|
|
648
|
+
7,
|
|
649
|
+
7,
|
|
650
|
+
7,
|
|
651
|
+
7,
|
|
652
|
+
7,
|
|
653
|
+
7,
|
|
654
|
+
7,
|
|
655
|
+
7,
|
|
656
|
+
7,
|
|
657
|
+
7,
|
|
658
|
+
7,
|
|
659
|
+
7,
|
|
660
|
+
7,
|
|
661
|
+
7,
|
|
662
|
+
7,
|
|
663
|
+
7,
|
|
664
|
+
7,
|
|
665
|
+
7,
|
|
666
|
+
7,
|
|
667
|
+
7,
|
|
668
|
+
7,
|
|
669
|
+
7,
|
|
670
|
+
7,
|
|
671
|
+
7,
|
|
672
|
+
7,
|
|
673
|
+
7,
|
|
674
|
+
7,
|
|
675
|
+
7,
|
|
676
|
+
7,
|
|
677
|
+
7,
|
|
678
|
+
7,
|
|
679
|
+
7,
|
|
680
|
+
7,
|
|
681
|
+
7,
|
|
682
|
+
7,
|
|
683
|
+
7,
|
|
684
|
+
7,
|
|
685
|
+
7,
|
|
686
|
+
7,
|
|
687
|
+
7,
|
|
688
|
+
7,
|
|
689
|
+
7,
|
|
690
|
+
7,
|
|
691
|
+
7,
|
|
692
|
+
7,
|
|
693
|
+
7,
|
|
694
|
+
7,
|
|
695
|
+
7
|
|
696
|
+
], Ea = [
|
|
697
|
+
0,
|
|
698
|
+
0,
|
|
699
|
+
1,
|
|
700
|
+
1,
|
|
701
|
+
2,
|
|
702
|
+
2,
|
|
703
|
+
2,
|
|
704
|
+
2,
|
|
705
|
+
3,
|
|
706
|
+
3,
|
|
707
|
+
3,
|
|
708
|
+
3,
|
|
709
|
+
3,
|
|
710
|
+
3,
|
|
711
|
+
3,
|
|
712
|
+
3,
|
|
713
|
+
4,
|
|
714
|
+
4,
|
|
715
|
+
4,
|
|
716
|
+
4,
|
|
717
|
+
4,
|
|
718
|
+
4,
|
|
719
|
+
4,
|
|
720
|
+
4,
|
|
721
|
+
4,
|
|
722
|
+
4,
|
|
723
|
+
4,
|
|
724
|
+
4,
|
|
725
|
+
4,
|
|
726
|
+
4,
|
|
727
|
+
4,
|
|
728
|
+
4,
|
|
729
|
+
5,
|
|
730
|
+
5,
|
|
731
|
+
5,
|
|
732
|
+
5,
|
|
733
|
+
5,
|
|
734
|
+
5,
|
|
735
|
+
5,
|
|
736
|
+
5,
|
|
737
|
+
5,
|
|
738
|
+
5,
|
|
739
|
+
5,
|
|
740
|
+
5,
|
|
741
|
+
5,
|
|
742
|
+
5,
|
|
743
|
+
5,
|
|
744
|
+
5,
|
|
745
|
+
5,
|
|
746
|
+
5,
|
|
747
|
+
5,
|
|
748
|
+
5,
|
|
749
|
+
5,
|
|
750
|
+
5,
|
|
751
|
+
5,
|
|
752
|
+
5,
|
|
753
|
+
5,
|
|
754
|
+
5,
|
|
755
|
+
5,
|
|
756
|
+
5,
|
|
757
|
+
5,
|
|
758
|
+
5,
|
|
759
|
+
5,
|
|
760
|
+
5,
|
|
761
|
+
6,
|
|
762
|
+
6,
|
|
763
|
+
6,
|
|
764
|
+
6,
|
|
765
|
+
6,
|
|
766
|
+
6,
|
|
767
|
+
6,
|
|
768
|
+
6,
|
|
769
|
+
6,
|
|
770
|
+
6,
|
|
771
|
+
6,
|
|
772
|
+
6,
|
|
773
|
+
6,
|
|
774
|
+
6,
|
|
775
|
+
6,
|
|
776
|
+
6,
|
|
777
|
+
6,
|
|
778
|
+
6,
|
|
779
|
+
6,
|
|
780
|
+
6,
|
|
781
|
+
6,
|
|
782
|
+
6,
|
|
783
|
+
6,
|
|
784
|
+
6,
|
|
785
|
+
6,
|
|
786
|
+
6,
|
|
787
|
+
6,
|
|
788
|
+
6,
|
|
789
|
+
6,
|
|
790
|
+
6,
|
|
791
|
+
6,
|
|
792
|
+
6,
|
|
793
|
+
6,
|
|
794
|
+
6,
|
|
795
|
+
6,
|
|
796
|
+
6,
|
|
797
|
+
6,
|
|
798
|
+
6,
|
|
799
|
+
6,
|
|
800
|
+
6,
|
|
801
|
+
6,
|
|
802
|
+
6,
|
|
803
|
+
6,
|
|
804
|
+
6,
|
|
805
|
+
6,
|
|
806
|
+
6,
|
|
807
|
+
6,
|
|
808
|
+
6,
|
|
809
|
+
6,
|
|
810
|
+
6,
|
|
811
|
+
6,
|
|
812
|
+
6,
|
|
813
|
+
6,
|
|
814
|
+
6,
|
|
815
|
+
6,
|
|
816
|
+
6,
|
|
817
|
+
6,
|
|
818
|
+
6,
|
|
819
|
+
6,
|
|
820
|
+
6,
|
|
821
|
+
6,
|
|
822
|
+
6,
|
|
823
|
+
6,
|
|
824
|
+
6,
|
|
825
|
+
7,
|
|
826
|
+
7,
|
|
827
|
+
7,
|
|
828
|
+
7,
|
|
829
|
+
7,
|
|
830
|
+
7,
|
|
831
|
+
7,
|
|
832
|
+
7,
|
|
833
|
+
7,
|
|
834
|
+
7,
|
|
835
|
+
7,
|
|
836
|
+
7,
|
|
837
|
+
7,
|
|
838
|
+
7,
|
|
839
|
+
7,
|
|
840
|
+
7,
|
|
841
|
+
7,
|
|
842
|
+
7,
|
|
843
|
+
7,
|
|
844
|
+
7,
|
|
845
|
+
7,
|
|
846
|
+
7,
|
|
847
|
+
7,
|
|
848
|
+
7,
|
|
849
|
+
7,
|
|
850
|
+
7,
|
|
851
|
+
7,
|
|
852
|
+
7,
|
|
853
|
+
7,
|
|
854
|
+
7,
|
|
855
|
+
7,
|
|
856
|
+
7,
|
|
857
|
+
7,
|
|
858
|
+
7,
|
|
859
|
+
7,
|
|
860
|
+
7,
|
|
861
|
+
7,
|
|
862
|
+
7,
|
|
863
|
+
7,
|
|
864
|
+
7,
|
|
865
|
+
7,
|
|
866
|
+
7,
|
|
867
|
+
7,
|
|
868
|
+
7,
|
|
869
|
+
7,
|
|
870
|
+
7,
|
|
871
|
+
7,
|
|
872
|
+
7,
|
|
873
|
+
7,
|
|
874
|
+
7,
|
|
875
|
+
7,
|
|
876
|
+
7,
|
|
877
|
+
7,
|
|
878
|
+
7,
|
|
879
|
+
7,
|
|
880
|
+
7,
|
|
881
|
+
7,
|
|
882
|
+
7,
|
|
883
|
+
7,
|
|
884
|
+
7,
|
|
885
|
+
7,
|
|
886
|
+
7,
|
|
887
|
+
7,
|
|
888
|
+
7,
|
|
889
|
+
7,
|
|
890
|
+
7,
|
|
891
|
+
7,
|
|
892
|
+
7,
|
|
893
|
+
7,
|
|
894
|
+
7,
|
|
895
|
+
7,
|
|
896
|
+
7,
|
|
897
|
+
7,
|
|
898
|
+
7,
|
|
899
|
+
7,
|
|
900
|
+
7,
|
|
901
|
+
7,
|
|
902
|
+
7,
|
|
903
|
+
7,
|
|
904
|
+
7,
|
|
905
|
+
7,
|
|
906
|
+
7,
|
|
907
|
+
7,
|
|
908
|
+
7,
|
|
909
|
+
7,
|
|
910
|
+
7,
|
|
911
|
+
7,
|
|
912
|
+
7,
|
|
913
|
+
7,
|
|
914
|
+
7,
|
|
915
|
+
7,
|
|
916
|
+
7,
|
|
917
|
+
7,
|
|
918
|
+
7,
|
|
919
|
+
7,
|
|
920
|
+
7,
|
|
921
|
+
7,
|
|
922
|
+
7,
|
|
923
|
+
7,
|
|
924
|
+
7,
|
|
925
|
+
7,
|
|
926
|
+
7,
|
|
927
|
+
7,
|
|
928
|
+
7,
|
|
929
|
+
7,
|
|
930
|
+
7,
|
|
931
|
+
7,
|
|
932
|
+
7,
|
|
933
|
+
7,
|
|
934
|
+
7,
|
|
935
|
+
7,
|
|
936
|
+
7,
|
|
937
|
+
7,
|
|
938
|
+
7,
|
|
939
|
+
7,
|
|
940
|
+
7,
|
|
941
|
+
7,
|
|
942
|
+
7,
|
|
943
|
+
7,
|
|
944
|
+
7,
|
|
945
|
+
7,
|
|
946
|
+
7,
|
|
947
|
+
7,
|
|
948
|
+
7,
|
|
949
|
+
7,
|
|
950
|
+
7,
|
|
951
|
+
7,
|
|
952
|
+
7
|
|
953
|
+
], Ga = [0, 132, 396, 924, 1980, 4092, 8316, 16764];
|
|
954
|
+
F.prototype.ga = function(a, b, c) {
|
|
955
|
+
c = void 0 === c ? 0 : c;
|
|
956
|
+
b = this.b(Math.round(b));
|
|
957
|
+
for (var d = 0, e = this.offset; d < e; d++) a[c] = Math.floor(b / Math.pow(2, 8 * d)) & 255, c++;
|
|
958
|
+
return c;
|
|
959
|
+
};
|
|
960
|
+
F.prototype.a = function(a, b) {
|
|
961
|
+
b = void 0 === b ? 0 : b;
|
|
962
|
+
for (var c = 0, d = 0; d < this.offset; d++) c += a[b + d] * Math.pow(256, d);
|
|
963
|
+
return c;
|
|
964
|
+
};
|
|
965
|
+
F.prototype.f = function(a, b) {
|
|
966
|
+
return this.c(this.a(a, void 0 === b ? 0 : b));
|
|
967
|
+
};
|
|
968
|
+
F.prototype.b = function(a) {
|
|
969
|
+
return a > this.max ? this.max : a < this.min ? this.min : a;
|
|
970
|
+
};
|
|
971
|
+
F.prototype.c = function(a) {
|
|
972
|
+
a > this.max && (a -= 2 * this.max + 2);
|
|
973
|
+
return a;
|
|
974
|
+
};
|
|
975
|
+
H.prototype.ga = function(a, b, c) {
|
|
976
|
+
Math.abs(b) > this.f - 2 * this.g && (b = 0 > b ? -Infinity : Infinity);
|
|
977
|
+
var d = 0 > ((b = +b) || 1 / b) ? 1 : 0 > b ? 1 : 0;
|
|
978
|
+
b = Math.abs(b);
|
|
979
|
+
var e = Math.min(Math.floor(Math.log(b) / Math.LN2), 1023), f = U(b / Math.pow(2, e) * Math.pow(2, this.c));
|
|
980
|
+
b !== b ? (f = Math.pow(2, this.c - 1), e = (1 << this.b) - 1) : 0 !== b && (b >= Math.pow(2, 1 - this.a) ? (2 <= f / Math.pow(2, this.c) && (e += 1, f = 1), e > this.a ? (e = (1 << this.b) - 1, f = 0) : (e += this.a, f = U(f) - Math.pow(2, this.c))) : (f = U(b / Math.pow(2, 1 - this.a - this.c)), e = 0));
|
|
981
|
+
return this.l(a, c, d, e, f);
|
|
982
|
+
};
|
|
983
|
+
H.prototype.S = function(a, b) {
|
|
984
|
+
for (var c = (1 << this.b) - 1, d = "", e = this.offset - 1; 0 <= e; e--) {
|
|
985
|
+
var f = a[e + b].toString(2);
|
|
986
|
+
d += "00000000".substring(f.length) + f;
|
|
987
|
+
}
|
|
988
|
+
e = "1" == d.charAt(0) ? -1 : 1;
|
|
989
|
+
d = d.substring(1);
|
|
990
|
+
f = parseInt(d.substring(0, this.b), 2);
|
|
991
|
+
d = d.substring(this.b);
|
|
992
|
+
if (f == c) return 0 !== parseInt(d, 2) ? NaN : Infinity * e;
|
|
993
|
+
0 === f ? (f += 1, c = parseInt(d, 2)) : c = parseInt("1" + d, 2);
|
|
994
|
+
return e * c * this.j * Math.pow(2, f - this.a);
|
|
995
|
+
};
|
|
996
|
+
H.prototype.l = function(a, b, c, d, e) {
|
|
997
|
+
var f = [];
|
|
998
|
+
f.push(c);
|
|
999
|
+
for (c = this.b; 0 < c; --c) f[c] = d % 2 ? 1 : 0, d = Math.floor(d / 2);
|
|
1000
|
+
d = f.length;
|
|
1001
|
+
for (c = this.c; 0 < c; --c) f[d + c] = e % 2 ? 1 : 0, e = Math.floor(e / 2);
|
|
1002
|
+
e = f.join("");
|
|
1003
|
+
f = this.offset + b - 1;
|
|
1004
|
+
for (d = b; f >= b; ) a[f] = parseInt(e.substring(0, 8), 2), e = e.substring(8), f--, d++;
|
|
1005
|
+
return d;
|
|
1006
|
+
};
|
|
1007
|
+
B.prototype.va = function(a) {
|
|
1008
|
+
this.c = 0;
|
|
1009
|
+
this.container = this.u(a, 4);
|
|
1010
|
+
if (-1 === this.Z.indexOf(this.container)) throw Error("Not a supported format.");
|
|
1011
|
+
this.a.o = "RIFX" === this.container;
|
|
1012
|
+
this.chunkSize = this.b(a);
|
|
1013
|
+
this.format = this.u(a, 4);
|
|
1014
|
+
this.Y = { chunkId: this.container, chunkSize: this.chunkSize, format: this.format, subChunks: this.V(a) };
|
|
1015
|
+
};
|
|
1016
|
+
B.prototype.s = function(a, b) {
|
|
1017
|
+
b = void 0 === b ? false : b;
|
|
1018
|
+
for (var c = this.Y.subChunks, d = [], e = 0; e < c.length; e++) if (c[e].chunkId == a) if (b) d.push(c[e]);
|
|
1019
|
+
else return c[e];
|
|
1020
|
+
return "LIST" == a ? d.length ? d : null : null;
|
|
1021
|
+
};
|
|
1022
|
+
B.prototype.u = function(a, b) {
|
|
1023
|
+
var c = G(a, this.c, this.c + b);
|
|
1024
|
+
this.c += b;
|
|
1025
|
+
return c;
|
|
1026
|
+
};
|
|
1027
|
+
B.prototype.b = function(a) {
|
|
1028
|
+
a = M(a, this.a, this.c);
|
|
1029
|
+
this.c += 4;
|
|
1030
|
+
return a;
|
|
1031
|
+
};
|
|
1032
|
+
B.prototype.V = function(a) {
|
|
1033
|
+
for (var b = [], c = this.c; c <= a.length - 8; ) b.push(this.$a(a, c)), c += 8 + b[b.length - 1].chunkSize, c = c % 2 ? c + 1 : c;
|
|
1034
|
+
return b;
|
|
1035
|
+
};
|
|
1036
|
+
B.prototype.$a = function(a, b) {
|
|
1037
|
+
var c = { chunkId: this.Ea(a, b), chunkSize: this.Fa(a, b) };
|
|
1038
|
+
"LIST" == c.chunkId ? (c.format = G(a, b + 8, b + 12), this.c += 4, c.subChunks = this.V(a)) : (this.c = b + 8 + (c.chunkSize % 2 ? c.chunkSize + 1 : c.chunkSize), c.chunkData = { start: b + 8, end: this.c });
|
|
1039
|
+
return c;
|
|
1040
|
+
};
|
|
1041
|
+
B.prototype.Ea = function(a, b) {
|
|
1042
|
+
this.c += 4;
|
|
1043
|
+
return G(a, b, b + 4);
|
|
1044
|
+
};
|
|
1045
|
+
B.prototype.Fa = function(a, b) {
|
|
1046
|
+
this.c += 4;
|
|
1047
|
+
return M(
|
|
1048
|
+
a,
|
|
1049
|
+
this.a,
|
|
1050
|
+
b + 4
|
|
1051
|
+
);
|
|
1052
|
+
};
|
|
1053
|
+
P(u, B);
|
|
1054
|
+
u.prototype.fromBuffer = function(a, b) {
|
|
1055
|
+
b = void 0 === b ? true : b;
|
|
1056
|
+
this.U();
|
|
1057
|
+
this.va(a);
|
|
1058
|
+
this.g.o = this.a.o;
|
|
1059
|
+
if ("WAVE" != this.format) throw Error('Could not find the "WAVE" format identifier');
|
|
1060
|
+
this.hb(a);
|
|
1061
|
+
this.jb(a);
|
|
1062
|
+
this.ib(a);
|
|
1063
|
+
this.eb(a);
|
|
1064
|
+
this.qa(a);
|
|
1065
|
+
this.fb(a);
|
|
1066
|
+
this.ma(a);
|
|
1067
|
+
this.gb(a, b);
|
|
1068
|
+
this.lb(a);
|
|
1069
|
+
this.ia(a);
|
|
1070
|
+
this.na(a);
|
|
1071
|
+
};
|
|
1072
|
+
u.prototype.U = function() {
|
|
1073
|
+
var a = new u();
|
|
1074
|
+
Object.assign(this.fmt, a.fmt);
|
|
1075
|
+
Object.assign(this.fact, a.fact);
|
|
1076
|
+
Object.assign(this.cue, a.cue);
|
|
1077
|
+
Object.assign(this.smpl, a.smpl);
|
|
1078
|
+
Object.assign(this.bext, a.bext);
|
|
1079
|
+
Object.assign(this.iXML, a.iXML);
|
|
1080
|
+
Object.assign(this.ds64, a.ds64);
|
|
1081
|
+
Object.assign(this.data, a.data);
|
|
1082
|
+
this.LIST = [];
|
|
1083
|
+
Object.assign(this.junk, a.junk);
|
|
1084
|
+
Object.assign(this._PMX, a._PMX);
|
|
1085
|
+
};
|
|
1086
|
+
u.prototype.jb = function(a) {
|
|
1087
|
+
var b = this.s("fmt ");
|
|
1088
|
+
if (b) this.c = b.chunkData.start, this.fmt.chunkId = b.chunkId, this.fmt.chunkSize = b.chunkSize, this.fmt.audioFormat = this.j(a), this.fmt.numChannels = this.j(a), this.fmt.sampleRate = this.b(a), this.fmt.byteRate = this.b(a), this.fmt.blockAlign = this.j(a), this.fmt.bitsPerSample = this.j(a), this.kb(a);
|
|
1089
|
+
else throw Error('Could not find the "fmt " chunk');
|
|
1090
|
+
};
|
|
1091
|
+
u.prototype.kb = function(a) {
|
|
1092
|
+
16 < this.fmt.chunkSize && (this.fmt.cbSize = this.j(a), 18 < this.fmt.chunkSize && (this.fmt.validBitsPerSample = this.j(a), 20 < this.fmt.chunkSize && (this.fmt.dwChannelMask = this.b(a), this.fmt.subformat = [this.b(a), this.b(a), this.b(a), this.b(a)])));
|
|
1093
|
+
};
|
|
1094
|
+
u.prototype.ib = function(a) {
|
|
1095
|
+
var b = this.s("fact");
|
|
1096
|
+
b && (this.c = b.chunkData.start, this.fact.chunkId = b.chunkId, this.fact.chunkSize = b.chunkSize, this.fact.dwSampleLength = this.b(a));
|
|
1097
|
+
};
|
|
1098
|
+
u.prototype.fb = function(a) {
|
|
1099
|
+
var b = this.s("cue ");
|
|
1100
|
+
if (b) for (this.c = b.chunkData.start, this.cue.chunkId = b.chunkId, this.cue.chunkSize = b.chunkSize, this.cue.dwCuePoints = this.b(a), b = 0; b < this.cue.dwCuePoints; b++) this.cue.points.push({ dwName: this.b(a), dwPosition: this.b(a), fccChunk: this.u(a, 4), dwChunkStart: this.b(a), dwBlockStart: this.b(a), dwSampleOffset: this.b(a) });
|
|
1101
|
+
};
|
|
1102
|
+
u.prototype.ma = function(a) {
|
|
1103
|
+
var b = this.s("smpl");
|
|
1104
|
+
if (b) for (this.c = b.chunkData.start, this.smpl.chunkId = b.chunkId, this.smpl.chunkSize = b.chunkSize, this.smpl.dwManufacturer = this.b(a), this.smpl.dwProduct = this.b(a), this.smpl.dwSamplePeriod = this.b(a), this.smpl.dwMIDIUnityNote = this.b(a), this.smpl.dwMIDIPitchFraction = this.b(a), this.smpl.dwSMPTEFormat = this.b(a), this.smpl.dwSMPTEOffset = this.b(a), this.smpl.dwNumSampleLoops = this.b(a), this.smpl.dwSamplerData = this.b(a), b = 0; b < this.smpl.dwNumSampleLoops; b++) this.smpl.loops.push({ dwName: this.b(a), dwType: this.b(a), dwStart: this.b(a), dwEnd: this.b(a), dwFraction: this.b(a), dwPlayCount: this.b(a) });
|
|
1105
|
+
};
|
|
1106
|
+
u.prototype.gb = function(a, b) {
|
|
1107
|
+
var c = this.s("data");
|
|
1108
|
+
if (c) this.data.chunkId = "data", this.data.chunkSize = c.chunkSize, b && (this.data.samples = a.slice(c.chunkData.start, c.chunkData.end));
|
|
1109
|
+
else throw Error('Could not find the "data" chunk');
|
|
1110
|
+
};
|
|
1111
|
+
u.prototype.eb = function(a) {
|
|
1112
|
+
var b = this.s("bext");
|
|
1113
|
+
b && (this.c = b.chunkData.start, this.bext.chunkId = b.chunkId, this.bext.chunkSize = b.chunkSize, this.bext.description = this.u(a, 256), this.bext.originator = this.u(a, 32), this.bext.originatorReference = this.u(a, 32), this.bext.originationDate = this.u(a, 10), this.bext.originationTime = this.u(
|
|
1114
|
+
a,
|
|
1115
|
+
8
|
|
1116
|
+
), this.bext.timeReference = [this.b(a), this.b(a)], this.bext.version = this.j(a), this.bext.UMID = this.u(a, 64), this.bext.loudnessValue = this.j(a), this.bext.loudnessRange = this.j(a), this.bext.maxTruePeakLevel = this.j(a), this.bext.maxMomentaryLoudness = this.j(a), this.bext.maxShortTermLoudness = this.j(a), this.bext.reserved = this.u(a, 180), this.bext.codingHistory = this.u(a, this.bext.chunkSize - 602));
|
|
1117
|
+
};
|
|
1118
|
+
u.prototype.qa = function(a) {
|
|
1119
|
+
var b = this.s("iXML");
|
|
1120
|
+
b && (this.c = b.chunkData.start, this.iXML.chunkId = b.chunkId, this.iXML.chunkSize = b.chunkSize, this.iXML.value = G(a, this.c, this.c + this.iXML.chunkSize));
|
|
1121
|
+
};
|
|
1122
|
+
u.prototype.hb = function(a) {
|
|
1123
|
+
var b = this.s("ds64");
|
|
1124
|
+
if (b) this.c = b.chunkData.start, this.ds64.chunkId = b.chunkId, this.ds64.chunkSize = b.chunkSize, this.ds64.riffSizeHigh = this.b(a), this.ds64.riffSizeLow = this.b(a), this.ds64.dataSizeHigh = this.b(a), this.ds64.dataSizeLow = this.b(a), this.ds64.originationTime = this.b(a), this.ds64.sampleCountHigh = this.b(a), this.ds64.sampleCountLow = this.b(a);
|
|
1125
|
+
else if ("RF64" == this.container) throw Error('Could not find the "ds64" chunk');
|
|
1126
|
+
};
|
|
1127
|
+
u.prototype.ia = function(a) {
|
|
1128
|
+
var b = this.s("LIST", true);
|
|
1129
|
+
if (null !== b) for (var c = 0; c < b.length; c++) {
|
|
1130
|
+
var d = b[c];
|
|
1131
|
+
this.LIST.push({ chunkId: d.chunkId, chunkSize: d.chunkSize, format: d.format, subChunks: [] });
|
|
1132
|
+
for (var e = 0; e < d.subChunks.length; e++) this.ka(d.subChunks[e], d.format, a);
|
|
1133
|
+
}
|
|
1134
|
+
};
|
|
1135
|
+
u.prototype.ka = function(a, b, c) {
|
|
1136
|
+
"adtl" == b ? -1 < ["labl", "note", "ltxt"].indexOf(a.chunkId) && this.la(c, a) : "INFO" == b && this.ja(c, a);
|
|
1137
|
+
};
|
|
1138
|
+
u.prototype.la = function(a, b) {
|
|
1139
|
+
this.c = b.chunkData.start;
|
|
1140
|
+
var c = { chunkId: b.chunkId, chunkSize: b.chunkSize, dwName: this.b(a) };
|
|
1141
|
+
"ltxt" == b.chunkId ? (c.dwSampleLength = this.b(a), c.dwPurposeID = this.b(a), c.dwCountry = this.j(a), c.dwLanguage = this.j(a), c.dwDialect = this.j(a), c.dwCodePage = this.j(a), c.value = "") : c.value = this.X(a, this.c);
|
|
1142
|
+
this.LIST[this.LIST.length - 1].subChunks.push(c);
|
|
1143
|
+
};
|
|
1144
|
+
u.prototype.ja = function(a, b) {
|
|
1145
|
+
this.c = b.chunkData.start;
|
|
1146
|
+
this.LIST[this.LIST.length - 1].subChunks.push({ chunkId: b.chunkId, chunkSize: b.chunkSize, value: this.X(a, this.c) });
|
|
1147
|
+
};
|
|
1148
|
+
u.prototype.lb = function(a) {
|
|
1149
|
+
var b = this.s("junk");
|
|
1150
|
+
b && (this.junk = {
|
|
1151
|
+
chunkId: b.chunkId,
|
|
1152
|
+
chunkSize: b.chunkSize,
|
|
1153
|
+
chunkData: [].slice.call(a.slice(b.chunkData.start, b.chunkData.end))
|
|
1154
|
+
});
|
|
1155
|
+
};
|
|
1156
|
+
u.prototype.na = function(a) {
|
|
1157
|
+
var b = this.s("_PMX");
|
|
1158
|
+
b && (this.c = b.chunkData.start, this._PMX.chunkId = b.chunkId, this._PMX.chunkSize = b.chunkSize, this._PMX.value = G(a, this.c, this.c + this._PMX.chunkSize));
|
|
1159
|
+
};
|
|
1160
|
+
u.prototype.X = function(a, b) {
|
|
1161
|
+
for (var c = b = void 0 === b ? 0 : b; c < a.length && (this.c++, 0 !== a[c]); c++) ;
|
|
1162
|
+
return G(a, b, this.c - 1);
|
|
1163
|
+
};
|
|
1164
|
+
u.prototype.j = function(a) {
|
|
1165
|
+
a = M(a, this.g, this.c);
|
|
1166
|
+
this.c += 2;
|
|
1167
|
+
return a;
|
|
1168
|
+
};
|
|
1169
|
+
P(q, u);
|
|
1170
|
+
q.prototype.toBuffer = function() {
|
|
1171
|
+
this.g.o = "RIFX" === this.container;
|
|
1172
|
+
this.a.o = this.g.o;
|
|
1173
|
+
for (var a = [this.Sa(), this.Oa(), this.Da(), this.bb(), this.Qa(), this.Pa(), x(this.data.chunkId), h(this.data.samples.length, this.a), this.data.samples, this.Ga(), this.Ya(), this.Ta(), this.ab()], b = 0, c = 0; c < a.length; c++) b += a[c].length;
|
|
1174
|
+
c = new Uint8Array(b + 12);
|
|
1175
|
+
var d = T(this.container, c, 0);
|
|
1176
|
+
d = L([b + 4], this.a, c, void 0 === d ? 0 : d);
|
|
1177
|
+
d = T(this.format, c, void 0 === d ? 0 : d);
|
|
1178
|
+
for (b = 0; b < a.length; b++) c.set(a[b], d), d += a[b].length;
|
|
1179
|
+
return c;
|
|
1180
|
+
};
|
|
1181
|
+
q.prototype.Da = function() {
|
|
1182
|
+
var a = [];
|
|
1183
|
+
this.Ca();
|
|
1184
|
+
this.bext.chunkId && (this.bext.chunkSize = 602 + this.bext.codingHistory.length, a = a.concat(x(this.bext.chunkId), h(602 + this.bext.codingHistory.length, this.a), A(this.bext.description, 256), A(this.bext.originator, 32), A(this.bext.originatorReference, 32), A(this.bext.originationDate, 10), A(this.bext.originationTime, 8), h(this.bext.timeReference[0], this.a), h(this.bext.timeReference[1], this.a), h(this.bext.version, this.g), A(this.bext.UMID, 64), h(this.bext.loudnessValue, this.g), h(this.bext.loudnessRange, this.g), h(
|
|
1185
|
+
this.bext.maxTruePeakLevel,
|
|
1186
|
+
this.g
|
|
1187
|
+
), h(this.bext.maxMomentaryLoudness, this.g), h(this.bext.maxShortTermLoudness, this.g), A(this.bext.reserved, 180), A(this.bext.codingHistory, this.bext.codingHistory.length)));
|
|
1188
|
+
this.l(a);
|
|
1189
|
+
return a;
|
|
1190
|
+
};
|
|
1191
|
+
q.prototype.Ca = function() {
|
|
1192
|
+
for (var a in this.bext) if (this.bext.hasOwnProperty(a) && this.bext[a] && "timeReference" != a) {
|
|
1193
|
+
this.bext.chunkId = "bext";
|
|
1194
|
+
break;
|
|
1195
|
+
}
|
|
1196
|
+
if (this.bext.timeReference[0] || this.bext.timeReference[1]) this.bext.chunkId = "bext";
|
|
1197
|
+
};
|
|
1198
|
+
q.prototype.bb = function() {
|
|
1199
|
+
var a = [];
|
|
1200
|
+
if (this.iXML.chunkId) {
|
|
1201
|
+
var b = x(this.iXML.value);
|
|
1202
|
+
this.iXML.chunkSize = b.length;
|
|
1203
|
+
a = a.concat(x(this.iXML.chunkId), h(this.iXML.chunkSize, this.a), b);
|
|
1204
|
+
}
|
|
1205
|
+
this.l(a);
|
|
1206
|
+
return a;
|
|
1207
|
+
};
|
|
1208
|
+
q.prototype.Oa = function() {
|
|
1209
|
+
var a = [];
|
|
1210
|
+
this.ds64.chunkId && (a = a.concat(x(this.ds64.chunkId), h(this.ds64.chunkSize, this.a), h(this.ds64.riffSizeHigh, this.a), h(this.ds64.riffSizeLow, this.a), h(this.ds64.dataSizeHigh, this.a), h(this.ds64.dataSizeLow, this.a), h(this.ds64.originationTime, this.a), h(this.ds64.sampleCountHigh, this.a), h(this.ds64.sampleCountLow, this.a)));
|
|
1211
|
+
this.l(a);
|
|
1212
|
+
return a;
|
|
1213
|
+
};
|
|
1214
|
+
q.prototype.Ga = function() {
|
|
1215
|
+
var a = [];
|
|
1216
|
+
if (this.cue.chunkId) {
|
|
1217
|
+
var b = this.Ja();
|
|
1218
|
+
a = a.concat(x(this.cue.chunkId), h(b.length + 4, this.a), h(this.cue.dwCuePoints, this.a), b);
|
|
1219
|
+
}
|
|
1220
|
+
this.l(a);
|
|
1221
|
+
return a;
|
|
1222
|
+
};
|
|
1223
|
+
q.prototype.Ja = function() {
|
|
1224
|
+
for (var a = [], b = 0; b < this.cue.dwCuePoints; b++) a = a.concat(h(this.cue.points[b].dwName, this.a), h(this.cue.points[b].dwPosition, this.a), x(this.cue.points[b].fccChunk), h(this.cue.points[b].dwChunkStart, this.a), h(this.cue.points[b].dwBlockStart, this.a), h(this.cue.points[b].dwSampleOffset, this.a));
|
|
1225
|
+
return a;
|
|
1226
|
+
};
|
|
1227
|
+
q.prototype.Ya = function() {
|
|
1228
|
+
var a = [];
|
|
1229
|
+
if (this.smpl.chunkId) {
|
|
1230
|
+
var b = this.Za();
|
|
1231
|
+
a = a.concat(x(this.smpl.chunkId), h(b.length + 36, this.a), h(this.smpl.dwManufacturer, this.a), h(this.smpl.dwProduct, this.a), h(this.smpl.dwSamplePeriod, this.a), h(this.smpl.dwMIDIUnityNote, this.a), h(this.smpl.dwMIDIPitchFraction, this.a), h(this.smpl.dwSMPTEFormat, this.a), h(this.smpl.dwSMPTEOffset, this.a), h(this.smpl.dwNumSampleLoops, this.a), h(this.smpl.dwSamplerData, this.a), b);
|
|
1232
|
+
}
|
|
1233
|
+
this.l(a);
|
|
1234
|
+
return a;
|
|
1235
|
+
};
|
|
1236
|
+
q.prototype.Za = function() {
|
|
1237
|
+
for (var a = [], b = 0; b < this.smpl.dwNumSampleLoops; b++) a = a.concat(h(this.smpl.loops[b].dwName, this.a), h(this.smpl.loops[b].dwType, this.a), h(this.smpl.loops[b].dwStart, this.a), h(this.smpl.loops[b].dwEnd, this.a), h(this.smpl.loops[b].dwFraction, this.a), h(this.smpl.loops[b].dwPlayCount, this.a));
|
|
1238
|
+
return a;
|
|
1239
|
+
};
|
|
1240
|
+
q.prototype.Pa = function() {
|
|
1241
|
+
var a = [];
|
|
1242
|
+
this.fact.chunkId && (a = a.concat(x(this.fact.chunkId), h(this.fact.chunkSize, this.a), h(this.fact.dwSampleLength, this.a)));
|
|
1243
|
+
this.l(a);
|
|
1244
|
+
return a;
|
|
1245
|
+
};
|
|
1246
|
+
q.prototype.Qa = function() {
|
|
1247
|
+
var a = [];
|
|
1248
|
+
if (this.fmt.chunkId) return a = a.concat(
|
|
1249
|
+
x(this.fmt.chunkId),
|
|
1250
|
+
h(this.fmt.chunkSize, this.a),
|
|
1251
|
+
h(this.fmt.audioFormat, this.g),
|
|
1252
|
+
h(this.fmt.numChannels, this.g),
|
|
1253
|
+
h(this.fmt.sampleRate, this.a),
|
|
1254
|
+
h(this.fmt.byteRate, this.a),
|
|
1255
|
+
h(this.fmt.blockAlign, this.g),
|
|
1256
|
+
h(this.fmt.bitsPerSample, this.g),
|
|
1257
|
+
this.Ra()
|
|
1258
|
+
), this.l(a), a;
|
|
1259
|
+
throw Error('Could not find the "fmt " chunk');
|
|
1260
|
+
};
|
|
1261
|
+
q.prototype.Ra = function() {
|
|
1262
|
+
var a = [];
|
|
1263
|
+
16 < this.fmt.chunkSize && (a = a.concat(h(this.fmt.cbSize, this.g)));
|
|
1264
|
+
18 < this.fmt.chunkSize && (a = a.concat(h(this.fmt.validBitsPerSample, this.g)));
|
|
1265
|
+
20 < this.fmt.chunkSize && (a = a.concat(h(
|
|
1266
|
+
this.fmt.dwChannelMask,
|
|
1267
|
+
this.a
|
|
1268
|
+
)));
|
|
1269
|
+
24 < this.fmt.chunkSize && (a = a.concat(h(this.fmt.subformat[0], this.a), h(this.fmt.subformat[1], this.a), h(this.fmt.subformat[2], this.a), h(this.fmt.subformat[3], this.a)));
|
|
1270
|
+
return a;
|
|
1271
|
+
};
|
|
1272
|
+
q.prototype.Ta = function() {
|
|
1273
|
+
for (var a = [], b = 0; b < this.LIST.length; b++) {
|
|
1274
|
+
var c = this.Va(this.LIST[b].subChunks, this.LIST[b].format);
|
|
1275
|
+
a = a.concat(x(this.LIST[b].chunkId), h(c.length + 4, this.a), x(this.LIST[b].format), c);
|
|
1276
|
+
}
|
|
1277
|
+
this.l(a);
|
|
1278
|
+
return a;
|
|
1279
|
+
};
|
|
1280
|
+
q.prototype.Va = function(a, b) {
|
|
1281
|
+
for (var c = [], d = 0, e = a.length; d < e; d++) "INFO" == b ? c = c.concat(this.Ua(a[d])) : "adtl" == b && (c = c.concat(this.Wa(a[d]))), this.l(c);
|
|
1282
|
+
return c;
|
|
1283
|
+
};
|
|
1284
|
+
q.prototype.Ua = function(a) {
|
|
1285
|
+
var b = [], c = A(a.value, a.value.length);
|
|
1286
|
+
b = b.concat(x(a.chunkId), h(c.length + 1, this.a), c);
|
|
1287
|
+
b.push(0);
|
|
1288
|
+
return b;
|
|
1289
|
+
};
|
|
1290
|
+
q.prototype.Wa = function(a) {
|
|
1291
|
+
var b = [];
|
|
1292
|
+
if (-1 < ["labl", "note"].indexOf(a.chunkId)) {
|
|
1293
|
+
var c = A(a.value, a.value.length);
|
|
1294
|
+
b = b.concat(x(a.chunkId), h(c.length + 5, this.a), h(a.dwName, this.a), c);
|
|
1295
|
+
b.push(0);
|
|
1296
|
+
} else "ltxt" == a.chunkId && (b = b.concat(this.Xa(a)));
|
|
1297
|
+
return b;
|
|
1298
|
+
};
|
|
1299
|
+
q.prototype.Xa = function(a) {
|
|
1300
|
+
return x(a.chunkId).concat(h(a.value.length + 20, this.a), h(a.dwName, this.a), h(a.dwSampleLength, this.a), h(a.dwPurposeID, this.a), h(a.dwCountry, this.g), h(a.dwLanguage, this.g), h(a.dwDialect, this.g), h(a.dwCodePage, this.g), A(a.value, a.value.length));
|
|
1301
|
+
};
|
|
1302
|
+
q.prototype.ab = function() {
|
|
1303
|
+
var a = [];
|
|
1304
|
+
if (this._PMX.chunkId) {
|
|
1305
|
+
var b = x(this._PMX.value);
|
|
1306
|
+
this._PMX.chunkSize = b.length;
|
|
1307
|
+
a = a.concat(x(this._PMX.chunkId), h(this._PMX.chunkSize, this.a), b);
|
|
1308
|
+
}
|
|
1309
|
+
this.l(a);
|
|
1310
|
+
return a;
|
|
1311
|
+
};
|
|
1312
|
+
q.prototype.Sa = function() {
|
|
1313
|
+
var a = [];
|
|
1314
|
+
if (this.junk.chunkId) return a.concat(x(this.junk.chunkId), h(
|
|
1315
|
+
this.junk.chunkData.length,
|
|
1316
|
+
this.a
|
|
1317
|
+
), this.junk.chunkData);
|
|
1318
|
+
this.l(a);
|
|
1319
|
+
return a;
|
|
1320
|
+
};
|
|
1321
|
+
q.prototype.l = function(a) {
|
|
1322
|
+
a.length % 2 && a.push(0);
|
|
1323
|
+
};
|
|
1324
|
+
P(t, q);
|
|
1325
|
+
t.prototype.fromScratch = function(a, b, c, d, e) {
|
|
1326
|
+
e = e || {};
|
|
1327
|
+
this.U();
|
|
1328
|
+
this.W(a, b, c, d, e);
|
|
1329
|
+
};
|
|
1330
|
+
t.prototype.fromBuffer = function(a, b) {
|
|
1331
|
+
q.prototype.fromBuffer.call(this, a, void 0 === b ? true : b);
|
|
1332
|
+
this.ya();
|
|
1333
|
+
this.$();
|
|
1334
|
+
};
|
|
1335
|
+
t.prototype.toBuffer = function() {
|
|
1336
|
+
this.aa();
|
|
1337
|
+
return q.prototype.toBuffer.call(this);
|
|
1338
|
+
};
|
|
1339
|
+
t.prototype.getSamples = function(a, b) {
|
|
1340
|
+
a = void 0 === a ? false : a;
|
|
1341
|
+
b = void 0 === b ? Float64Array : b;
|
|
1342
|
+
var c = new b(this.data.samples.length / (this.f.h / 8));
|
|
1343
|
+
E(this.data.samples, this.f, c, 0, this.data.samples.length);
|
|
1344
|
+
if (!a && 1 < this.fmt.numChannels) {
|
|
1345
|
+
var d = this.fmt.numChannels, e = b;
|
|
1346
|
+
e = void 0 === e ? Float64Array : e;
|
|
1347
|
+
for (var f = [], g = 0; g < d; g++) f[g] = new e(c.length / d);
|
|
1348
|
+
for (e = 0; e < d; e++) {
|
|
1349
|
+
g = e;
|
|
1350
|
+
for (var k = 0; g < c.length; g += d, k++) f[e][k] = c[g];
|
|
1351
|
+
}
|
|
1352
|
+
c = f;
|
|
1353
|
+
}
|
|
1354
|
+
return c;
|
|
1355
|
+
};
|
|
1356
|
+
t.prototype.getSample = function(a) {
|
|
1357
|
+
a *= this.f.h / 8;
|
|
1358
|
+
if (a + this.f.h / 8 > this.data.samples.length) throw Error("Range error");
|
|
1359
|
+
return M(this.data.samples.slice(a, a + this.f.h / 8), this.f);
|
|
1360
|
+
};
|
|
1361
|
+
t.prototype.setSample = function(a, b) {
|
|
1362
|
+
a *= this.f.h / 8;
|
|
1363
|
+
if (a + this.f.h / 8 > this.data.samples.length) throw Error("Range error");
|
|
1364
|
+
L([b], this.f, this.data.samples, void 0 === a ? 0 : a);
|
|
1365
|
+
};
|
|
1366
|
+
t.prototype.getiXML = function() {
|
|
1367
|
+
return this.iXML.value;
|
|
1368
|
+
};
|
|
1369
|
+
t.prototype.setiXML = function(a) {
|
|
1370
|
+
if ("string" !== typeof a) throw new TypeError("iXML value must be a string.");
|
|
1371
|
+
this.iXML.value = a;
|
|
1372
|
+
this.iXML.chunkId = "iXML";
|
|
1373
|
+
};
|
|
1374
|
+
t.prototype.get_PMX = function() {
|
|
1375
|
+
return this._PMX.value;
|
|
1376
|
+
};
|
|
1377
|
+
t.prototype.set_PMX = function(a) {
|
|
1378
|
+
if ("string" !== typeof a) throw new TypeError("_PMX value must be a string.");
|
|
1379
|
+
this._PMX.value = a;
|
|
1380
|
+
this._PMX.chunkId = "_PMX";
|
|
1381
|
+
};
|
|
1382
|
+
t.prototype.W = function(a, b, c, d, e) {
|
|
1383
|
+
e.container || (e.container = "RIFF");
|
|
1384
|
+
this.container = e.container;
|
|
1385
|
+
this.bitDepth = c;
|
|
1386
|
+
var f = [];
|
|
1387
|
+
if (0 < d.length) if (d[0].constructor !== Number) {
|
|
1388
|
+
f = new Float64Array(d[0].length * d.length);
|
|
1389
|
+
for (var g = 0, k = d[0].length, r = 0; g < k; g++) for (var z3 = 0, I = d.length; z3 < I; z3++, r++) f[r] = d[z3][g];
|
|
1390
|
+
} else f = d;
|
|
1391
|
+
d = f;
|
|
1392
|
+
this.$();
|
|
1393
|
+
f = this.f.h / 8;
|
|
1394
|
+
this.data.samples = new Uint8Array(d.length * f);
|
|
1395
|
+
L(d, this.f, this.data.samples, 0);
|
|
1396
|
+
this.cb(c, a, b, f, this.data.samples.length, e);
|
|
1397
|
+
this.data.chunkId = "data";
|
|
1398
|
+
this.data.chunkSize = this.data.samples.length;
|
|
1399
|
+
this.aa();
|
|
1400
|
+
};
|
|
1401
|
+
t.prototype.cb = function(a, b, c, d, e, f) {
|
|
1402
|
+
"4" == a ? this.za(a, b, c, d, e, f) : "8a" == a || "8m" == a ? this.Aa(a, b, c, d, e, f) : -1 == Object.keys(this.G).indexOf(a) || 2 < b ? this.Ba(a, b, c, d, e, f) : this.F(a, b, c, d, e, f);
|
|
1403
|
+
};
|
|
1404
|
+
t.prototype.F = function(a, b, c, d, e, f) {
|
|
1405
|
+
this.container = f.container;
|
|
1406
|
+
this.chunkSize = 36 + e;
|
|
1407
|
+
this.format = "WAVE";
|
|
1408
|
+
this.bitDepth = a;
|
|
1409
|
+
this.fmt = {
|
|
1410
|
+
chunkId: "fmt ",
|
|
1411
|
+
chunkSize: 16,
|
|
1412
|
+
audioFormat: this.G[a] || 65534,
|
|
1413
|
+
numChannels: b,
|
|
1414
|
+
sampleRate: c,
|
|
1415
|
+
byteRate: b * d * c,
|
|
1416
|
+
blockAlign: b * d,
|
|
1417
|
+
bitsPerSample: parseInt(a, 10),
|
|
1418
|
+
cbSize: 0,
|
|
1419
|
+
validBitsPerSample: 0,
|
|
1420
|
+
dwChannelMask: 0,
|
|
1421
|
+
subformat: []
|
|
1422
|
+
};
|
|
1423
|
+
};
|
|
1424
|
+
t.prototype.za = function(a, b, c, d, e, f) {
|
|
1425
|
+
this.F(a, b, c, d, e, f);
|
|
1426
|
+
this.chunkSize = 40 + e;
|
|
1427
|
+
this.fmt.chunkSize = 20;
|
|
1428
|
+
this.fmt.byteRate = 4055;
|
|
1429
|
+
this.fmt.blockAlign = 256;
|
|
1430
|
+
this.fmt.bitsPerSample = 4;
|
|
1431
|
+
this.fmt.cbSize = 2;
|
|
1432
|
+
this.fmt.validBitsPerSample = 505;
|
|
1433
|
+
this.fact = { chunkId: "fact", chunkSize: 4, dwSampleLength: 2 * e };
|
|
1434
|
+
};
|
|
1435
|
+
t.prototype.Ba = function(a, b, c, d, e, f) {
|
|
1436
|
+
this.F(a, b, c, d, e, f);
|
|
1437
|
+
this.chunkSize = 60 + e;
|
|
1438
|
+
this.fmt.chunkSize = 40;
|
|
1439
|
+
this.fmt.bitsPerSample = (parseInt(a, 10) - 1 | 7) + 1;
|
|
1440
|
+
this.fmt.cbSize = 22;
|
|
1441
|
+
this.fmt.validBitsPerSample = parseInt(a, 10);
|
|
1442
|
+
a = this.fmt;
|
|
1443
|
+
c = 0;
|
|
1444
|
+
1 === b ? c = 4 : 2 === b ? c = 3 : 4 === b ? c = 51 : 6 === b ? c = 63 : 8 === b && (c = 1599);
|
|
1445
|
+
a.dwChannelMask = c;
|
|
1446
|
+
this.fmt.subformat = [1, 1048576, 2852126848, 1905997824];
|
|
1447
|
+
};
|
|
1448
|
+
t.prototype.Aa = function(a, b, c, d, e, f) {
|
|
1449
|
+
this.F(a, b, c, d, e, f);
|
|
1450
|
+
this.chunkSize = 40 + e;
|
|
1451
|
+
this.fmt.chunkSize = 20;
|
|
1452
|
+
this.fmt.cbSize = 2;
|
|
1453
|
+
this.fmt.validBitsPerSample = 8;
|
|
1454
|
+
this.fact = { chunkId: "fact", chunkSize: 4, dwSampleLength: e };
|
|
1455
|
+
};
|
|
1456
|
+
t.prototype.ya = function() {
|
|
1457
|
+
3 === this.fmt.audioFormat && 32 === this.fmt.bitsPerSample ? this.bitDepth = "32f" : 6 === this.fmt.audioFormat ? this.bitDepth = "8a" : 7 === this.fmt.audioFormat ? this.bitDepth = "8m" : this.bitDepth = this.fmt.bitsPerSample.toString();
|
|
1458
|
+
};
|
|
1459
|
+
t.prototype.wa = function() {
|
|
1460
|
+
if (!(this.G[this.bitDepth] || 8 < parseInt(this.bitDepth, 10) && 54 > parseInt(this.bitDepth, 10))) throw Error("Invalid bit depth.");
|
|
1461
|
+
};
|
|
1462
|
+
t.prototype.$ = function() {
|
|
1463
|
+
this.f = { h: (parseInt(this.bitDepth, 10) - 1 | 7) + 1, R: "32f" == this.bitDepth || "64" == this.bitDepth, O: "8" != this.bitDepth, o: "RIFX" == this.container };
|
|
1464
|
+
-1 < ["4", "8a", "8m"].indexOf(this.bitDepth) && (this.f.h = 8, this.f.O = false);
|
|
1465
|
+
};
|
|
1466
|
+
t.prototype.aa = function() {
|
|
1467
|
+
this.wa();
|
|
1468
|
+
var a = this.fmt.numChannels;
|
|
1469
|
+
if (1 > a || 65535 < a * this.fmt.bitsPerSample / 8) throw Error("Invalid number of channels.");
|
|
1470
|
+
a = this.fmt.sampleRate;
|
|
1471
|
+
if (1 > a || 4294967295 < this.fmt.bitsPerSample / 8 * this.fmt.numChannels * a) throw Error("Invalid sample rate.");
|
|
1472
|
+
};
|
|
1473
|
+
P(C, t);
|
|
1474
|
+
C.prototype.getTag = function(a) {
|
|
1475
|
+
a = this.P(a);
|
|
1476
|
+
return null !== a.w ? this.LIST[a.LIST].subChunks[a.w].value : null;
|
|
1477
|
+
};
|
|
1478
|
+
C.prototype.setTag = function(a, b) {
|
|
1479
|
+
var c = a;
|
|
1480
|
+
if (c.constructor !== String) throw Error("Invalid tag name.");
|
|
1481
|
+
if (4 > c.length) for (var d = 0, e = 4 - c.length; d < e; d++) c += " ";
|
|
1482
|
+
a = c;
|
|
1483
|
+
c = this.P(a);
|
|
1484
|
+
null !== c.w ? (this.LIST[c.LIST].subChunks[c.w].chunkSize = b.length + 1, this.LIST[c.LIST].subChunks[c.w].value = b) : null !== c.LIST ? this.LIST[c.LIST].subChunks.push({ chunkId: a, chunkSize: b.length + 1, value: b }) : (this.LIST.push({ chunkId: "LIST", chunkSize: b.length + 9, format: "INFO", subChunks: [] }), this.LIST[this.LIST.length - 1].subChunks.push({ chunkId: a, chunkSize: b.length + 1, value: b }));
|
|
1485
|
+
};
|
|
1486
|
+
C.prototype.deleteTag = function(a) {
|
|
1487
|
+
a = this.P(a);
|
|
1488
|
+
return null !== a.w ? (this.LIST[a.LIST].subChunks.splice(a.w, 1), true) : false;
|
|
1489
|
+
};
|
|
1490
|
+
C.prototype.listTags = function() {
|
|
1491
|
+
var a = this.C("INFO"), b = {};
|
|
1492
|
+
if (null !== a) for (var c = 0, d = this.LIST[a].subChunks.length; c < d; c++) b[this.LIST[a].subChunks[c].chunkId] = this.LIST[a].subChunks[c].value;
|
|
1493
|
+
return b;
|
|
1494
|
+
};
|
|
1495
|
+
C.prototype.C = function(a) {
|
|
1496
|
+
for (var b = 0, c = this.LIST.length; b < c; b++) if (this.LIST[b].format == a) return b;
|
|
1497
|
+
return null;
|
|
1498
|
+
};
|
|
1499
|
+
C.prototype.P = function(a) {
|
|
1500
|
+
for (var b = { LIST: null, w: null }, c = 0, d = this.LIST.length; c < d; c++) if ("INFO" == this.LIST[c].format) {
|
|
1501
|
+
b.LIST = c;
|
|
1502
|
+
d = 0;
|
|
1503
|
+
for (var e = this.LIST[c].subChunks.length; d < e; d++) if (this.LIST[c].subChunks[d].chunkId == a) {
|
|
1504
|
+
b.w = d;
|
|
1505
|
+
break;
|
|
1506
|
+
}
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
return b;
|
|
1510
|
+
};
|
|
1511
|
+
P(w, C);
|
|
1512
|
+
w.prototype.listCuePoints = function() {
|
|
1513
|
+
for (var a = this.J(), b = 0, c = a.length; b < c; b++) a[b].position = a[b].dwSampleOffset / this.fmt.sampleRate * 1e3, a[b].dwSampleLength ? (a[b].end = a[b].dwSampleLength / this.fmt.sampleRate * 1e3, a[b].end += a[b].position) : a[b].end = null, delete a[b].value;
|
|
1514
|
+
return a;
|
|
1515
|
+
};
|
|
1516
|
+
w.prototype.setCuePoint = function(a) {
|
|
1517
|
+
this.cue.chunkId = "cue ";
|
|
1518
|
+
a.label || (a.label = "");
|
|
1519
|
+
var b = this.J();
|
|
1520
|
+
this.I();
|
|
1521
|
+
this.cue.points = [];
|
|
1522
|
+
a.dwSampleOffset = a.position * this.fmt.sampleRate / 1e3;
|
|
1523
|
+
a.dwSampleLength = 0;
|
|
1524
|
+
a.end && (a.dwSampleLength = a.end * this.fmt.sampleRate / 1e3 - a.dwSampleOffset);
|
|
1525
|
+
0 === b.length ? this.B(a, 1) : this.ra(b, a);
|
|
1526
|
+
this.cue.dwCuePoints = this.cue.points.length;
|
|
1527
|
+
};
|
|
1528
|
+
w.prototype.deleteCuePoint = function(a) {
|
|
1529
|
+
this.cue.chunkId = "cue ";
|
|
1530
|
+
var b = this.J();
|
|
1531
|
+
this.I();
|
|
1532
|
+
var c = this.cue.points.length;
|
|
1533
|
+
this.cue.points = [];
|
|
1534
|
+
for (var d = 0; d < c; d++) d + 1 !== a && this.B(b[d], d + 1);
|
|
1535
|
+
this.cue.dwCuePoints = this.cue.points.length;
|
|
1536
|
+
this.cue.dwCuePoints ? this.cue.chunkId = "cue " : (this.cue.chunkId = "", this.I());
|
|
1537
|
+
};
|
|
1538
|
+
w.prototype.updateLabel = function(a, b) {
|
|
1539
|
+
var c = this.C("adtl");
|
|
1540
|
+
if (null !== c) for (var d = 0, e = this.LIST[c].subChunks.length; d < e; d++) this.LIST[c].subChunks[d].dwName == a && (this.LIST[c].subChunks[d].value = b);
|
|
1541
|
+
};
|
|
1542
|
+
w.prototype.J = function() {
|
|
1543
|
+
for (var a = [], b = 0; b < this.cue.points.length; b++) {
|
|
1544
|
+
var c = this.cue.points[b], d = this.Na(c.dwName);
|
|
1545
|
+
d.label = d.value ? d.value : "";
|
|
1546
|
+
d.dwPosition = c.dwPosition;
|
|
1547
|
+
d.fccChunk = c.fccChunk;
|
|
1548
|
+
d.dwChunkStart = c.dwChunkStart;
|
|
1549
|
+
d.dwBlockStart = c.dwBlockStart;
|
|
1550
|
+
d.dwSampleOffset = c.dwSampleOffset;
|
|
1551
|
+
a.push(d);
|
|
1552
|
+
}
|
|
1553
|
+
return a;
|
|
1554
|
+
};
|
|
1555
|
+
w.prototype.Na = function(a) {
|
|
1556
|
+
var b = this.C("adtl"), c = {};
|
|
1557
|
+
null !== b && this.ha(c, b, a);
|
|
1558
|
+
return c;
|
|
1559
|
+
};
|
|
1560
|
+
w.prototype.ha = function(a, b, c) {
|
|
1561
|
+
for (var d = 0, e = this.LIST[b].subChunks.length; d < e; d++) if (this.LIST[b].subChunks[d].dwName == c) {
|
|
1562
|
+
var f = this.LIST[b].subChunks[d];
|
|
1563
|
+
a.value = f.value || a.value;
|
|
1564
|
+
a.dwName = f.dwName || 0;
|
|
1565
|
+
a.dwSampleLength = f.dwSampleLength || 0;
|
|
1566
|
+
a.dwPurposeID = f.dwPurposeID || 0;
|
|
1567
|
+
a.dwCountry = f.dwCountry || 0;
|
|
1568
|
+
a.dwLanguage = f.dwLanguage || 0;
|
|
1569
|
+
a.dwDialect = f.dwDialect || 0;
|
|
1570
|
+
a.dwCodePage = f.dwCodePage || 0;
|
|
1571
|
+
}
|
|
1572
|
+
};
|
|
1573
|
+
w.prototype.B = function(a, b) {
|
|
1574
|
+
this.cue.points.push({ dwName: b, dwPosition: a.dwPosition ? a.dwPosition : 0, fccChunk: a.fccChunk ? a.fccChunk : "data", dwChunkStart: a.dwChunkStart ? a.dwChunkStart : 0, dwBlockStart: a.dwBlockStart ? a.dwBlockStart : 0, dwSampleOffset: a.dwSampleOffset });
|
|
1575
|
+
this.ta(a, b);
|
|
1576
|
+
};
|
|
1577
|
+
w.prototype.ra = function(a, b) {
|
|
1578
|
+
for (var c = false, d = 0; d < a.length; d++) a[d].dwSampleOffset > b.dwSampleOffset && !c ? (this.B(b, d + 1), this.B(a[d], d + 2), c = true) : this.B(a[d], c ? d + 2 : d + 1);
|
|
1579
|
+
c || this.B(b, this.cue.points.length + 1);
|
|
1580
|
+
};
|
|
1581
|
+
w.prototype.I = function() {
|
|
1582
|
+
for (var a = 0, b = this.LIST.length; a < b; a++) "adtl" == this.LIST[a].format && this.LIST.splice(a);
|
|
1583
|
+
};
|
|
1584
|
+
w.prototype.ta = function(a, b) {
|
|
1585
|
+
var c = this.C("adtl");
|
|
1586
|
+
null === c && (this.LIST.push({ chunkId: "LIST", chunkSize: 4, format: "adtl", subChunks: [] }), c = this.LIST.length - 1);
|
|
1587
|
+
this.sa(c, a, b);
|
|
1588
|
+
a.dwSampleLength && this.ua(c, a, b);
|
|
1589
|
+
};
|
|
1590
|
+
w.prototype.sa = function(a, b, c) {
|
|
1591
|
+
this.LIST[a].subChunks.push({ chunkId: "labl", chunkSize: 4, dwName: c, value: b.label });
|
|
1592
|
+
this.LIST[a].chunkSize += 12;
|
|
1593
|
+
};
|
|
1594
|
+
w.prototype.ua = function(a, b, c) {
|
|
1595
|
+
this.LIST[a].subChunks.push({
|
|
1596
|
+
chunkId: "ltxt",
|
|
1597
|
+
chunkSize: 20,
|
|
1598
|
+
dwName: c,
|
|
1599
|
+
dwSampleLength: b.dwSampleLength,
|
|
1600
|
+
dwPurposeID: b.dwPurposeID || 0,
|
|
1601
|
+
dwCountry: b.dwCountry || 0,
|
|
1602
|
+
dwLanguage: b.dwLanguage || 0,
|
|
1603
|
+
dwDialect: b.dwDialect || 0,
|
|
1604
|
+
dwCodePage: b.dwCodePage || 0,
|
|
1605
|
+
value: b.label
|
|
1606
|
+
});
|
|
1607
|
+
this.LIST[a].chunkSize += 28;
|
|
1608
|
+
};
|
|
1609
|
+
v.prototype.H = function(a, b) {
|
|
1610
|
+
return this.f(Math.round(this.l * a), b);
|
|
1611
|
+
};
|
|
1612
|
+
v.prototype.G = function(a, b) {
|
|
1613
|
+
a *= this.l;
|
|
1614
|
+
var c = Math.floor(a);
|
|
1615
|
+
a -= c;
|
|
1616
|
+
return (1 - a) * this.f(c, b) + a * this.f(c + 1, b);
|
|
1617
|
+
};
|
|
1618
|
+
v.prototype.B = function(a, b) {
|
|
1619
|
+
a *= this.l;
|
|
1620
|
+
var c = Math.floor(a), d = [this.m(c, b), this.m(c + 1, b)], e = [this.f(c, b), this.f(c + 1, b)];
|
|
1621
|
+
a -= c;
|
|
1622
|
+
c = a * a;
|
|
1623
|
+
var f = a * c;
|
|
1624
|
+
return (2 * f - 3 * c + 1) * e[0] + (f - 2 * c + a) * d[0] + (-2 * f + 3 * c) * e[1] + (f - c) * d[1];
|
|
1625
|
+
};
|
|
1626
|
+
v.prototype.I = function(a, b) {
|
|
1627
|
+
a *= this.l;
|
|
1628
|
+
var c = Math.floor(a), d = c + this.v, e = 0;
|
|
1629
|
+
for (c = c - this.v + 1; c <= d; c++) e += this.F(a - c) * this.f(c, b);
|
|
1630
|
+
return e;
|
|
1631
|
+
};
|
|
1632
|
+
v.prototype.m = function(a, b) {
|
|
1633
|
+
return this.J * (this.f(a + 1, b) - this.f(a - 1, b)) / 2;
|
|
1634
|
+
};
|
|
1635
|
+
v.prototype.f = function(a, b) {
|
|
1636
|
+
return 0 <= a && a < this.C ? b[a] : 0;
|
|
1637
|
+
};
|
|
1638
|
+
y.prototype.filter = function(a) {
|
|
1639
|
+
this.z.L[this.z.N] = a;
|
|
1640
|
+
for (var b = a = 0, c = this.z.L.length; b < c; b++) a += this.a[b] * this.z.L[(this.z.N + b) % this.z.L.length];
|
|
1641
|
+
this.z.N = (this.z.N + 1) % this.z.L.length;
|
|
1642
|
+
return a;
|
|
1643
|
+
};
|
|
1644
|
+
y.prototype.reset = function() {
|
|
1645
|
+
this.z = this.b();
|
|
1646
|
+
};
|
|
1647
|
+
y.prototype.b = function() {
|
|
1648
|
+
for (var a = [], b = 0; b < this.a.length - 1; b++) a.push(0);
|
|
1649
|
+
return { L: a, N: 0 };
|
|
1650
|
+
};
|
|
1651
|
+
p.prototype.filter = function(a) {
|
|
1652
|
+
for (var b = 0, c = this.a.length; b < c; b++) a = this.f(b, a);
|
|
1653
|
+
return a;
|
|
1654
|
+
};
|
|
1655
|
+
p.prototype.b = function(a) {
|
|
1656
|
+
var b = { D: [], A: [] };
|
|
1657
|
+
a = this.c(a, b);
|
|
1658
|
+
b.k = 1;
|
|
1659
|
+
b.A.push((1 - a.ba) / (2 * a.K));
|
|
1660
|
+
b.A.push(2 * b.A[0]);
|
|
1661
|
+
b.A.push(b.A[0]);
|
|
1662
|
+
return b;
|
|
1663
|
+
};
|
|
1664
|
+
p.prototype.c = function(a, b) {
|
|
1665
|
+
var c = {}, d = 2 * Math.PI * a.oa / a.pa;
|
|
1666
|
+
c.alpha = Math.sin(d) / (2 * a.Q);
|
|
1667
|
+
c.ba = Math.cos(d);
|
|
1668
|
+
c.K = 1 + c.alpha;
|
|
1669
|
+
b.K = c.K;
|
|
1670
|
+
b.D.push(-2 * c.ba / c.K);
|
|
1671
|
+
b.k = 1;
|
|
1672
|
+
b.D.push((1 - c.alpha) / c.K);
|
|
1673
|
+
return c;
|
|
1674
|
+
};
|
|
1675
|
+
p.prototype.f = function(a, b) {
|
|
1676
|
+
var c = b * this.a[a].k - this.a[a].Ha * this.a[a].z[0] - this.a[a].Ia * this.a[a].z[1], d = this.a[a].Ka * c + this.a[a].La * this.a[a].z[0] + this.a[a].Ma * this.a[a].z[1];
|
|
1677
|
+
this.a[a].z[1] = this.a[a].z[0];
|
|
1678
|
+
this.a[a].z[0] = c;
|
|
1679
|
+
return d;
|
|
1680
|
+
};
|
|
1681
|
+
p.prototype.reset = function() {
|
|
1682
|
+
for (var a = 0; a < this.a.length; a++) this.a[a].z = [0, 0];
|
|
1683
|
+
};
|
|
1684
|
+
var Ha = { point: false, linear: false, cubic: true, sinc: true }, ia = { IIR: 16, FIR: 71 }, Ia = { IIR: p, FIR: y };
|
|
1685
|
+
P(l, w);
|
|
1686
|
+
l.prototype.toRIFF = function() {
|
|
1687
|
+
var a = new Float64Array(J(
|
|
1688
|
+
this.data.samples.length,
|
|
1689
|
+
this.f.h / 8
|
|
1690
|
+
));
|
|
1691
|
+
E(this.data.samples, this.f, a, 0, this.data.samples.length);
|
|
1692
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, this.bitDepth, a, { container: "RIFF" });
|
|
1693
|
+
};
|
|
1694
|
+
l.prototype.toRIFX = function() {
|
|
1695
|
+
var a = new Float64Array(J(this.data.samples.length, this.f.h / 8));
|
|
1696
|
+
E(this.data.samples, this.f, a, 0, this.data.samples.length);
|
|
1697
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, this.bitDepth, a, { container: "RIFX" });
|
|
1698
|
+
};
|
|
1699
|
+
l.prototype.toIMAADPCM = function() {
|
|
1700
|
+
if (8e3 !== this.fmt.sampleRate) throw Error("Only 8000 Hz files can be compressed as IMA-ADPCM.");
|
|
1701
|
+
if (1 !== this.fmt.numChannels) throw Error("Only mono files can be compressed as IMA-ADPCM.");
|
|
1702
|
+
this.H();
|
|
1703
|
+
var a = new Int16Array(J(this.data.samples.length, 2));
|
|
1704
|
+
E(this.data.samples, this.f, a, 0, this.data.samples.length);
|
|
1705
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, "4", wa(a), { container: this.v() });
|
|
1706
|
+
};
|
|
1707
|
+
l.prototype.fromIMAADPCM = function(a) {
|
|
1708
|
+
a = void 0 === a ? "16" : a;
|
|
1709
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, "16", ya(this.data.samples, this.fmt.blockAlign), { container: this.v() });
|
|
1710
|
+
"16" != a && this.toBitDepth(a);
|
|
1711
|
+
};
|
|
1712
|
+
l.prototype.toALaw = function() {
|
|
1713
|
+
this.H();
|
|
1714
|
+
var a = new Int16Array(J(this.data.samples.length, 2));
|
|
1715
|
+
E(this.data.samples, this.f, a, 0, this.data.samples.length);
|
|
1716
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, "8a", Aa(a), { container: this.v() });
|
|
1717
|
+
};
|
|
1718
|
+
l.prototype.fromALaw = function(a) {
|
|
1719
|
+
a = void 0 === a ? "16" : a;
|
|
1720
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, "16", Ca(this.data.samples), { container: this.v() });
|
|
1721
|
+
"16" != a && this.toBitDepth(a);
|
|
1722
|
+
};
|
|
1723
|
+
l.prototype.toMuLaw = function() {
|
|
1724
|
+
this.H();
|
|
1725
|
+
var a = new Int16Array(J(this.data.samples.length, 2));
|
|
1726
|
+
E(
|
|
1727
|
+
this.data.samples,
|
|
1728
|
+
this.f,
|
|
1729
|
+
a,
|
|
1730
|
+
0,
|
|
1731
|
+
this.data.samples.length
|
|
1732
|
+
);
|
|
1733
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, "8m", Da(a), { container: this.v() });
|
|
1734
|
+
};
|
|
1735
|
+
l.prototype.fromMuLaw = function(a) {
|
|
1736
|
+
a = void 0 === a ? "16" : a;
|
|
1737
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, "16", Fa(this.data.samples), { container: this.v() });
|
|
1738
|
+
"16" != a && this.toBitDepth(a);
|
|
1739
|
+
};
|
|
1740
|
+
l.prototype.toBitDepth = function(a, b) {
|
|
1741
|
+
var c = a, d = this.bitDepth;
|
|
1742
|
+
void 0 === b || b || ("32f" != a && (c = this.f.h.toString()), d = "" + this.f.h);
|
|
1743
|
+
this.T();
|
|
1744
|
+
var e = this.getSamples(true), f = new Float64Array(e.length), g = d;
|
|
1745
|
+
if (-1 < [
|
|
1746
|
+
"32f",
|
|
1747
|
+
"64"
|
|
1748
|
+
].indexOf(g) && -1 < ["32f", "64"].indexOf(c)) f.set(e);
|
|
1749
|
+
else {
|
|
1750
|
+
X(g);
|
|
1751
|
+
X(c);
|
|
1752
|
+
d = va(g, c);
|
|
1753
|
+
var k = { fa: Math.pow(2, parseInt(g, 10)) / 2, da: Math.pow(2, parseInt(c, 10)) / 2, ea: Math.pow(2, parseInt(g, 10)) / 2 - 1, ca: Math.pow(2, parseInt(c, 10)) / 2 - 1 };
|
|
1754
|
+
Y(g, e, true);
|
|
1755
|
+
g = 0;
|
|
1756
|
+
for (var r = e.length; g < r; g++) f[g] = d(e[g], k);
|
|
1757
|
+
Y(c, f, false);
|
|
1758
|
+
}
|
|
1759
|
+
this.m(this.fmt.numChannels, this.fmt.sampleRate, a, f, { container: this.v() });
|
|
1760
|
+
};
|
|
1761
|
+
l.prototype.toSampleRate = function(a, b) {
|
|
1762
|
+
this.xa(a);
|
|
1763
|
+
var c = this.getSamples(), d = [];
|
|
1764
|
+
if (c.constructor === Float64Array) d = ha(c, this.fmt.sampleRate, a, b);
|
|
1765
|
+
else for (var e = 0; e < c.length; e++) d.push(ha(c[e], this.fmt.sampleRate, a, b));
|
|
1766
|
+
this.m(this.fmt.numChannels, a, this.bitDepth, d, { container: this.v() });
|
|
1767
|
+
};
|
|
1768
|
+
l.prototype.xa = function(a) {
|
|
1769
|
+
if (1 > a || 4294967295 < this.fmt.bitsPerSample / 8 * this.fmt.numChannels * a) throw Error("Invalid sample rate.");
|
|
1770
|
+
if (-1 < ["4", "8a", "8m"].indexOf(this.bitDepth)) throw Error("wavefile can't change the sample rate of compressed files.");
|
|
1771
|
+
};
|
|
1772
|
+
l.prototype.H = function() {
|
|
1773
|
+
this.T();
|
|
1774
|
+
"16" != this.bitDepth && this.toBitDepth("16");
|
|
1775
|
+
};
|
|
1776
|
+
l.prototype.T = function() {
|
|
1777
|
+
"8a" == this.bitDepth ? this.fromALaw() : "8m" == this.bitDepth ? this.fromMuLaw() : "4" == this.bitDepth && this.fromIMAADPCM();
|
|
1778
|
+
};
|
|
1779
|
+
l.prototype.v = function() {
|
|
1780
|
+
return "RF64" == this.container ? "RIFF" : this.container;
|
|
1781
|
+
};
|
|
1782
|
+
l.prototype.m = function(a, b, c, d, e) {
|
|
1783
|
+
var f = new w();
|
|
1784
|
+
Object.assign(this.fmt, f.fmt);
|
|
1785
|
+
Object.assign(this.fact, f.fact);
|
|
1786
|
+
Object.assign(this.ds64, f.ds64);
|
|
1787
|
+
Object.assign(this.data, f.data);
|
|
1788
|
+
this.W(a, b, c, d, e);
|
|
1789
|
+
};
|
|
1790
|
+
P(m, l);
|
|
1791
|
+
m.prototype.fromBase64 = function(a) {
|
|
1792
|
+
this.fromBuffer(ra(a));
|
|
1793
|
+
};
|
|
1794
|
+
m.prototype.toBase64 = function() {
|
|
1795
|
+
for (var a = this.toBuffer(), b = "", c = 0; c < a.length; c += 3) b += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c] >> 2], b += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c] & 3) << 4 | a[c + 1] >> 4], b += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[c + 1] & 15) << 2 | a[c + 2] >> 6], b += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[c + 2] & 63];
|
|
1796
|
+
2 === a.length % 3 ? b = b.substring(0, b.length - 1) + "=" : 1 === a.length % 3 && (b = b.substring(0, b.length - 2) + "==");
|
|
1797
|
+
return b;
|
|
1798
|
+
};
|
|
1799
|
+
m.prototype.toDataURI = function() {
|
|
1800
|
+
return "data:audio/wav;base64," + this.toBase64();
|
|
1801
|
+
};
|
|
1802
|
+
m.prototype.fromDataURI = function(a) {
|
|
1803
|
+
this.fromBase64(a.replace("data:audio/wav;base64,", ""));
|
|
1804
|
+
};
|
|
1805
|
+
n.WaveFile = m;
|
|
1806
|
+
Object.defineProperty(n, "__esModule", { value: true });
|
|
1807
|
+
}
|
|
1808
|
+
"object" === typeof exports$1 && "undefined" !== typeof module ? W(exports$1) : "function" === typeof define && define.amd ? define(["exports"], W) : (V = V || self, W(V.wavefile = {}));
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
15
1811
|
|
|
16
1812
|
// ../../node_modules/zod/v4/classic/external.js
|
|
17
1813
|
var external_exports = {};
|
|
@@ -28150,7 +29946,7 @@ async function reverseBuffer(source, dest) {
|
|
|
28150
29946
|
// package.json
|
|
28151
29947
|
var package_default = {
|
|
28152
29948
|
name: "@buffered-audio/nodes",
|
|
28153
|
-
version: "0.15.
|
|
29949
|
+
version: "0.15.2"};
|
|
28154
29950
|
|
|
28155
29951
|
// src/package-metadata.ts
|
|
28156
29952
|
var PACKAGE_NAME = package_default.name;
|
|
@@ -29560,7 +31356,7 @@ function getBatchTime(fftSize, numFrames) {
|
|
|
29560
31356
|
return grown;
|
|
29561
31357
|
}
|
|
29562
31358
|
function stft(signal, fftSize, hopSize, output, backend, fftAddonOptions) {
|
|
29563
|
-
const
|
|
31359
|
+
const window2 = hanningWindow(fftSize);
|
|
29564
31360
|
const numFrames = Math.floor((signal.length - fftSize) / hopSize) + 1;
|
|
29565
31361
|
const halfSize = fftSize / 2 + 1;
|
|
29566
31362
|
const addon = backend ? getFftAddon(backend, fftAddonOptions) : null;
|
|
@@ -29574,7 +31370,7 @@ function stft(signal, fftSize, hopSize, output, backend, fftAddonOptions) {
|
|
|
29574
31370
|
for (let frame = 0; frame < numFrames; frame++) {
|
|
29575
31371
|
const offset = frame * hopSize;
|
|
29576
31372
|
for (let index = 0; index < fftSize; index++) {
|
|
29577
|
-
batchInput[frame * fftSize + index] = (signal[offset + index] ?? 0) * (
|
|
31373
|
+
batchInput[frame * fftSize + index] = (signal[offset + index] ?? 0) * (window2[index] ?? 0);
|
|
29578
31374
|
}
|
|
29579
31375
|
}
|
|
29580
31376
|
if (typeof addon.batchFftInto === "function") {
|
|
@@ -29591,7 +31387,7 @@ function stft(signal, fftSize, hopSize, output, backend, fftAddonOptions) {
|
|
|
29591
31387
|
for (let frame = 0; frame < numFrames; frame++) {
|
|
29592
31388
|
const offset = frame * hopSize;
|
|
29593
31389
|
for (let index = 0; index < fftSize; index++) {
|
|
29594
|
-
windowed[index] = (signal[offset + index] ?? 0) * (
|
|
31390
|
+
windowed[index] = (signal[offset + index] ?? 0) * (window2[index] ?? 0);
|
|
29595
31391
|
}
|
|
29596
31392
|
const { re, im } = fft(windowed, workspace);
|
|
29597
31393
|
const dstOffset = frame * halfSize;
|
|
@@ -29604,7 +31400,7 @@ function stft(signal, fftSize, hopSize, output, backend, fftAddonOptions) {
|
|
|
29604
31400
|
}
|
|
29605
31401
|
function istft(result, hopSize, outputLength, backend, fftAddonOptions) {
|
|
29606
31402
|
const { real, imag, frames, fftSize } = result;
|
|
29607
|
-
const
|
|
31403
|
+
const window2 = hanningWindow(fftSize);
|
|
29608
31404
|
const output = new Float32Array(outputLength);
|
|
29609
31405
|
const windowSum = new Float32Array(outputLength);
|
|
29610
31406
|
const halfSize = fftSize / 2 + 1;
|
|
@@ -29625,8 +31421,8 @@ function istft(result, hopSize, outputLength, backend, fftAddonOptions) {
|
|
|
29625
31421
|
for (let index = 0; index < fftSize; index++) {
|
|
29626
31422
|
const pos = offset + index;
|
|
29627
31423
|
if (pos < outputLength) {
|
|
29628
|
-
output[pos] = (output[pos] ?? 0) + (timeDomainBatch[frame * fftSize + index] ?? 0) * (
|
|
29629
|
-
windowSum[pos] = (windowSum[pos] ?? 0) + (
|
|
31424
|
+
output[pos] = (output[pos] ?? 0) + (timeDomainBatch[frame * fftSize + index] ?? 0) * (window2[index] ?? 0);
|
|
31425
|
+
windowSum[pos] = (windowSum[pos] ?? 0) + (window2[index] ?? 0) * (window2[index] ?? 0);
|
|
29630
31426
|
}
|
|
29631
31427
|
}
|
|
29632
31428
|
}
|
|
@@ -29651,8 +31447,8 @@ function istft(result, hopSize, outputLength, backend, fftAddonOptions) {
|
|
|
29651
31447
|
for (let index = 0; index < fftSize; index++) {
|
|
29652
31448
|
const pos = offset + index;
|
|
29653
31449
|
if (pos < outputLength) {
|
|
29654
|
-
output[pos] = (output[pos] ?? 0) + (timeDomain[index] ?? 0) * (
|
|
29655
|
-
windowSum[pos] = (windowSum[pos] ?? 0) + (
|
|
31450
|
+
output[pos] = (output[pos] ?? 0) + (timeDomain[index] ?? 0) * (window2[index] ?? 0);
|
|
31451
|
+
windowSum[pos] = (windowSum[pos] ?? 0) + (window2[index] ?? 0) * (window2[index] ?? 0);
|
|
29656
31452
|
}
|
|
29657
31453
|
}
|
|
29658
31454
|
}
|
|
@@ -29670,13 +31466,13 @@ function hanningWindow(size, periodic = true) {
|
|
|
29670
31466
|
const key = `${size}:${periodic ? "p" : "s"}`;
|
|
29671
31467
|
const cached3 = hanningWindowCache.get(key);
|
|
29672
31468
|
if (cached3) return cached3;
|
|
29673
|
-
const
|
|
31469
|
+
const window2 = new Float32Array(size);
|
|
29674
31470
|
const denominator = periodic ? size : size - 1;
|
|
29675
31471
|
for (let index = 0; index < size; index++) {
|
|
29676
|
-
|
|
31472
|
+
window2[index] = 0.5 * (1 - Math.cos(2 * Math.PI * index / denominator));
|
|
29677
31473
|
}
|
|
29678
|
-
hanningWindowCache.set(key,
|
|
29679
|
-
return
|
|
31474
|
+
hanningWindowCache.set(key, window2);
|
|
31475
|
+
return window2;
|
|
29680
31476
|
}
|
|
29681
31477
|
function createFftWorkspace(size) {
|
|
29682
31478
|
return {
|
|
@@ -32052,7 +33848,10 @@ var ReverseNode = _ReverseNode;
|
|
|
32052
33848
|
function reverse(options) {
|
|
32053
33849
|
return new ReverseNode({ id: options?.id });
|
|
32054
33850
|
}
|
|
32055
|
-
|
|
33851
|
+
|
|
33852
|
+
// src/utils/read-to-buffer.ts
|
|
33853
|
+
var import_wavefile = __toESM(require_wavefile());
|
|
33854
|
+
var { WaveFile } = import_wavefile.default;
|
|
32056
33855
|
async function readWavSamples(path2) {
|
|
32057
33856
|
const data = await readFile(path2);
|
|
32058
33857
|
const wav = new WaveFile(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
@@ -34126,13 +35925,13 @@ function groupDelayLambda(sampleRate, order = LATTICE_ORDER) {
|
|
|
34126
35925
|
if (!(ratio > 1)) return 0;
|
|
34127
35926
|
return (ratio - 1) / (ratio + 1);
|
|
34128
35927
|
}
|
|
34129
|
-
function applyWindowAtScale(
|
|
34130
|
-
const length =
|
|
35928
|
+
function applyWindowAtScale(window2, reflectionRow, scale, order) {
|
|
35929
|
+
const length = window2.length;
|
|
34131
35930
|
const output = new Float32Array(length);
|
|
34132
35931
|
const state = new Float32Array(order);
|
|
34133
35932
|
const MAX_REFLECTION2 = 0.95;
|
|
34134
35933
|
for (let sample = 0; sample < length; sample++) {
|
|
34135
|
-
let signalValue =
|
|
35934
|
+
let signalValue = window2[sample] ?? 0;
|
|
34136
35935
|
for (let section = 0; section < order; section++) {
|
|
34137
35936
|
let kCoeff = scale * (reflectionRow[section] ?? 0);
|
|
34138
35937
|
if (kCoeff > MAX_REFLECTION2) kCoeff = MAX_REFLECTION2;
|
|
@@ -34388,7 +36187,7 @@ async function streamLatticeTrajectory(buffer, frameSize, hopSize, backend, addo
|
|
|
34388
36187
|
await buffer.reset();
|
|
34389
36188
|
const sumRing = new Float32Array(frameSize);
|
|
34390
36189
|
const channelRings = Array.from({ length: channelCount }, () => new Float32Array(frameSize));
|
|
34391
|
-
const
|
|
36190
|
+
const window2 = new Float32Array(frameSize);
|
|
34392
36191
|
const channelWindows = Array.from({ length: channelCount }, () => new Float32Array(frameSize));
|
|
34393
36192
|
const sumMagnitude = new Float32Array(halfSize);
|
|
34394
36193
|
let consumed = 0;
|
|
@@ -34413,14 +36212,14 @@ async function streamLatticeTrajectory(buffer, frameSize, hopSize, backend, addo
|
|
|
34413
36212
|
consumed += 1;
|
|
34414
36213
|
while (nextFrame < frameCount && consumed >= nextFrame * hopSize + frameSize) {
|
|
34415
36214
|
const start = nextFrame * hopSize;
|
|
34416
|
-
for (let pos = 0; pos < frameSize; pos++)
|
|
36215
|
+
for (let pos = 0; pos < frameSize; pos++) window2[pos] = sumRing[(start + pos) % frameSize] ?? 0;
|
|
34417
36216
|
for (let ch = 0; ch < channelCount; ch++) {
|
|
34418
36217
|
const channelRing = channelRings[ch];
|
|
34419
36218
|
const channelWindow = channelWindows[ch];
|
|
34420
36219
|
if (!channelRing || !channelWindow) continue;
|
|
34421
36220
|
for (let pos = 0; pos < frameSize; pos++) channelWindow[pos] = channelRing[(start + pos) % frameSize] ?? 0;
|
|
34422
36221
|
}
|
|
34423
|
-
const frameStft = stft(
|
|
36222
|
+
const frameStft = stft(window2, frameSize, frameSize, void 0, backend, addonOptions);
|
|
34424
36223
|
let energy = 0;
|
|
34425
36224
|
for (let bin = 0; bin < halfSize; bin++) {
|
|
34426
36225
|
const re = frameStft.real[bin] ?? 0;
|
|
@@ -34431,11 +36230,11 @@ async function streamLatticeTrajectory(buffer, frameSize, hopSize, backend, addo
|
|
|
34431
36230
|
}
|
|
34432
36231
|
transientMask[nextFrame] = previousEnergy > 0 && energy > TRANSIENT_ENERGY_RATIO * previousEnergy ? 1 : 0;
|
|
34433
36232
|
previousEnergy = energy;
|
|
34434
|
-
const amount = peakPriorityAmount(
|
|
36233
|
+
const amount = peakPriorityAmount(window2, 0, frameSize);
|
|
34435
36234
|
let windowPeak = 0;
|
|
34436
36235
|
let peakPos = 0;
|
|
34437
36236
|
for (let pos = 0; pos < frameSize; pos++) {
|
|
34438
|
-
const value =
|
|
36237
|
+
const value = window2[pos] ?? 0;
|
|
34439
36238
|
const absolute = value < 0 ? -value : value;
|
|
34440
36239
|
if (absolute > windowPeak) {
|
|
34441
36240
|
windowPeak = absolute;
|
|
@@ -36960,14 +38759,14 @@ var DIM_F2 = 3072;
|
|
|
36960
38759
|
var DIM_T2 = 256;
|
|
36961
38760
|
var CHANNEL_STRIDE = DIM_F2 * DIM_T2;
|
|
36962
38761
|
function buildTransitionWindow(segmentLength, transitionPower) {
|
|
36963
|
-
const
|
|
38762
|
+
const window2 = new Float32Array(segmentLength);
|
|
36964
38763
|
const half = segmentLength / 2;
|
|
36965
38764
|
for (let index = 0; index < half; index++) {
|
|
36966
38765
|
const value = Math.pow((index + 1) / half, transitionPower);
|
|
36967
|
-
|
|
36968
|
-
|
|
38766
|
+
window2[index] = value;
|
|
38767
|
+
window2[segmentLength - 1 - index] = value;
|
|
36969
38768
|
}
|
|
36970
|
-
return
|
|
38769
|
+
return window2;
|
|
36971
38770
|
}
|
|
36972
38771
|
function createSegmentWorkspace(segmentLength) {
|
|
36973
38772
|
return {
|