@grame/faustwasm 0.1.6 → 0.2.0
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/assets/standalone/faustwasm/index.d.ts +132 -99
- package/assets/standalone/faustwasm/index.js +907 -1230
- package/assets/standalone/faustwasm/index.js.map +4 -4
- package/dist/cjs/index.d.ts +132 -99
- package/dist/cjs/index.js +909 -1212
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs-bundle/index.d.ts +132 -99
- package/dist/cjs-bundle/index.js +1013 -1317
- package/dist/cjs-bundle/index.js.map +4 -4
- package/dist/esm/index.d.ts +132 -99
- package/dist/esm/index.js +907 -1230
- package/dist/esm/index.js.map +4 -4
- package/dist/esm-bundle/index.d.ts +132 -99
- package/dist/esm-bundle/index.js +1013 -1321
- package/dist/esm-bundle/index.js.map +4 -4
- package/libfaust-wasm/libfaust-wasm.js +1 -1
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +15 -13
- package/src/FaustAudioWorkletProcessor.ts +3 -14
- package/src/FaustCmajor.ts +6 -6
- package/src/FaustCompiler.ts +2 -2
- package/src/FaustDspGenerator.ts +109 -75
- package/src/FaustDspInstance.ts +2 -2
- package/src/FaustFFTAudioWorkletProcessor.ts +3 -1
- package/src/FaustWebAudioDsp.ts +224 -449
- package/src/SoundfileReader.ts +117 -0
- package/src/exports.ts +1 -0
- package/src/faust2wasmFiles.js +1 -1
- package/src/types.ts +15 -7
- package/test/faustlive-wasm/faustwasm/index.d.ts +132 -99
- package/test/faustlive-wasm/faustwasm/index.js +907 -1230
- package/test/faustlive-wasm/faustwasm/index.js.map +4 -4
- package/test/soundfile.dsp +15 -0
- package/test/soundfile1.dsp +23 -0
- package/test/web/soundfile.html +69 -0
- package/out/clarinetMIDI.html +0 -50
- package/out/clarinetMIDI.js +0 -63
- package/out/clarinetMIDI.json +0 -431
- package/out/clarinetMIDI.wasm +0 -0
- package/out/faustwasm/index.d.ts +0 -1495
- package/out/faustwasm/index.js +0 -4470
- package/out/faustwasm/index.js.map +0 -7
|
@@ -1,887 +1,3 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
20
|
-
mod
|
|
21
|
-
));
|
|
22
|
-
|
|
23
|
-
// node_modules/tslib/tslib.js
|
|
24
|
-
var require_tslib = __commonJS({
|
|
25
|
-
"node_modules/tslib/tslib.js"(exports, module) {
|
|
26
|
-
var __extends;
|
|
27
|
-
var __assign;
|
|
28
|
-
var __rest;
|
|
29
|
-
var __decorate;
|
|
30
|
-
var __param;
|
|
31
|
-
var __metadata;
|
|
32
|
-
var __awaiter;
|
|
33
|
-
var __generator;
|
|
34
|
-
var __exportStar;
|
|
35
|
-
var __values;
|
|
36
|
-
var __read;
|
|
37
|
-
var __spread;
|
|
38
|
-
var __spreadArrays;
|
|
39
|
-
var __await;
|
|
40
|
-
var __asyncGenerator;
|
|
41
|
-
var __asyncDelegator;
|
|
42
|
-
var __asyncValues;
|
|
43
|
-
var __makeTemplateObject;
|
|
44
|
-
var __importStar;
|
|
45
|
-
var __importDefault;
|
|
46
|
-
var __classPrivateFieldGet;
|
|
47
|
-
var __classPrivateFieldSet;
|
|
48
|
-
var __createBinding;
|
|
49
|
-
(function(factory) {
|
|
50
|
-
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
51
|
-
if (typeof define === "function" && define.amd) {
|
|
52
|
-
define("tslib", ["exports"], function(exports2) {
|
|
53
|
-
factory(createExporter(root, createExporter(exports2)));
|
|
54
|
-
});
|
|
55
|
-
} else if (typeof module === "object" && typeof module.exports === "object") {
|
|
56
|
-
factory(createExporter(root, createExporter(module.exports)));
|
|
57
|
-
} else {
|
|
58
|
-
factory(createExporter(root));
|
|
59
|
-
}
|
|
60
|
-
function createExporter(exports2, previous) {
|
|
61
|
-
if (exports2 !== root) {
|
|
62
|
-
if (typeof Object.create === "function") {
|
|
63
|
-
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64
|
-
} else {
|
|
65
|
-
exports2.__esModule = true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return function(id, v) {
|
|
69
|
-
return exports2[id] = previous ? previous(id, v) : v;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
})(function(exporter) {
|
|
73
|
-
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
|
|
74
|
-
d.__proto__ = b;
|
|
75
|
-
} || function(d, b) {
|
|
76
|
-
for (var p in b)
|
|
77
|
-
if (b.hasOwnProperty(p))
|
|
78
|
-
d[p] = b[p];
|
|
79
|
-
};
|
|
80
|
-
__extends = function(d, b) {
|
|
81
|
-
extendStatics(d, b);
|
|
82
|
-
function __() {
|
|
83
|
-
this.constructor = d;
|
|
84
|
-
}
|
|
85
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
86
|
-
};
|
|
87
|
-
__assign = Object.assign || function(t) {
|
|
88
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
89
|
-
s = arguments[i];
|
|
90
|
-
for (var p in s)
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
92
|
-
t[p] = s[p];
|
|
93
|
-
}
|
|
94
|
-
return t;
|
|
95
|
-
};
|
|
96
|
-
__rest = function(s, e) {
|
|
97
|
-
var t = {};
|
|
98
|
-
for (var p in s)
|
|
99
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
100
|
-
t[p] = s[p];
|
|
101
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
102
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
103
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
104
|
-
t[p[i]] = s[p[i]];
|
|
105
|
-
}
|
|
106
|
-
return t;
|
|
107
|
-
};
|
|
108
|
-
__decorate = function(decorators, target, key, desc) {
|
|
109
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
110
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
111
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
112
|
-
else
|
|
113
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
114
|
-
if (d = decorators[i])
|
|
115
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
116
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
117
|
-
};
|
|
118
|
-
__param = function(paramIndex, decorator) {
|
|
119
|
-
return function(target, key) {
|
|
120
|
-
decorator(target, key, paramIndex);
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
__metadata = function(metadataKey, metadataValue) {
|
|
124
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
125
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
126
|
-
};
|
|
127
|
-
__awaiter = function(thisArg, _arguments, P, generator) {
|
|
128
|
-
function adopt(value) {
|
|
129
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
130
|
-
resolve(value);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
134
|
-
function fulfilled(value) {
|
|
135
|
-
try {
|
|
136
|
-
step(generator.next(value));
|
|
137
|
-
} catch (e) {
|
|
138
|
-
reject(e);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
function rejected(value) {
|
|
142
|
-
try {
|
|
143
|
-
step(generator["throw"](value));
|
|
144
|
-
} catch (e) {
|
|
145
|
-
reject(e);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function step(result) {
|
|
149
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
150
|
-
}
|
|
151
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
__generator = function(thisArg, body) {
|
|
155
|
-
var _ = { label: 0, sent: function() {
|
|
156
|
-
if (t[0] & 1)
|
|
157
|
-
throw t[1];
|
|
158
|
-
return t[1];
|
|
159
|
-
}, trys: [], ops: [] }, f, y, t, g;
|
|
160
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
161
|
-
return this;
|
|
162
|
-
}), g;
|
|
163
|
-
function verb(n) {
|
|
164
|
-
return function(v) {
|
|
165
|
-
return step([n, v]);
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
function step(op) {
|
|
169
|
-
if (f)
|
|
170
|
-
throw new TypeError("Generator is already executing.");
|
|
171
|
-
while (_)
|
|
172
|
-
try {
|
|
173
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
174
|
-
return t;
|
|
175
|
-
if (y = 0, t)
|
|
176
|
-
op = [op[0] & 2, t.value];
|
|
177
|
-
switch (op[0]) {
|
|
178
|
-
case 0:
|
|
179
|
-
case 1:
|
|
180
|
-
t = op;
|
|
181
|
-
break;
|
|
182
|
-
case 4:
|
|
183
|
-
_.label++;
|
|
184
|
-
return { value: op[1], done: false };
|
|
185
|
-
case 5:
|
|
186
|
-
_.label++;
|
|
187
|
-
y = op[1];
|
|
188
|
-
op = [0];
|
|
189
|
-
continue;
|
|
190
|
-
case 7:
|
|
191
|
-
op = _.ops.pop();
|
|
192
|
-
_.trys.pop();
|
|
193
|
-
continue;
|
|
194
|
-
default:
|
|
195
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
196
|
-
_ = 0;
|
|
197
|
-
continue;
|
|
198
|
-
}
|
|
199
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
200
|
-
_.label = op[1];
|
|
201
|
-
break;
|
|
202
|
-
}
|
|
203
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
204
|
-
_.label = t[1];
|
|
205
|
-
t = op;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
if (t && _.label < t[2]) {
|
|
209
|
-
_.label = t[2];
|
|
210
|
-
_.ops.push(op);
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
if (t[2])
|
|
214
|
-
_.ops.pop();
|
|
215
|
-
_.trys.pop();
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
op = body.call(thisArg, _);
|
|
219
|
-
} catch (e) {
|
|
220
|
-
op = [6, e];
|
|
221
|
-
y = 0;
|
|
222
|
-
} finally {
|
|
223
|
-
f = t = 0;
|
|
224
|
-
}
|
|
225
|
-
if (op[0] & 5)
|
|
226
|
-
throw op[1];
|
|
227
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
__createBinding = function(o, m, k, k2) {
|
|
231
|
-
if (k2 === void 0)
|
|
232
|
-
k2 = k;
|
|
233
|
-
o[k2] = m[k];
|
|
234
|
-
};
|
|
235
|
-
__exportStar = function(m, exports2) {
|
|
236
|
-
for (var p in m)
|
|
237
|
-
if (p !== "default" && !exports2.hasOwnProperty(p))
|
|
238
|
-
exports2[p] = m[p];
|
|
239
|
-
};
|
|
240
|
-
__values = function(o) {
|
|
241
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
242
|
-
if (m)
|
|
243
|
-
return m.call(o);
|
|
244
|
-
if (o && typeof o.length === "number")
|
|
245
|
-
return {
|
|
246
|
-
next: function() {
|
|
247
|
-
if (o && i >= o.length)
|
|
248
|
-
o = void 0;
|
|
249
|
-
return { value: o && o[i++], done: !o };
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
253
|
-
};
|
|
254
|
-
__read = function(o, n) {
|
|
255
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
256
|
-
if (!m)
|
|
257
|
-
return o;
|
|
258
|
-
var i = m.call(o), r, ar = [], e;
|
|
259
|
-
try {
|
|
260
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
261
|
-
ar.push(r.value);
|
|
262
|
-
} catch (error) {
|
|
263
|
-
e = { error };
|
|
264
|
-
} finally {
|
|
265
|
-
try {
|
|
266
|
-
if (r && !r.done && (m = i["return"]))
|
|
267
|
-
m.call(i);
|
|
268
|
-
} finally {
|
|
269
|
-
if (e)
|
|
270
|
-
throw e.error;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return ar;
|
|
274
|
-
};
|
|
275
|
-
__spread = function() {
|
|
276
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
277
|
-
ar = ar.concat(__read(arguments[i]));
|
|
278
|
-
return ar;
|
|
279
|
-
};
|
|
280
|
-
__spreadArrays = function() {
|
|
281
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
282
|
-
s += arguments[i].length;
|
|
283
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
284
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
285
|
-
r[k] = a[j];
|
|
286
|
-
return r;
|
|
287
|
-
};
|
|
288
|
-
__await = function(v) {
|
|
289
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
290
|
-
};
|
|
291
|
-
__asyncGenerator = function(thisArg, _arguments, generator) {
|
|
292
|
-
if (!Symbol.asyncIterator)
|
|
293
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
294
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
295
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
296
|
-
return this;
|
|
297
|
-
}, i;
|
|
298
|
-
function verb(n) {
|
|
299
|
-
if (g[n])
|
|
300
|
-
i[n] = function(v) {
|
|
301
|
-
return new Promise(function(a, b) {
|
|
302
|
-
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
function resume(n, v) {
|
|
307
|
-
try {
|
|
308
|
-
step(g[n](v));
|
|
309
|
-
} catch (e) {
|
|
310
|
-
settle(q[0][3], e);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
function step(r) {
|
|
314
|
-
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
315
|
-
}
|
|
316
|
-
function fulfill(value) {
|
|
317
|
-
resume("next", value);
|
|
318
|
-
}
|
|
319
|
-
function reject(value) {
|
|
320
|
-
resume("throw", value);
|
|
321
|
-
}
|
|
322
|
-
function settle(f, v) {
|
|
323
|
-
if (f(v), q.shift(), q.length)
|
|
324
|
-
resume(q[0][0], q[0][1]);
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
__asyncDelegator = function(o) {
|
|
328
|
-
var i, p;
|
|
329
|
-
return i = {}, verb("next"), verb("throw", function(e) {
|
|
330
|
-
throw e;
|
|
331
|
-
}), verb("return"), i[Symbol.iterator] = function() {
|
|
332
|
-
return this;
|
|
333
|
-
}, i;
|
|
334
|
-
function verb(n, f) {
|
|
335
|
-
i[n] = o[n] ? function(v) {
|
|
336
|
-
return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v;
|
|
337
|
-
} : f;
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
__asyncValues = function(o) {
|
|
341
|
-
if (!Symbol.asyncIterator)
|
|
342
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
343
|
-
var m = o[Symbol.asyncIterator], i;
|
|
344
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
345
|
-
return this;
|
|
346
|
-
}, i);
|
|
347
|
-
function verb(n) {
|
|
348
|
-
i[n] = o[n] && function(v) {
|
|
349
|
-
return new Promise(function(resolve, reject) {
|
|
350
|
-
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
351
|
-
});
|
|
352
|
-
};
|
|
353
|
-
}
|
|
354
|
-
function settle(resolve, reject, d, v) {
|
|
355
|
-
Promise.resolve(v).then(function(v2) {
|
|
356
|
-
resolve({ value: v2, done: d });
|
|
357
|
-
}, reject);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
__makeTemplateObject = function(cooked, raw) {
|
|
361
|
-
if (Object.defineProperty) {
|
|
362
|
-
Object.defineProperty(cooked, "raw", { value: raw });
|
|
363
|
-
} else {
|
|
364
|
-
cooked.raw = raw;
|
|
365
|
-
}
|
|
366
|
-
return cooked;
|
|
367
|
-
};
|
|
368
|
-
__importStar = function(mod) {
|
|
369
|
-
if (mod && mod.__esModule)
|
|
370
|
-
return mod;
|
|
371
|
-
var result = {};
|
|
372
|
-
if (mod != null) {
|
|
373
|
-
for (var k in mod)
|
|
374
|
-
if (Object.hasOwnProperty.call(mod, k))
|
|
375
|
-
result[k] = mod[k];
|
|
376
|
-
}
|
|
377
|
-
result["default"] = mod;
|
|
378
|
-
return result;
|
|
379
|
-
};
|
|
380
|
-
__importDefault = function(mod) {
|
|
381
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
382
|
-
};
|
|
383
|
-
__classPrivateFieldGet = function(receiver, privateMap) {
|
|
384
|
-
if (!privateMap.has(receiver)) {
|
|
385
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
386
|
-
}
|
|
387
|
-
return privateMap.get(receiver);
|
|
388
|
-
};
|
|
389
|
-
__classPrivateFieldSet = function(receiver, privateMap, value) {
|
|
390
|
-
if (!privateMap.has(receiver)) {
|
|
391
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
392
|
-
}
|
|
393
|
-
privateMap.set(receiver, value);
|
|
394
|
-
return value;
|
|
395
|
-
};
|
|
396
|
-
exporter("__extends", __extends);
|
|
397
|
-
exporter("__assign", __assign);
|
|
398
|
-
exporter("__rest", __rest);
|
|
399
|
-
exporter("__decorate", __decorate);
|
|
400
|
-
exporter("__param", __param);
|
|
401
|
-
exporter("__metadata", __metadata);
|
|
402
|
-
exporter("__awaiter", __awaiter);
|
|
403
|
-
exporter("__generator", __generator);
|
|
404
|
-
exporter("__exportStar", __exportStar);
|
|
405
|
-
exporter("__createBinding", __createBinding);
|
|
406
|
-
exporter("__values", __values);
|
|
407
|
-
exporter("__read", __read);
|
|
408
|
-
exporter("__spread", __spread);
|
|
409
|
-
exporter("__spreadArrays", __spreadArrays);
|
|
410
|
-
exporter("__await", __await);
|
|
411
|
-
exporter("__asyncGenerator", __asyncGenerator);
|
|
412
|
-
exporter("__asyncDelegator", __asyncDelegator);
|
|
413
|
-
exporter("__asyncValues", __asyncValues);
|
|
414
|
-
exporter("__makeTemplateObject", __makeTemplateObject);
|
|
415
|
-
exporter("__importStar", __importStar);
|
|
416
|
-
exporter("__importDefault", __importDefault);
|
|
417
|
-
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
|
|
418
|
-
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
// node_modules/@aws-crypto/sha256-js/build/constants.js
|
|
424
|
-
var require_constants = __commonJS({
|
|
425
|
-
"node_modules/@aws-crypto/sha256-js/build/constants.js"(exports) {
|
|
426
|
-
"use strict";
|
|
427
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
428
|
-
exports.MAX_HASHABLE_LENGTH = exports.INIT = exports.KEY = exports.DIGEST_LENGTH = exports.BLOCK_SIZE = void 0;
|
|
429
|
-
exports.BLOCK_SIZE = 64;
|
|
430
|
-
exports.DIGEST_LENGTH = 32;
|
|
431
|
-
exports.KEY = new Uint32Array([
|
|
432
|
-
1116352408,
|
|
433
|
-
1899447441,
|
|
434
|
-
3049323471,
|
|
435
|
-
3921009573,
|
|
436
|
-
961987163,
|
|
437
|
-
1508970993,
|
|
438
|
-
2453635748,
|
|
439
|
-
2870763221,
|
|
440
|
-
3624381080,
|
|
441
|
-
310598401,
|
|
442
|
-
607225278,
|
|
443
|
-
1426881987,
|
|
444
|
-
1925078388,
|
|
445
|
-
2162078206,
|
|
446
|
-
2614888103,
|
|
447
|
-
3248222580,
|
|
448
|
-
3835390401,
|
|
449
|
-
4022224774,
|
|
450
|
-
264347078,
|
|
451
|
-
604807628,
|
|
452
|
-
770255983,
|
|
453
|
-
1249150122,
|
|
454
|
-
1555081692,
|
|
455
|
-
1996064986,
|
|
456
|
-
2554220882,
|
|
457
|
-
2821834349,
|
|
458
|
-
2952996808,
|
|
459
|
-
3210313671,
|
|
460
|
-
3336571891,
|
|
461
|
-
3584528711,
|
|
462
|
-
113926993,
|
|
463
|
-
338241895,
|
|
464
|
-
666307205,
|
|
465
|
-
773529912,
|
|
466
|
-
1294757372,
|
|
467
|
-
1396182291,
|
|
468
|
-
1695183700,
|
|
469
|
-
1986661051,
|
|
470
|
-
2177026350,
|
|
471
|
-
2456956037,
|
|
472
|
-
2730485921,
|
|
473
|
-
2820302411,
|
|
474
|
-
3259730800,
|
|
475
|
-
3345764771,
|
|
476
|
-
3516065817,
|
|
477
|
-
3600352804,
|
|
478
|
-
4094571909,
|
|
479
|
-
275423344,
|
|
480
|
-
430227734,
|
|
481
|
-
506948616,
|
|
482
|
-
659060556,
|
|
483
|
-
883997877,
|
|
484
|
-
958139571,
|
|
485
|
-
1322822218,
|
|
486
|
-
1537002063,
|
|
487
|
-
1747873779,
|
|
488
|
-
1955562222,
|
|
489
|
-
2024104815,
|
|
490
|
-
2227730452,
|
|
491
|
-
2361852424,
|
|
492
|
-
2428436474,
|
|
493
|
-
2756734187,
|
|
494
|
-
3204031479,
|
|
495
|
-
3329325298
|
|
496
|
-
]);
|
|
497
|
-
exports.INIT = [
|
|
498
|
-
1779033703,
|
|
499
|
-
3144134277,
|
|
500
|
-
1013904242,
|
|
501
|
-
2773480762,
|
|
502
|
-
1359893119,
|
|
503
|
-
2600822924,
|
|
504
|
-
528734635,
|
|
505
|
-
1541459225
|
|
506
|
-
];
|
|
507
|
-
exports.MAX_HASHABLE_LENGTH = Math.pow(2, 53) - 1;
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
|
|
511
|
-
// node_modules/@aws-crypto/sha256-js/build/RawSha256.js
|
|
512
|
-
var require_RawSha256 = __commonJS({
|
|
513
|
-
"node_modules/@aws-crypto/sha256-js/build/RawSha256.js"(exports) {
|
|
514
|
-
"use strict";
|
|
515
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
516
|
-
exports.RawSha256 = void 0;
|
|
517
|
-
var constants_1 = require_constants();
|
|
518
|
-
var RawSha256 = function() {
|
|
519
|
-
function RawSha2562() {
|
|
520
|
-
this.state = Int32Array.from(constants_1.INIT);
|
|
521
|
-
this.temp = new Int32Array(64);
|
|
522
|
-
this.buffer = new Uint8Array(64);
|
|
523
|
-
this.bufferLength = 0;
|
|
524
|
-
this.bytesHashed = 0;
|
|
525
|
-
this.finished = false;
|
|
526
|
-
}
|
|
527
|
-
RawSha2562.prototype.update = function(data) {
|
|
528
|
-
if (this.finished) {
|
|
529
|
-
throw new Error("Attempted to update an already finished hash.");
|
|
530
|
-
}
|
|
531
|
-
var position = 0;
|
|
532
|
-
var byteLength = data.byteLength;
|
|
533
|
-
this.bytesHashed += byteLength;
|
|
534
|
-
if (this.bytesHashed * 8 > constants_1.MAX_HASHABLE_LENGTH) {
|
|
535
|
-
throw new Error("Cannot hash more than 2^53 - 1 bits");
|
|
536
|
-
}
|
|
537
|
-
while (byteLength > 0) {
|
|
538
|
-
this.buffer[this.bufferLength++] = data[position++];
|
|
539
|
-
byteLength--;
|
|
540
|
-
if (this.bufferLength === constants_1.BLOCK_SIZE) {
|
|
541
|
-
this.hashBuffer();
|
|
542
|
-
this.bufferLength = 0;
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
};
|
|
546
|
-
RawSha2562.prototype.digest = function() {
|
|
547
|
-
if (!this.finished) {
|
|
548
|
-
var bitsHashed = this.bytesHashed * 8;
|
|
549
|
-
var bufferView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
550
|
-
var undecoratedLength = this.bufferLength;
|
|
551
|
-
bufferView.setUint8(this.bufferLength++, 128);
|
|
552
|
-
if (undecoratedLength % constants_1.BLOCK_SIZE >= constants_1.BLOCK_SIZE - 8) {
|
|
553
|
-
for (var i = this.bufferLength; i < constants_1.BLOCK_SIZE; i++) {
|
|
554
|
-
bufferView.setUint8(i, 0);
|
|
555
|
-
}
|
|
556
|
-
this.hashBuffer();
|
|
557
|
-
this.bufferLength = 0;
|
|
558
|
-
}
|
|
559
|
-
for (var i = this.bufferLength; i < constants_1.BLOCK_SIZE - 8; i++) {
|
|
560
|
-
bufferView.setUint8(i, 0);
|
|
561
|
-
}
|
|
562
|
-
bufferView.setUint32(constants_1.BLOCK_SIZE - 8, Math.floor(bitsHashed / 4294967296), true);
|
|
563
|
-
bufferView.setUint32(constants_1.BLOCK_SIZE - 4, bitsHashed);
|
|
564
|
-
this.hashBuffer();
|
|
565
|
-
this.finished = true;
|
|
566
|
-
}
|
|
567
|
-
var out = new Uint8Array(constants_1.DIGEST_LENGTH);
|
|
568
|
-
for (var i = 0; i < 8; i++) {
|
|
569
|
-
out[i * 4] = this.state[i] >>> 24 & 255;
|
|
570
|
-
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
|
|
571
|
-
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
|
|
572
|
-
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
|
|
573
|
-
}
|
|
574
|
-
return out;
|
|
575
|
-
};
|
|
576
|
-
RawSha2562.prototype.hashBuffer = function() {
|
|
577
|
-
var _a = this, buffer = _a.buffer, state = _a.state;
|
|
578
|
-
var state0 = state[0], state1 = state[1], state2 = state[2], state3 = state[3], state4 = state[4], state5 = state[5], state6 = state[6], state7 = state[7];
|
|
579
|
-
for (var i = 0; i < constants_1.BLOCK_SIZE; i++) {
|
|
580
|
-
if (i < 16) {
|
|
581
|
-
this.temp[i] = (buffer[i * 4] & 255) << 24 | (buffer[i * 4 + 1] & 255) << 16 | (buffer[i * 4 + 2] & 255) << 8 | buffer[i * 4 + 3] & 255;
|
|
582
|
-
} else {
|
|
583
|
-
var u = this.temp[i - 2];
|
|
584
|
-
var t1_1 = (u >>> 17 | u << 15) ^ (u >>> 19 | u << 13) ^ u >>> 10;
|
|
585
|
-
u = this.temp[i - 15];
|
|
586
|
-
var t2_1 = (u >>> 7 | u << 25) ^ (u >>> 18 | u << 14) ^ u >>> 3;
|
|
587
|
-
this.temp[i] = (t1_1 + this.temp[i - 7] | 0) + (t2_1 + this.temp[i - 16] | 0);
|
|
588
|
-
}
|
|
589
|
-
var t1 = (((state4 >>> 6 | state4 << 26) ^ (state4 >>> 11 | state4 << 21) ^ (state4 >>> 25 | state4 << 7)) + (state4 & state5 ^ ~state4 & state6) | 0) + (state7 + (constants_1.KEY[i] + this.temp[i] | 0) | 0) | 0;
|
|
590
|
-
var t2 = ((state0 >>> 2 | state0 << 30) ^ (state0 >>> 13 | state0 << 19) ^ (state0 >>> 22 | state0 << 10)) + (state0 & state1 ^ state0 & state2 ^ state1 & state2) | 0;
|
|
591
|
-
state7 = state6;
|
|
592
|
-
state6 = state5;
|
|
593
|
-
state5 = state4;
|
|
594
|
-
state4 = state3 + t1 | 0;
|
|
595
|
-
state3 = state2;
|
|
596
|
-
state2 = state1;
|
|
597
|
-
state1 = state0;
|
|
598
|
-
state0 = t1 + t2 | 0;
|
|
599
|
-
}
|
|
600
|
-
state[0] += state0;
|
|
601
|
-
state[1] += state1;
|
|
602
|
-
state[2] += state2;
|
|
603
|
-
state[3] += state3;
|
|
604
|
-
state[4] += state4;
|
|
605
|
-
state[5] += state5;
|
|
606
|
-
state[6] += state6;
|
|
607
|
-
state[7] += state7;
|
|
608
|
-
};
|
|
609
|
-
return RawSha2562;
|
|
610
|
-
}();
|
|
611
|
-
exports.RawSha256 = RawSha256;
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
|
|
615
|
-
// node_modules/@aws-sdk/util-utf8-browser/dist-cjs/pureJs.js
|
|
616
|
-
var require_pureJs = __commonJS({
|
|
617
|
-
"node_modules/@aws-sdk/util-utf8-browser/dist-cjs/pureJs.js"(exports) {
|
|
618
|
-
"use strict";
|
|
619
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
620
|
-
exports.toUtf8 = exports.fromUtf8 = void 0;
|
|
621
|
-
var fromUtf8 = (input) => {
|
|
622
|
-
const bytes = [];
|
|
623
|
-
for (let i = 0, len = input.length; i < len; i++) {
|
|
624
|
-
const value = input.charCodeAt(i);
|
|
625
|
-
if (value < 128) {
|
|
626
|
-
bytes.push(value);
|
|
627
|
-
} else if (value < 2048) {
|
|
628
|
-
bytes.push(value >> 6 | 192, value & 63 | 128);
|
|
629
|
-
} else if (i + 1 < input.length && (value & 64512) === 55296 && (input.charCodeAt(i + 1) & 64512) === 56320) {
|
|
630
|
-
const surrogatePair = 65536 + ((value & 1023) << 10) + (input.charCodeAt(++i) & 1023);
|
|
631
|
-
bytes.push(surrogatePair >> 18 | 240, surrogatePair >> 12 & 63 | 128, surrogatePair >> 6 & 63 | 128, surrogatePair & 63 | 128);
|
|
632
|
-
} else {
|
|
633
|
-
bytes.push(value >> 12 | 224, value >> 6 & 63 | 128, value & 63 | 128);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
return Uint8Array.from(bytes);
|
|
637
|
-
};
|
|
638
|
-
exports.fromUtf8 = fromUtf8;
|
|
639
|
-
var toUtf8 = (input) => {
|
|
640
|
-
let decoded = "";
|
|
641
|
-
for (let i = 0, len = input.length; i < len; i++) {
|
|
642
|
-
const byte = input[i];
|
|
643
|
-
if (byte < 128) {
|
|
644
|
-
decoded += String.fromCharCode(byte);
|
|
645
|
-
} else if (192 <= byte && byte < 224) {
|
|
646
|
-
const nextByte = input[++i];
|
|
647
|
-
decoded += String.fromCharCode((byte & 31) << 6 | nextByte & 63);
|
|
648
|
-
} else if (240 <= byte && byte < 365) {
|
|
649
|
-
const surrogatePair = [byte, input[++i], input[++i], input[++i]];
|
|
650
|
-
const encoded = "%" + surrogatePair.map((byteValue) => byteValue.toString(16)).join("%");
|
|
651
|
-
decoded += decodeURIComponent(encoded);
|
|
652
|
-
} else {
|
|
653
|
-
decoded += String.fromCharCode((byte & 15) << 12 | (input[++i] & 63) << 6 | input[++i] & 63);
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
return decoded;
|
|
657
|
-
};
|
|
658
|
-
exports.toUtf8 = toUtf8;
|
|
659
|
-
}
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
// node_modules/@aws-sdk/util-utf8-browser/dist-cjs/whatwgEncodingApi.js
|
|
663
|
-
var require_whatwgEncodingApi = __commonJS({
|
|
664
|
-
"node_modules/@aws-sdk/util-utf8-browser/dist-cjs/whatwgEncodingApi.js"(exports) {
|
|
665
|
-
"use strict";
|
|
666
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
667
|
-
exports.toUtf8 = exports.fromUtf8 = void 0;
|
|
668
|
-
function fromUtf8(input) {
|
|
669
|
-
return new TextEncoder().encode(input);
|
|
670
|
-
}
|
|
671
|
-
exports.fromUtf8 = fromUtf8;
|
|
672
|
-
function toUtf8(input) {
|
|
673
|
-
return new TextDecoder("utf-8").decode(input);
|
|
674
|
-
}
|
|
675
|
-
exports.toUtf8 = toUtf8;
|
|
676
|
-
}
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
// node_modules/@aws-sdk/util-utf8-browser/dist-cjs/index.js
|
|
680
|
-
var require_dist_cjs = __commonJS({
|
|
681
|
-
"node_modules/@aws-sdk/util-utf8-browser/dist-cjs/index.js"(exports) {
|
|
682
|
-
"use strict";
|
|
683
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
684
|
-
exports.toUtf8 = exports.fromUtf8 = void 0;
|
|
685
|
-
var pureJs_1 = require_pureJs();
|
|
686
|
-
var whatwgEncodingApi_1 = require_whatwgEncodingApi();
|
|
687
|
-
var fromUtf8 = (input) => typeof TextEncoder === "function" ? (0, whatwgEncodingApi_1.fromUtf8)(input) : (0, pureJs_1.fromUtf8)(input);
|
|
688
|
-
exports.fromUtf8 = fromUtf8;
|
|
689
|
-
var toUtf8 = (input) => typeof TextDecoder === "function" ? (0, whatwgEncodingApi_1.toUtf8)(input) : (0, pureJs_1.toUtf8)(input);
|
|
690
|
-
exports.toUtf8 = toUtf8;
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
|
|
694
|
-
// node_modules/@aws-crypto/util/build/convertToBuffer.js
|
|
695
|
-
var require_convertToBuffer = __commonJS({
|
|
696
|
-
"node_modules/@aws-crypto/util/build/convertToBuffer.js"(exports) {
|
|
697
|
-
"use strict";
|
|
698
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
699
|
-
exports.convertToBuffer = void 0;
|
|
700
|
-
var util_utf8_browser_1 = require_dist_cjs();
|
|
701
|
-
var fromUtf8 = typeof Buffer !== "undefined" && Buffer.from ? function(input) {
|
|
702
|
-
return Buffer.from(input, "utf8");
|
|
703
|
-
} : util_utf8_browser_1.fromUtf8;
|
|
704
|
-
function convertToBuffer(data) {
|
|
705
|
-
if (data instanceof Uint8Array)
|
|
706
|
-
return data;
|
|
707
|
-
if (typeof data === "string") {
|
|
708
|
-
return fromUtf8(data);
|
|
709
|
-
}
|
|
710
|
-
if (ArrayBuffer.isView(data)) {
|
|
711
|
-
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
712
|
-
}
|
|
713
|
-
return new Uint8Array(data);
|
|
714
|
-
}
|
|
715
|
-
exports.convertToBuffer = convertToBuffer;
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
// node_modules/@aws-crypto/util/build/isEmptyData.js
|
|
720
|
-
var require_isEmptyData = __commonJS({
|
|
721
|
-
"node_modules/@aws-crypto/util/build/isEmptyData.js"(exports) {
|
|
722
|
-
"use strict";
|
|
723
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
724
|
-
exports.isEmptyData = void 0;
|
|
725
|
-
function isEmptyData(data) {
|
|
726
|
-
if (typeof data === "string") {
|
|
727
|
-
return data.length === 0;
|
|
728
|
-
}
|
|
729
|
-
return data.byteLength === 0;
|
|
730
|
-
}
|
|
731
|
-
exports.isEmptyData = isEmptyData;
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
|
|
735
|
-
// node_modules/@aws-crypto/util/build/numToUint8.js
|
|
736
|
-
var require_numToUint8 = __commonJS({
|
|
737
|
-
"node_modules/@aws-crypto/util/build/numToUint8.js"(exports) {
|
|
738
|
-
"use strict";
|
|
739
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
740
|
-
exports.numToUint8 = void 0;
|
|
741
|
-
function numToUint8(num) {
|
|
742
|
-
return new Uint8Array([
|
|
743
|
-
(num & 4278190080) >> 24,
|
|
744
|
-
(num & 16711680) >> 16,
|
|
745
|
-
(num & 65280) >> 8,
|
|
746
|
-
num & 255
|
|
747
|
-
]);
|
|
748
|
-
}
|
|
749
|
-
exports.numToUint8 = numToUint8;
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
|
|
753
|
-
// node_modules/@aws-crypto/util/build/uint32ArrayFrom.js
|
|
754
|
-
var require_uint32ArrayFrom = __commonJS({
|
|
755
|
-
"node_modules/@aws-crypto/util/build/uint32ArrayFrom.js"(exports) {
|
|
756
|
-
"use strict";
|
|
757
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
758
|
-
exports.uint32ArrayFrom = void 0;
|
|
759
|
-
function uint32ArrayFrom(a_lookUpTable) {
|
|
760
|
-
if (!Uint32Array.from) {
|
|
761
|
-
var return_array = new Uint32Array(a_lookUpTable.length);
|
|
762
|
-
var a_index = 0;
|
|
763
|
-
while (a_index < a_lookUpTable.length) {
|
|
764
|
-
return_array[a_index] = a_lookUpTable[a_index];
|
|
765
|
-
a_index += 1;
|
|
766
|
-
}
|
|
767
|
-
return return_array;
|
|
768
|
-
}
|
|
769
|
-
return Uint32Array.from(a_lookUpTable);
|
|
770
|
-
}
|
|
771
|
-
exports.uint32ArrayFrom = uint32ArrayFrom;
|
|
772
|
-
}
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
// node_modules/@aws-crypto/util/build/index.js
|
|
776
|
-
var require_build = __commonJS({
|
|
777
|
-
"node_modules/@aws-crypto/util/build/index.js"(exports) {
|
|
778
|
-
"use strict";
|
|
779
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
780
|
-
exports.uint32ArrayFrom = exports.numToUint8 = exports.isEmptyData = exports.convertToBuffer = void 0;
|
|
781
|
-
var convertToBuffer_1 = require_convertToBuffer();
|
|
782
|
-
Object.defineProperty(exports, "convertToBuffer", { enumerable: true, get: function() {
|
|
783
|
-
return convertToBuffer_1.convertToBuffer;
|
|
784
|
-
} });
|
|
785
|
-
var isEmptyData_1 = require_isEmptyData();
|
|
786
|
-
Object.defineProperty(exports, "isEmptyData", { enumerable: true, get: function() {
|
|
787
|
-
return isEmptyData_1.isEmptyData;
|
|
788
|
-
} });
|
|
789
|
-
var numToUint8_1 = require_numToUint8();
|
|
790
|
-
Object.defineProperty(exports, "numToUint8", { enumerable: true, get: function() {
|
|
791
|
-
return numToUint8_1.numToUint8;
|
|
792
|
-
} });
|
|
793
|
-
var uint32ArrayFrom_1 = require_uint32ArrayFrom();
|
|
794
|
-
Object.defineProperty(exports, "uint32ArrayFrom", { enumerable: true, get: function() {
|
|
795
|
-
return uint32ArrayFrom_1.uint32ArrayFrom;
|
|
796
|
-
} });
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
|
|
800
|
-
// node_modules/@aws-crypto/sha256-js/build/jsSha256.js
|
|
801
|
-
var require_jsSha256 = __commonJS({
|
|
802
|
-
"node_modules/@aws-crypto/sha256-js/build/jsSha256.js"(exports) {
|
|
803
|
-
"use strict";
|
|
804
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
805
|
-
exports.Sha256 = void 0;
|
|
806
|
-
var tslib_1 = require_tslib();
|
|
807
|
-
var constants_1 = require_constants();
|
|
808
|
-
var RawSha256_1 = require_RawSha256();
|
|
809
|
-
var util_1 = require_build();
|
|
810
|
-
var Sha2562 = function() {
|
|
811
|
-
function Sha2563(secret) {
|
|
812
|
-
this.hash = new RawSha256_1.RawSha256();
|
|
813
|
-
if (secret) {
|
|
814
|
-
this.outer = new RawSha256_1.RawSha256();
|
|
815
|
-
var inner = bufferFromSecret(secret);
|
|
816
|
-
var outer = new Uint8Array(constants_1.BLOCK_SIZE);
|
|
817
|
-
outer.set(inner);
|
|
818
|
-
for (var i = 0; i < constants_1.BLOCK_SIZE; i++) {
|
|
819
|
-
inner[i] ^= 54;
|
|
820
|
-
outer[i] ^= 92;
|
|
821
|
-
}
|
|
822
|
-
this.hash.update(inner);
|
|
823
|
-
this.outer.update(outer);
|
|
824
|
-
for (var i = 0; i < inner.byteLength; i++) {
|
|
825
|
-
inner[i] = 0;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
}
|
|
829
|
-
Sha2563.prototype.update = function(toHash) {
|
|
830
|
-
if ((0, util_1.isEmptyData)(toHash) || this.error) {
|
|
831
|
-
return;
|
|
832
|
-
}
|
|
833
|
-
try {
|
|
834
|
-
this.hash.update((0, util_1.convertToBuffer)(toHash));
|
|
835
|
-
} catch (e) {
|
|
836
|
-
this.error = e;
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
Sha2563.prototype.digestSync = function() {
|
|
840
|
-
if (this.error) {
|
|
841
|
-
throw this.error;
|
|
842
|
-
}
|
|
843
|
-
if (this.outer) {
|
|
844
|
-
if (!this.outer.finished) {
|
|
845
|
-
this.outer.update(this.hash.digest());
|
|
846
|
-
}
|
|
847
|
-
return this.outer.digest();
|
|
848
|
-
}
|
|
849
|
-
return this.hash.digest();
|
|
850
|
-
};
|
|
851
|
-
Sha2563.prototype.digest = function() {
|
|
852
|
-
return tslib_1.__awaiter(this, void 0, void 0, function() {
|
|
853
|
-
return tslib_1.__generator(this, function(_a) {
|
|
854
|
-
return [2, this.digestSync()];
|
|
855
|
-
});
|
|
856
|
-
});
|
|
857
|
-
};
|
|
858
|
-
return Sha2563;
|
|
859
|
-
}();
|
|
860
|
-
exports.Sha256 = Sha2562;
|
|
861
|
-
function bufferFromSecret(secret) {
|
|
862
|
-
var input = (0, util_1.convertToBuffer)(secret);
|
|
863
|
-
if (input.byteLength > constants_1.BLOCK_SIZE) {
|
|
864
|
-
var bufferHash = new RawSha256_1.RawSha256();
|
|
865
|
-
bufferHash.update(input);
|
|
866
|
-
input = bufferHash.digest();
|
|
867
|
-
}
|
|
868
|
-
var buffer = new Uint8Array(constants_1.BLOCK_SIZE);
|
|
869
|
-
buffer.set(input);
|
|
870
|
-
return buffer;
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
});
|
|
874
|
-
|
|
875
|
-
// node_modules/@aws-crypto/sha256-js/build/index.js
|
|
876
|
-
var require_build2 = __commonJS({
|
|
877
|
-
"node_modules/@aws-crypto/sha256-js/build/index.js"(exports) {
|
|
878
|
-
"use strict";
|
|
879
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
880
|
-
var tslib_1 = require_tslib();
|
|
881
|
-
tslib_1.__exportStar(require_jsSha256(), exports);
|
|
882
|
-
}
|
|
883
|
-
});
|
|
884
|
-
|
|
885
1
|
// src/instantiateFaustModuleFromFile.ts
|
|
886
2
|
var instantiateFaustModuleFromFile = async (jsFile, dataFile = jsFile.replace(/c?js$/, "data"), wasmFile = jsFile.replace(/c?js$/, "wasm")) => {
|
|
887
3
|
var _a, _b;
|
|
@@ -1059,11 +175,7 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
1059
175
|
const { FaustMonoWebAudioDsp: FaustMonoWebAudioDsp2 } = dependencies;
|
|
1060
176
|
const { factory, sampleSize } = options.processorOptions;
|
|
1061
177
|
const instance = FaustWasmInstantiator2.createSyncMonoDSPInstance(factory);
|
|
1062
|
-
this.fDSPCode = new FaustMonoWebAudioDsp2(instance, sampleRate, sampleSize, 128);
|
|
1063
|
-
if (this.fDSPCode.hasSoundfiles()) {
|
|
1064
|
-
console.error("FaustAudioWorkletProcessor: Soundfile support is not implemented yet, switch to ScriptProcessorNode for now");
|
|
1065
|
-
return;
|
|
1066
|
-
}
|
|
178
|
+
this.fDSPCode = new FaustMonoWebAudioDsp2(instance, sampleRate, sampleSize, 128, factory.soundfiles);
|
|
1067
179
|
this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: "param" }));
|
|
1068
180
|
this.fDSPCode.start();
|
|
1069
181
|
}
|
|
@@ -1088,11 +200,8 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
1088
200
|
const { FaustPolyWebAudioDsp: FaustPolyWebAudioDsp3 } = dependencies;
|
|
1089
201
|
const { voiceFactory, mixerModule, voices, effectFactory, sampleSize } = options.processorOptions;
|
|
1090
202
|
const instance = FaustWasmInstantiator2.createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory);
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
console.error("FaustAudioWorkletProcessor: Soundfile support is not implemented yet, switch to ScriptProcessorNode for now");
|
|
1094
|
-
return;
|
|
1095
|
-
}
|
|
203
|
+
const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
|
|
204
|
+
this.fDSPCode = new FaustPolyWebAudioDsp3(instance, sampleRate, sampleSize, 128, soundfiles);
|
|
1096
205
|
this.port.onmessage = (e) => this.handleMessageAux(e);
|
|
1097
206
|
this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: "param" }));
|
|
1098
207
|
this.fDSPCode.start();
|
|
@@ -1109,6 +218,7 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
1109
218
|
else
|
|
1110
219
|
super.midiMessage(data);
|
|
1111
220
|
}
|
|
221
|
+
// Public API
|
|
1112
222
|
keyOn(channel, pitch, velocity) {
|
|
1113
223
|
this.fDSPCode.keyOn(channel, pitch, velocity);
|
|
1114
224
|
}
|
|
@@ -1197,13 +307,21 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
1197
307
|
super(options);
|
|
1198
308
|
this.paramValuesCache = {};
|
|
1199
309
|
this.destroyed = false;
|
|
310
|
+
/** Pointer of next start sample to write of the FFT input window */
|
|
1200
311
|
this.$inputWrite = 0;
|
|
312
|
+
/** Pointer of next start sample to read of the FFT input window */
|
|
1201
313
|
this.$inputRead = 0;
|
|
314
|
+
/** Pointer of next start sample to write of the FFT output window */
|
|
1202
315
|
this.$outputWrite = 0;
|
|
316
|
+
/** Pointer of next start sample to read of the FFT output window */
|
|
1203
317
|
this.$outputRead = 0;
|
|
318
|
+
/** Not perform in IFFT when reconstruct the audio signal */
|
|
1204
319
|
this.noIFFT = false;
|
|
320
|
+
/** audio data from input, array of channels */
|
|
1205
321
|
this.fftInput = [];
|
|
322
|
+
/** audio data for output, array of channels */
|
|
1206
323
|
this.fftOutput = [];
|
|
324
|
+
/** FFT Overlaps, 1 means no overlap */
|
|
1207
325
|
this.fftOverlap = 0;
|
|
1208
326
|
this.fftHopSize = 0;
|
|
1209
327
|
this.fftSize = 0;
|
|
@@ -1211,6 +329,7 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
1211
329
|
this.fPlotHandler = null;
|
|
1212
330
|
this.fCachedEvents = [];
|
|
1213
331
|
this.fBufferNum = 0;
|
|
332
|
+
this.soundfiles = {};
|
|
1214
333
|
this.windowFunction = null;
|
|
1215
334
|
this.port.onmessage = (e) => this.handleMessageAux(e);
|
|
1216
335
|
const { parameterDescriptors } = this.constructor;
|
|
@@ -1220,6 +339,7 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
1220
339
|
const { factory, sampleSize } = options.processorOptions;
|
|
1221
340
|
this.dspInstance = FaustWasmInstantiator2.createSyncMonoDSPInstance(factory);
|
|
1222
341
|
this.sampleSize = sampleSize;
|
|
342
|
+
this.soundfiles = factory.soundfiles;
|
|
1223
343
|
this.initFFT();
|
|
1224
344
|
}
|
|
1225
345
|
get fftProcessorBufferSize() {
|
|
@@ -1505,7 +625,7 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
1505
625
|
var _a, _b;
|
|
1506
626
|
(_a = this.fDSPCode) == null ? void 0 : _a.stop();
|
|
1507
627
|
(_b = this.fDSPCode) == null ? void 0 : _b.destroy();
|
|
1508
|
-
this.fDSPCode = new FaustMonoWebAudioDsp2(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize);
|
|
628
|
+
this.fDSPCode = new FaustMonoWebAudioDsp2(this.dspInstance, sampleRate, this.sampleSize, this.fftProcessorBufferSize, this.soundfiles);
|
|
1509
629
|
this.fDSPCode.setOutputParamHandler((path, value) => this.port.postMessage({ path, value, type: "param" }));
|
|
1510
630
|
this.fDSPCode.setPlotHandler(this.fPlotHandler);
|
|
1511
631
|
const params = this.fDSPCode.getParams();
|
|
@@ -1543,8 +663,389 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
1543
663
|
};
|
|
1544
664
|
var FaustFFTAudioWorkletProcessor_default = getFaustFFTAudioWorkletProcessor;
|
|
1545
665
|
|
|
666
|
+
// node_modules/tslib/tslib.es6.mjs
|
|
667
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
668
|
+
function adopt(value) {
|
|
669
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
670
|
+
resolve(value);
|
|
671
|
+
});
|
|
672
|
+
}
|
|
673
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
674
|
+
function fulfilled(value) {
|
|
675
|
+
try {
|
|
676
|
+
step(generator.next(value));
|
|
677
|
+
} catch (e) {
|
|
678
|
+
reject(e);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
function rejected(value) {
|
|
682
|
+
try {
|
|
683
|
+
step(generator["throw"](value));
|
|
684
|
+
} catch (e) {
|
|
685
|
+
reject(e);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
function step(result) {
|
|
689
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
690
|
+
}
|
|
691
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
function __generator(thisArg, body) {
|
|
695
|
+
var _ = { label: 0, sent: function() {
|
|
696
|
+
if (t[0] & 1)
|
|
697
|
+
throw t[1];
|
|
698
|
+
return t[1];
|
|
699
|
+
}, trys: [], ops: [] }, f, y, t, g;
|
|
700
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
701
|
+
return this;
|
|
702
|
+
}), g;
|
|
703
|
+
function verb(n) {
|
|
704
|
+
return function(v) {
|
|
705
|
+
return step([n, v]);
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
function step(op) {
|
|
709
|
+
if (f)
|
|
710
|
+
throw new TypeError("Generator is already executing.");
|
|
711
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
|
712
|
+
try {
|
|
713
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
714
|
+
return t;
|
|
715
|
+
if (y = 0, t)
|
|
716
|
+
op = [op[0] & 2, t.value];
|
|
717
|
+
switch (op[0]) {
|
|
718
|
+
case 0:
|
|
719
|
+
case 1:
|
|
720
|
+
t = op;
|
|
721
|
+
break;
|
|
722
|
+
case 4:
|
|
723
|
+
_.label++;
|
|
724
|
+
return { value: op[1], done: false };
|
|
725
|
+
case 5:
|
|
726
|
+
_.label++;
|
|
727
|
+
y = op[1];
|
|
728
|
+
op = [0];
|
|
729
|
+
continue;
|
|
730
|
+
case 7:
|
|
731
|
+
op = _.ops.pop();
|
|
732
|
+
_.trys.pop();
|
|
733
|
+
continue;
|
|
734
|
+
default:
|
|
735
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
736
|
+
_ = 0;
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
740
|
+
_.label = op[1];
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
744
|
+
_.label = t[1];
|
|
745
|
+
t = op;
|
|
746
|
+
break;
|
|
747
|
+
}
|
|
748
|
+
if (t && _.label < t[2]) {
|
|
749
|
+
_.label = t[2];
|
|
750
|
+
_.ops.push(op);
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
if (t[2])
|
|
754
|
+
_.ops.pop();
|
|
755
|
+
_.trys.pop();
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
op = body.call(thisArg, _);
|
|
759
|
+
} catch (e) {
|
|
760
|
+
op = [6, e];
|
|
761
|
+
y = 0;
|
|
762
|
+
} finally {
|
|
763
|
+
f = t = 0;
|
|
764
|
+
}
|
|
765
|
+
if (op[0] & 5)
|
|
766
|
+
throw op[1];
|
|
767
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
// node_modules/@aws-crypto/sha256-js/build/module/constants.js
|
|
772
|
+
var BLOCK_SIZE = 64;
|
|
773
|
+
var DIGEST_LENGTH = 32;
|
|
774
|
+
var KEY = new Uint32Array([
|
|
775
|
+
1116352408,
|
|
776
|
+
1899447441,
|
|
777
|
+
3049323471,
|
|
778
|
+
3921009573,
|
|
779
|
+
961987163,
|
|
780
|
+
1508970993,
|
|
781
|
+
2453635748,
|
|
782
|
+
2870763221,
|
|
783
|
+
3624381080,
|
|
784
|
+
310598401,
|
|
785
|
+
607225278,
|
|
786
|
+
1426881987,
|
|
787
|
+
1925078388,
|
|
788
|
+
2162078206,
|
|
789
|
+
2614888103,
|
|
790
|
+
3248222580,
|
|
791
|
+
3835390401,
|
|
792
|
+
4022224774,
|
|
793
|
+
264347078,
|
|
794
|
+
604807628,
|
|
795
|
+
770255983,
|
|
796
|
+
1249150122,
|
|
797
|
+
1555081692,
|
|
798
|
+
1996064986,
|
|
799
|
+
2554220882,
|
|
800
|
+
2821834349,
|
|
801
|
+
2952996808,
|
|
802
|
+
3210313671,
|
|
803
|
+
3336571891,
|
|
804
|
+
3584528711,
|
|
805
|
+
113926993,
|
|
806
|
+
338241895,
|
|
807
|
+
666307205,
|
|
808
|
+
773529912,
|
|
809
|
+
1294757372,
|
|
810
|
+
1396182291,
|
|
811
|
+
1695183700,
|
|
812
|
+
1986661051,
|
|
813
|
+
2177026350,
|
|
814
|
+
2456956037,
|
|
815
|
+
2730485921,
|
|
816
|
+
2820302411,
|
|
817
|
+
3259730800,
|
|
818
|
+
3345764771,
|
|
819
|
+
3516065817,
|
|
820
|
+
3600352804,
|
|
821
|
+
4094571909,
|
|
822
|
+
275423344,
|
|
823
|
+
430227734,
|
|
824
|
+
506948616,
|
|
825
|
+
659060556,
|
|
826
|
+
883997877,
|
|
827
|
+
958139571,
|
|
828
|
+
1322822218,
|
|
829
|
+
1537002063,
|
|
830
|
+
1747873779,
|
|
831
|
+
1955562222,
|
|
832
|
+
2024104815,
|
|
833
|
+
2227730452,
|
|
834
|
+
2361852424,
|
|
835
|
+
2428436474,
|
|
836
|
+
2756734187,
|
|
837
|
+
3204031479,
|
|
838
|
+
3329325298
|
|
839
|
+
]);
|
|
840
|
+
var INIT = [
|
|
841
|
+
1779033703,
|
|
842
|
+
3144134277,
|
|
843
|
+
1013904242,
|
|
844
|
+
2773480762,
|
|
845
|
+
1359893119,
|
|
846
|
+
2600822924,
|
|
847
|
+
528734635,
|
|
848
|
+
1541459225
|
|
849
|
+
];
|
|
850
|
+
var MAX_HASHABLE_LENGTH = Math.pow(2, 53) - 1;
|
|
851
|
+
|
|
852
|
+
// node_modules/@aws-crypto/sha256-js/build/module/RawSha256.js
|
|
853
|
+
var RawSha256 = (
|
|
854
|
+
/** @class */
|
|
855
|
+
function() {
|
|
856
|
+
function RawSha2562() {
|
|
857
|
+
this.state = Int32Array.from(INIT);
|
|
858
|
+
this.temp = new Int32Array(64);
|
|
859
|
+
this.buffer = new Uint8Array(64);
|
|
860
|
+
this.bufferLength = 0;
|
|
861
|
+
this.bytesHashed = 0;
|
|
862
|
+
this.finished = false;
|
|
863
|
+
}
|
|
864
|
+
RawSha2562.prototype.update = function(data) {
|
|
865
|
+
if (this.finished) {
|
|
866
|
+
throw new Error("Attempted to update an already finished hash.");
|
|
867
|
+
}
|
|
868
|
+
var position = 0;
|
|
869
|
+
var byteLength = data.byteLength;
|
|
870
|
+
this.bytesHashed += byteLength;
|
|
871
|
+
if (this.bytesHashed * 8 > MAX_HASHABLE_LENGTH) {
|
|
872
|
+
throw new Error("Cannot hash more than 2^53 - 1 bits");
|
|
873
|
+
}
|
|
874
|
+
while (byteLength > 0) {
|
|
875
|
+
this.buffer[this.bufferLength++] = data[position++];
|
|
876
|
+
byteLength--;
|
|
877
|
+
if (this.bufferLength === BLOCK_SIZE) {
|
|
878
|
+
this.hashBuffer();
|
|
879
|
+
this.bufferLength = 0;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
};
|
|
883
|
+
RawSha2562.prototype.digest = function() {
|
|
884
|
+
if (!this.finished) {
|
|
885
|
+
var bitsHashed = this.bytesHashed * 8;
|
|
886
|
+
var bufferView = new DataView(this.buffer.buffer, this.buffer.byteOffset, this.buffer.byteLength);
|
|
887
|
+
var undecoratedLength = this.bufferLength;
|
|
888
|
+
bufferView.setUint8(this.bufferLength++, 128);
|
|
889
|
+
if (undecoratedLength % BLOCK_SIZE >= BLOCK_SIZE - 8) {
|
|
890
|
+
for (var i = this.bufferLength; i < BLOCK_SIZE; i++) {
|
|
891
|
+
bufferView.setUint8(i, 0);
|
|
892
|
+
}
|
|
893
|
+
this.hashBuffer();
|
|
894
|
+
this.bufferLength = 0;
|
|
895
|
+
}
|
|
896
|
+
for (var i = this.bufferLength; i < BLOCK_SIZE - 8; i++) {
|
|
897
|
+
bufferView.setUint8(i, 0);
|
|
898
|
+
}
|
|
899
|
+
bufferView.setUint32(BLOCK_SIZE - 8, Math.floor(bitsHashed / 4294967296), true);
|
|
900
|
+
bufferView.setUint32(BLOCK_SIZE - 4, bitsHashed);
|
|
901
|
+
this.hashBuffer();
|
|
902
|
+
this.finished = true;
|
|
903
|
+
}
|
|
904
|
+
var out = new Uint8Array(DIGEST_LENGTH);
|
|
905
|
+
for (var i = 0; i < 8; i++) {
|
|
906
|
+
out[i * 4] = this.state[i] >>> 24 & 255;
|
|
907
|
+
out[i * 4 + 1] = this.state[i] >>> 16 & 255;
|
|
908
|
+
out[i * 4 + 2] = this.state[i] >>> 8 & 255;
|
|
909
|
+
out[i * 4 + 3] = this.state[i] >>> 0 & 255;
|
|
910
|
+
}
|
|
911
|
+
return out;
|
|
912
|
+
};
|
|
913
|
+
RawSha2562.prototype.hashBuffer = function() {
|
|
914
|
+
var _a = this, buffer = _a.buffer, state = _a.state;
|
|
915
|
+
var state0 = state[0], state1 = state[1], state2 = state[2], state3 = state[3], state4 = state[4], state5 = state[5], state6 = state[6], state7 = state[7];
|
|
916
|
+
for (var i = 0; i < BLOCK_SIZE; i++) {
|
|
917
|
+
if (i < 16) {
|
|
918
|
+
this.temp[i] = (buffer[i * 4] & 255) << 24 | (buffer[i * 4 + 1] & 255) << 16 | (buffer[i * 4 + 2] & 255) << 8 | buffer[i * 4 + 3] & 255;
|
|
919
|
+
} else {
|
|
920
|
+
var u = this.temp[i - 2];
|
|
921
|
+
var t1_1 = (u >>> 17 | u << 15) ^ (u >>> 19 | u << 13) ^ u >>> 10;
|
|
922
|
+
u = this.temp[i - 15];
|
|
923
|
+
var t2_1 = (u >>> 7 | u << 25) ^ (u >>> 18 | u << 14) ^ u >>> 3;
|
|
924
|
+
this.temp[i] = (t1_1 + this.temp[i - 7] | 0) + (t2_1 + this.temp[i - 16] | 0);
|
|
925
|
+
}
|
|
926
|
+
var t1 = (((state4 >>> 6 | state4 << 26) ^ (state4 >>> 11 | state4 << 21) ^ (state4 >>> 25 | state4 << 7)) + (state4 & state5 ^ ~state4 & state6) | 0) + (state7 + (KEY[i] + this.temp[i] | 0) | 0) | 0;
|
|
927
|
+
var t2 = ((state0 >>> 2 | state0 << 30) ^ (state0 >>> 13 | state0 << 19) ^ (state0 >>> 22 | state0 << 10)) + (state0 & state1 ^ state0 & state2 ^ state1 & state2) | 0;
|
|
928
|
+
state7 = state6;
|
|
929
|
+
state6 = state5;
|
|
930
|
+
state5 = state4;
|
|
931
|
+
state4 = state3 + t1 | 0;
|
|
932
|
+
state3 = state2;
|
|
933
|
+
state2 = state1;
|
|
934
|
+
state1 = state0;
|
|
935
|
+
state0 = t1 + t2 | 0;
|
|
936
|
+
}
|
|
937
|
+
state[0] += state0;
|
|
938
|
+
state[1] += state1;
|
|
939
|
+
state[2] += state2;
|
|
940
|
+
state[3] += state3;
|
|
941
|
+
state[4] += state4;
|
|
942
|
+
state[5] += state5;
|
|
943
|
+
state[6] += state6;
|
|
944
|
+
state[7] += state7;
|
|
945
|
+
};
|
|
946
|
+
return RawSha2562;
|
|
947
|
+
}()
|
|
948
|
+
);
|
|
949
|
+
|
|
950
|
+
// node_modules/@smithy/util-utf8/dist-es/fromUtf8.browser.js
|
|
951
|
+
var fromUtf8 = (input) => new TextEncoder().encode(input);
|
|
952
|
+
|
|
953
|
+
// node_modules/@aws-crypto/util/build/module/convertToBuffer.js
|
|
954
|
+
var fromUtf82 = typeof Buffer !== "undefined" && Buffer.from ? function(input) {
|
|
955
|
+
return Buffer.from(input, "utf8");
|
|
956
|
+
} : fromUtf8;
|
|
957
|
+
function convertToBuffer(data) {
|
|
958
|
+
if (data instanceof Uint8Array)
|
|
959
|
+
return data;
|
|
960
|
+
if (typeof data === "string") {
|
|
961
|
+
return fromUtf82(data);
|
|
962
|
+
}
|
|
963
|
+
if (ArrayBuffer.isView(data)) {
|
|
964
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength / Uint8Array.BYTES_PER_ELEMENT);
|
|
965
|
+
}
|
|
966
|
+
return new Uint8Array(data);
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
// node_modules/@aws-crypto/util/build/module/isEmptyData.js
|
|
970
|
+
function isEmptyData(data) {
|
|
971
|
+
if (typeof data === "string") {
|
|
972
|
+
return data.length === 0;
|
|
973
|
+
}
|
|
974
|
+
return data.byteLength === 0;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// node_modules/@aws-crypto/sha256-js/build/module/jsSha256.js
|
|
978
|
+
var Sha256 = (
|
|
979
|
+
/** @class */
|
|
980
|
+
function() {
|
|
981
|
+
function Sha2562(secret) {
|
|
982
|
+
this.secret = secret;
|
|
983
|
+
this.hash = new RawSha256();
|
|
984
|
+
this.reset();
|
|
985
|
+
}
|
|
986
|
+
Sha2562.prototype.update = function(toHash) {
|
|
987
|
+
if (isEmptyData(toHash) || this.error) {
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
try {
|
|
991
|
+
this.hash.update(convertToBuffer(toHash));
|
|
992
|
+
} catch (e) {
|
|
993
|
+
this.error = e;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
Sha2562.prototype.digestSync = function() {
|
|
997
|
+
if (this.error) {
|
|
998
|
+
throw this.error;
|
|
999
|
+
}
|
|
1000
|
+
if (this.outer) {
|
|
1001
|
+
if (!this.outer.finished) {
|
|
1002
|
+
this.outer.update(this.hash.digest());
|
|
1003
|
+
}
|
|
1004
|
+
return this.outer.digest();
|
|
1005
|
+
}
|
|
1006
|
+
return this.hash.digest();
|
|
1007
|
+
};
|
|
1008
|
+
Sha2562.prototype.digest = function() {
|
|
1009
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
1010
|
+
return __generator(this, function(_a) {
|
|
1011
|
+
return [2, this.digestSync()];
|
|
1012
|
+
});
|
|
1013
|
+
});
|
|
1014
|
+
};
|
|
1015
|
+
Sha2562.prototype.reset = function() {
|
|
1016
|
+
this.hash = new RawSha256();
|
|
1017
|
+
if (this.secret) {
|
|
1018
|
+
this.outer = new RawSha256();
|
|
1019
|
+
var inner = bufferFromSecret(this.secret);
|
|
1020
|
+
var outer = new Uint8Array(BLOCK_SIZE);
|
|
1021
|
+
outer.set(inner);
|
|
1022
|
+
for (var i = 0; i < BLOCK_SIZE; i++) {
|
|
1023
|
+
inner[i] ^= 54;
|
|
1024
|
+
outer[i] ^= 92;
|
|
1025
|
+
}
|
|
1026
|
+
this.hash.update(inner);
|
|
1027
|
+
this.outer.update(outer);
|
|
1028
|
+
for (var i = 0; i < inner.byteLength; i++) {
|
|
1029
|
+
inner[i] = 0;
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
return Sha2562;
|
|
1034
|
+
}()
|
|
1035
|
+
);
|
|
1036
|
+
function bufferFromSecret(secret) {
|
|
1037
|
+
var input = convertToBuffer(secret);
|
|
1038
|
+
if (input.byteLength > BLOCK_SIZE) {
|
|
1039
|
+
var bufferHash = new RawSha256();
|
|
1040
|
+
bufferHash.update(input);
|
|
1041
|
+
input = bufferHash.digest();
|
|
1042
|
+
}
|
|
1043
|
+
var buffer = new Uint8Array(BLOCK_SIZE);
|
|
1044
|
+
buffer.set(input);
|
|
1045
|
+
return buffer;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1546
1048
|
// src/FaustCompiler.ts
|
|
1547
|
-
var import_sha256_js = __toESM(require_build2(), 1);
|
|
1548
1049
|
var ab2str = (buf) => String.fromCharCode.apply(null, buf);
|
|
1549
1050
|
var str2ab = (str) => {
|
|
1550
1051
|
const buf = new ArrayBuffer(str.length);
|
|
@@ -1555,13 +1056,16 @@ var str2ab = (str) => {
|
|
|
1555
1056
|
return bufView;
|
|
1556
1057
|
};
|
|
1557
1058
|
var sha256 = async (str) => {
|
|
1558
|
-
const sha2562 = new
|
|
1059
|
+
const sha2562 = new Sha256();
|
|
1559
1060
|
sha2562.update(str);
|
|
1560
1061
|
const hashArray = Array.from(await sha2562.digest());
|
|
1561
1062
|
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
1562
1063
|
return hashHex;
|
|
1563
1064
|
};
|
|
1564
|
-
var _FaustCompiler = class {
|
|
1065
|
+
var _FaustCompiler = class _FaustCompiler {
|
|
1066
|
+
/**
|
|
1067
|
+
* Get a stringified DSP factories table
|
|
1068
|
+
*/
|
|
1565
1069
|
static serializeDSPFactories() {
|
|
1566
1070
|
const table = {};
|
|
1567
1071
|
this.gFactories.forEach((factory, shaKey) => {
|
|
@@ -1570,19 +1074,28 @@ var _FaustCompiler = class {
|
|
|
1570
1074
|
});
|
|
1571
1075
|
return table;
|
|
1572
1076
|
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Get a stringified DSP factories table as string
|
|
1079
|
+
*/
|
|
1573
1080
|
static stringifyDSPFactories() {
|
|
1574
1081
|
return JSON.stringify(this.serializeDSPFactories());
|
|
1575
1082
|
}
|
|
1083
|
+
/**
|
|
1084
|
+
* Import a DSP factories table
|
|
1085
|
+
*/
|
|
1576
1086
|
static deserializeDSPFactories(table) {
|
|
1577
1087
|
const awaited = [];
|
|
1578
1088
|
for (const shaKey in table) {
|
|
1579
1089
|
const factory = table[shaKey];
|
|
1580
1090
|
const { code, json, poly } = factory;
|
|
1581
1091
|
const ab = str2ab(atob(code));
|
|
1582
|
-
awaited.push(WebAssembly.compile(ab).then((module) => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly })));
|
|
1092
|
+
awaited.push(WebAssembly.compile(ab).then((module) => this.gFactories.set(shaKey, { shaKey, cfactory: 0, code: ab, module, json: JSON.stringify(json), poly, soundfiles: {} })));
|
|
1583
1093
|
}
|
|
1584
1094
|
return Promise.all(awaited);
|
|
1585
1095
|
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Import a stringified DSP factories table
|
|
1098
|
+
*/
|
|
1586
1099
|
static importDSPFactories(tableStr) {
|
|
1587
1100
|
const table = JSON.parse(tableStr);
|
|
1588
1101
|
return this.deserializeDSPFactories(table);
|
|
@@ -1612,7 +1125,7 @@ var _FaustCompiler = class {
|
|
|
1612
1125
|
const ui8Code = this.intVec2intArray(faustDspWasm.data);
|
|
1613
1126
|
faustDspWasm.data.delete();
|
|
1614
1127
|
const module = await WebAssembly.compile(ui8Code);
|
|
1615
|
-
const factory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly };
|
|
1128
|
+
const factory = { shaKey, cfactory: faustDspWasm.cfactory, code: ui8Code, module, json: faustDspWasm.json, poly, soundfiles: {} };
|
|
1616
1129
|
this.deleteDSPFactory(factory);
|
|
1617
1130
|
_FaustCompiler.gFactories.set(shaKey, factory);
|
|
1618
1131
|
return factory;
|
|
@@ -1688,8 +1201,8 @@ var _FaustCompiler = class {
|
|
|
1688
1201
|
return { mixerBuffer, mixerModule };
|
|
1689
1202
|
}
|
|
1690
1203
|
};
|
|
1204
|
+
_FaustCompiler.gFactories = /* @__PURE__ */ new Map();
|
|
1691
1205
|
var FaustCompiler = _FaustCompiler;
|
|
1692
|
-
FaustCompiler.gFactories = /* @__PURE__ */ new Map();
|
|
1693
1206
|
var FaustCompiler_default = FaustCompiler;
|
|
1694
1207
|
|
|
1695
1208
|
// src/FaustDspInstance.ts
|
|
@@ -1740,7 +1253,9 @@ var FaustWasmInstantiator = class {
|
|
|
1740
1253
|
memory: memory || new WebAssembly.Memory({ initial: 100 }),
|
|
1741
1254
|
memoryBase: 0,
|
|
1742
1255
|
tableBase: 0,
|
|
1256
|
+
// Integer version
|
|
1743
1257
|
_abs: Math.abs,
|
|
1258
|
+
// Float version
|
|
1744
1259
|
_acosf: Math.acos,
|
|
1745
1260
|
_asinf: Math.asin,
|
|
1746
1261
|
_atanf: Math.atan,
|
|
@@ -1769,6 +1284,7 @@ var FaustWasmInstantiator = class {
|
|
|
1769
1284
|
_isnanf: Number.isNaN,
|
|
1770
1285
|
_isinff: (x) => !isFinite(x),
|
|
1771
1286
|
_copysignf: (x, y) => Math.sign(x) === Math.sign(y) ? x : -x,
|
|
1287
|
+
// Double version
|
|
1772
1288
|
_acos: Math.acos,
|
|
1773
1289
|
_asin: Math.asin,
|
|
1774
1290
|
_atan: Math.atan,
|
|
@@ -1849,6 +1365,7 @@ var FaustWasmInstantiator = class {
|
|
|
1849
1365
|
const mixerFunctions = mixerInstance.exports;
|
|
1850
1366
|
return mixerFunctions;
|
|
1851
1367
|
}
|
|
1368
|
+
// Public API
|
|
1852
1369
|
static async loadDSPFactory(wasmPath, jsonPath) {
|
|
1853
1370
|
const wasmFile = await fetch(wasmPath);
|
|
1854
1371
|
if (!wasmFile.ok) {
|
|
@@ -1972,6 +1489,14 @@ var WasmAllocator = class {
|
|
|
1972
1489
|
this.memory = memory;
|
|
1973
1490
|
this.allocatedBytes = offset;
|
|
1974
1491
|
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Allocates a block of memory of the specified size, returning the pointer to the
|
|
1494
|
+
* beginning of the block. The block is allocated at the current offset and the
|
|
1495
|
+
* offset is incremented by the size of the block.
|
|
1496
|
+
*
|
|
1497
|
+
* @param sizeInBytes The size of the block to allocate in bytes.
|
|
1498
|
+
* @returns The offset (pointer) to the beginning of the allocated block.
|
|
1499
|
+
*/
|
|
1975
1500
|
alloc(sizeInBytes) {
|
|
1976
1501
|
const currentOffset = this.allocatedBytes;
|
|
1977
1502
|
const newOffset = currentOffset + sizeInBytes;
|
|
@@ -1984,38 +1509,75 @@ var WasmAllocator = class {
|
|
|
1984
1509
|
this.allocatedBytes = newOffset;
|
|
1985
1510
|
return currentOffset;
|
|
1986
1511
|
}
|
|
1512
|
+
/**
|
|
1513
|
+
* Returns the underlying buffer object.
|
|
1514
|
+
*
|
|
1515
|
+
* @returns The buffer object.
|
|
1516
|
+
*/
|
|
1987
1517
|
getBuffer() {
|
|
1988
1518
|
return this.memory.buffer;
|
|
1989
1519
|
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Returns the Int32 view of the underlying buffer object.
|
|
1522
|
+
*
|
|
1523
|
+
* @returns The view of the memory buffer as Int32Array.
|
|
1524
|
+
*/
|
|
1990
1525
|
getInt32Array() {
|
|
1991
1526
|
return new Int32Array(this.memory.buffer);
|
|
1992
1527
|
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Returns the Int64 view of the underlying buffer object.
|
|
1530
|
+
*
|
|
1531
|
+
* @returns The view of the memory buffer as BigInt64Array.
|
|
1532
|
+
*/
|
|
1993
1533
|
getInt64Array() {
|
|
1994
1534
|
return new BigInt64Array(this.memory.buffer);
|
|
1995
1535
|
}
|
|
1536
|
+
/**
|
|
1537
|
+
* Returns the Float32 view of the underlying buffer object.
|
|
1538
|
+
*
|
|
1539
|
+
* @returns The view of the memory buffer as Float32Array.
|
|
1540
|
+
*/
|
|
1996
1541
|
getFloat32Array() {
|
|
1997
1542
|
return new Float32Array(this.memory.buffer);
|
|
1998
1543
|
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Returns the Float64 view of the underlying buffer object..
|
|
1546
|
+
*
|
|
1547
|
+
* @returns The view of the memory buffer as Float64Array.
|
|
1548
|
+
*/
|
|
1999
1549
|
getFloat64Array() {
|
|
2000
1550
|
return new Float64Array(this.memory.buffer);
|
|
2001
1551
|
}
|
|
2002
1552
|
};
|
|
2003
|
-
var
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
1553
|
+
var Soundfile = class _Soundfile {
|
|
1554
|
+
/** Maximum number of soundfile parts. */
|
|
1555
|
+
static get MAX_SOUNDFILE_PARTS() {
|
|
1556
|
+
return 256;
|
|
1557
|
+
}
|
|
1558
|
+
/** Maximum number of channels. */
|
|
1559
|
+
static get MAX_CHAN() {
|
|
1560
|
+
return 64;
|
|
1561
|
+
}
|
|
1562
|
+
/** Maximum buffer size in frames. */
|
|
1563
|
+
static get BUFFER_SIZE() {
|
|
1564
|
+
return 1024;
|
|
1565
|
+
}
|
|
1566
|
+
/** Default sample rate. */
|
|
1567
|
+
static get SAMPLE_RATE() {
|
|
1568
|
+
return 44100;
|
|
1569
|
+
}
|
|
1570
|
+
constructor(allocator, sampleSize, curChan, length, maxChan, totalParts) {
|
|
2009
1571
|
this.fSampleSize = sampleSize;
|
|
2010
1572
|
this.fIntSize = this.fSampleSize;
|
|
2011
1573
|
this.fPtrSize = 4;
|
|
2012
1574
|
this.fAllocator = allocator;
|
|
2013
|
-
console.log(`Soundfile constructor: curChan: ${curChan}, length: ${
|
|
1575
|
+
console.log(`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`);
|
|
2014
1576
|
this.fPtr = allocator.alloc(4 * this.fPtrSize);
|
|
2015
|
-
this.fLength = allocator.alloc(MAX_SOUNDFILE_PARTS * this.fIntSize);
|
|
2016
|
-
this.fSR = allocator.alloc(MAX_SOUNDFILE_PARTS * this.fIntSize);
|
|
2017
|
-
this.fOffset = allocator.alloc(MAX_SOUNDFILE_PARTS * this.fIntSize);
|
|
2018
|
-
this.fBuffers = this.allocBuffers(curChan,
|
|
1577
|
+
this.fLength = allocator.alloc(_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);
|
|
1578
|
+
this.fSR = allocator.alloc(_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);
|
|
1579
|
+
this.fOffset = allocator.alloc(_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize);
|
|
1580
|
+
this.fBuffers = this.allocBuffers(curChan, length, maxChan);
|
|
2019
1581
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
2020
1582
|
HEAP32[this.fPtr >> 2] = this.fBuffers;
|
|
2021
1583
|
HEAP32[this.fPtr + this.fPtrSize >> 2] = this.fLength;
|
|
@@ -2026,11 +1588,11 @@ var Soundfile = class {
|
|
|
2026
1588
|
console.log(`allocBuffers AFTER: ${chan} - ${buffer}`);
|
|
2027
1589
|
}
|
|
2028
1590
|
}
|
|
2029
|
-
allocBuffers(curChan,
|
|
1591
|
+
allocBuffers(curChan, length, maxChan) {
|
|
2030
1592
|
const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);
|
|
2031
1593
|
console.log(`allocBuffers buffers: ${buffers}`);
|
|
2032
1594
|
for (let chan = 0; chan < curChan; chan++) {
|
|
2033
|
-
const buffer = this.fAllocator.alloc(
|
|
1595
|
+
const buffer = this.fAllocator.alloc(length * this.fSampleSize);
|
|
2034
1596
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
2035
1597
|
HEAP32[(buffers >> 2) + chan] = buffer;
|
|
2036
1598
|
}
|
|
@@ -2042,30 +1604,30 @@ var Soundfile = class {
|
|
|
2042
1604
|
HEAP32[(this.fBuffers >> 2) + chan] = HEAP32[(this.fBuffers >> 2) + chan % curChan];
|
|
2043
1605
|
}
|
|
2044
1606
|
}
|
|
2045
|
-
copyToOut(part, maxChannels, offset,
|
|
1607
|
+
copyToOut(part, maxChannels, offset, audioData) {
|
|
2046
1608
|
if (this.fIntSize === 4) {
|
|
2047
1609
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
2048
|
-
HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] =
|
|
2049
|
-
HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] =
|
|
1610
|
+
HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = audioData.audioBuffer[0].length;
|
|
1611
|
+
HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = audioData.sampleRate;
|
|
2050
1612
|
HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;
|
|
2051
1613
|
} else {
|
|
2052
1614
|
const HEAP64 = this.fAllocator.getInt64Array();
|
|
2053
|
-
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
2054
|
-
HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
1615
|
+
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.audioBuffer[0].length);
|
|
1616
|
+
HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(audioData.sampleRate);
|
|
2055
1617
|
HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);
|
|
2056
1618
|
}
|
|
2057
|
-
console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${
|
|
1619
|
+
console.log(`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`);
|
|
2058
1620
|
if (this.fSampleSize === 8) {
|
|
2059
|
-
this.copyToOutReal64(maxChannels, offset,
|
|
1621
|
+
this.copyToOutReal64(maxChannels, offset, audioData);
|
|
2060
1622
|
} else {
|
|
2061
|
-
this.copyToOutReal32(maxChannels, offset,
|
|
1623
|
+
this.copyToOutReal32(maxChannels, offset, audioData);
|
|
2062
1624
|
}
|
|
2063
1625
|
}
|
|
2064
|
-
copyToOutReal32(maxChannels, offset,
|
|
1626
|
+
copyToOutReal32(maxChannels, offset, audioData) {
|
|
2065
1627
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
2066
1628
|
const HEAPF = this.fAllocator.getFloat32Array();
|
|
2067
|
-
for (let chan = 0; chan <
|
|
2068
|
-
const input =
|
|
1629
|
+
for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {
|
|
1630
|
+
const input = audioData.audioBuffer[chan];
|
|
2069
1631
|
const output = HEAP32[(this.fBuffers >> 2) + chan];
|
|
2070
1632
|
const begin = output + offset * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
2071
1633
|
const end = output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
@@ -2079,11 +1641,11 @@ var Soundfile = class {
|
|
|
2079
1641
|
}
|
|
2080
1642
|
}
|
|
2081
1643
|
}
|
|
2082
|
-
copyToOutReal64(maxChannels, offset,
|
|
1644
|
+
copyToOutReal64(maxChannels, offset, audioData) {
|
|
2083
1645
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
2084
1646
|
const HEAPF = this.fAllocator.getFloat64Array();
|
|
2085
|
-
for (let chan = 0; chan <
|
|
2086
|
-
const input =
|
|
1647
|
+
for (let chan = 0; chan < audioData.audioBuffer.length; chan++) {
|
|
1648
|
+
const input = audioData.audioBuffer[chan];
|
|
2087
1649
|
const output = HEAP32[(this.fBuffers >> 2) + chan];
|
|
2088
1650
|
const begin = output + offset * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
2089
1651
|
const end = output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
@@ -2100,16 +1662,16 @@ var Soundfile = class {
|
|
|
2100
1662
|
emptyFile(part, offset) {
|
|
2101
1663
|
if (this.fIntSize === 4) {
|
|
2102
1664
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
2103
|
-
HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = BUFFER_SIZE;
|
|
2104
|
-
HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = SAMPLE_RATE;
|
|
1665
|
+
HEAP32[(this.fLength >> Math.log2(this.fIntSize)) + part] = _Soundfile.BUFFER_SIZE;
|
|
1666
|
+
HEAP32[(this.fSR >> Math.log2(this.fIntSize)) + part] = _Soundfile.SAMPLE_RATE;
|
|
2105
1667
|
HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;
|
|
2106
1668
|
} else {
|
|
2107
1669
|
const HEAP64 = this.fAllocator.getInt64Array();
|
|
2108
|
-
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(BUFFER_SIZE);
|
|
2109
|
-
HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(SAMPLE_RATE);
|
|
1670
|
+
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(_Soundfile.BUFFER_SIZE);
|
|
1671
|
+
HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(_Soundfile.SAMPLE_RATE);
|
|
2110
1672
|
HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);
|
|
2111
1673
|
}
|
|
2112
|
-
return offset + BUFFER_SIZE;
|
|
1674
|
+
return offset + _Soundfile.BUFFER_SIZE;
|
|
2113
1675
|
}
|
|
2114
1676
|
displayMemory(where = "", mem = false) {
|
|
2115
1677
|
console.log("Soundfile memory: " + where);
|
|
@@ -2126,6 +1688,7 @@ var Soundfile = class {
|
|
|
2126
1688
|
console.log(`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 2 * this.fPtrSize >> 2]}`);
|
|
2127
1689
|
console.log(`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 3 * this.fPtrSize >> 2]}`);
|
|
2128
1690
|
}
|
|
1691
|
+
// Return the pointer to the soundfile structure in wasm memory
|
|
2129
1692
|
getPtr() {
|
|
2130
1693
|
return this.fPtr;
|
|
2131
1694
|
}
|
|
@@ -2139,139 +1702,28 @@ var Soundfile = class {
|
|
|
2139
1702
|
return this.fAllocator.getFloat64Array();
|
|
2140
1703
|
}
|
|
2141
1704
|
};
|
|
2142
|
-
var
|
|
2143
|
-
constructor(
|
|
2144
|
-
this.fAllocator = allocator;
|
|
2145
|
-
this.fSampleSize = sampleSize;
|
|
2146
|
-
this.fContext = context;
|
|
2147
|
-
this.fAudioBuffers = [];
|
|
2148
|
-
}
|
|
2149
|
-
async checkFileExists(url) {
|
|
2150
|
-
try {
|
|
2151
|
-
console.log(`"checkFileExists" url: ${url}`);
|
|
2152
|
-
const response = await fetch(url, { method: "HEAD" });
|
|
2153
|
-
return response.ok;
|
|
2154
|
-
} catch (error) {
|
|
2155
|
-
console.error("Fetch error:", error);
|
|
2156
|
-
return false;
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
async checkFile(directories, fileName) {
|
|
2160
|
-
if (await this.checkFileExists(fileName)) {
|
|
2161
|
-
return fileName;
|
|
2162
|
-
} else {
|
|
2163
|
-
for (let i = 0; i < directories.length; i++) {
|
|
2164
|
-
const pathName = directories[i] + "/" + fileName;
|
|
2165
|
-
if (await this.checkFileExists(pathName)) {
|
|
2166
|
-
return pathName;
|
|
2167
|
-
}
|
|
2168
|
-
}
|
|
2169
|
-
return "";
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
async checkFiles(directories, fileNameList) {
|
|
2173
|
-
const pathNameList = [];
|
|
2174
|
-
for (let i = 0; i < fileNameList.length; i++) {
|
|
2175
|
-
const pathName = await this.checkFile(directories, fileNameList[i]);
|
|
2176
|
-
console.log(`checkFiles pathName: ${pathName}`);
|
|
2177
|
-
pathNameList.push(pathName === "" ? "__empty_sound__" : pathName);
|
|
2178
|
-
}
|
|
2179
|
-
return pathNameList;
|
|
2180
|
-
}
|
|
2181
|
-
async getParamsFile(pathName) {
|
|
2182
|
-
console.log(`Loading sound file from ${pathName}`);
|
|
2183
|
-
const item = this.fAudioBuffers.find((element) => element.pathName === pathName);
|
|
2184
|
-
if (item) {
|
|
2185
|
-
console.log(`getItemByPathName FOUND`);
|
|
2186
|
-
return { channels: item.audioBuffer.numberOfChannels, length: item.audioBuffer.length };
|
|
2187
|
-
} else {
|
|
2188
|
-
const response = await fetch(pathName);
|
|
2189
|
-
if (!response.ok) {
|
|
2190
|
-
console.log(`Failed to load sound file from ${pathName}: ${response.statusText}`);
|
|
2191
|
-
return { channels: 1, length: BUFFER_SIZE };
|
|
2192
|
-
} else {
|
|
2193
|
-
const arrayBuffer = await response.arrayBuffer();
|
|
2194
|
-
const audioBuffer = await this.fContext.decodeAudioData(arrayBuffer);
|
|
2195
|
-
const { numberOfChannels, length: length2 } = audioBuffer;
|
|
2196
|
-
this.fAudioBuffers.push({ pathName, audioBuffer });
|
|
2197
|
-
return { channels: numberOfChannels, length: length2 };
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
readFile(soundfile, pathName, part, offset, maxChan) {
|
|
2202
|
-
const item = this.fAudioBuffers.find((entry) => entry.pathName === pathName);
|
|
2203
|
-
if (item) {
|
|
2204
|
-
soundfile.copyToOut(part, maxChan, offset, item.audioBuffer);
|
|
2205
|
-
return offset + item.audioBuffer.length;
|
|
2206
|
-
} else {
|
|
2207
|
-
console.error(`Failed to access sound file from ${pathName}`);
|
|
2208
|
-
return offset + BUFFER_SIZE;
|
|
2209
|
-
}
|
|
2210
|
-
}
|
|
2211
|
-
async createSoundfile(pathNameList, maxChan) {
|
|
2212
|
-
try {
|
|
2213
|
-
let curChan = 1;
|
|
2214
|
-
let totalLength = 0;
|
|
2215
|
-
for (const pathName of pathNameList) {
|
|
2216
|
-
let chan = 0, len = 0;
|
|
2217
|
-
if (pathName === "__empty_sound__") {
|
|
2218
|
-
length = BUFFER_SIZE;
|
|
2219
|
-
chan = 1;
|
|
2220
|
-
} else {
|
|
2221
|
-
const { channels, length: length2 } = await this.getParamsFile(pathName);
|
|
2222
|
-
chan = channels;
|
|
2223
|
-
len = length2;
|
|
2224
|
-
}
|
|
2225
|
-
curChan = Math.max(curChan, chan);
|
|
2226
|
-
totalLength += len;
|
|
2227
|
-
}
|
|
2228
|
-
totalLength += (MAX_SOUNDFILE_PARTS - pathNameList.length) * BUFFER_SIZE;
|
|
2229
|
-
let soundfile = new Soundfile(this.fAllocator, this.fSampleSize, curChan, totalLength, maxChan, pathNameList.length);
|
|
2230
|
-
let offset = 0;
|
|
2231
|
-
for (let part = 0; part < pathNameList.length; part++) {
|
|
2232
|
-
if (pathNameList[part] === "__empty_sound__") {
|
|
2233
|
-
offset = soundfile.emptyFile(part, offset);
|
|
2234
|
-
} else {
|
|
2235
|
-
offset = await this.readFile(soundfile, pathNameList[part], part, offset, maxChan);
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
for (let part = pathNameList.length; part < MAX_SOUNDFILE_PARTS; part++) {
|
|
2239
|
-
offset = soundfile.emptyFile(part, offset);
|
|
2240
|
-
}
|
|
2241
|
-
soundfile.shareBuffers(curChan, maxChan);
|
|
2242
|
-
return soundfile;
|
|
2243
|
-
} catch (error) {
|
|
2244
|
-
console.error("Failed to create soundfile:", error);
|
|
2245
|
-
return null;
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
getHEAP32() {
|
|
2249
|
-
return this.fAllocator.getInt32Array();
|
|
2250
|
-
}
|
|
2251
|
-
};
|
|
2252
|
-
var FaustBaseWebAudioDsp = class {
|
|
2253
|
-
constructor(sampleSize, bufferSize) {
|
|
1705
|
+
var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
1706
|
+
constructor(sampleSize, bufferSize, soundfiles) {
|
|
2254
1707
|
this.fOutputHandler = null;
|
|
2255
1708
|
this.fComputeHandler = null;
|
|
1709
|
+
// To handle MIDI events plot
|
|
1710
|
+
this.fPlotHandler = null;
|
|
2256
1711
|
this.fCachedEvents = [];
|
|
2257
1712
|
this.fBufferNum = 0;
|
|
2258
|
-
this.fPlotHandler = null;
|
|
2259
|
-
this.fBufferSize = bufferSize;
|
|
2260
1713
|
this.fInChannels = [];
|
|
2261
1714
|
this.fOutChannels = [];
|
|
2262
|
-
this.fPtrSize = sampleSize;
|
|
2263
|
-
this.fSampleSize = sampleSize;
|
|
2264
1715
|
this.fOutputsTimer = 5;
|
|
1716
|
+
// UI items path
|
|
2265
1717
|
this.fInputsItems = [];
|
|
2266
1718
|
this.fOutputsItems = [];
|
|
2267
1719
|
this.fDescriptor = [];
|
|
1720
|
+
// Soundfile handling
|
|
2268
1721
|
this.fSoundfiles = [];
|
|
1722
|
+
this.fSoundfileBuffers = {};
|
|
1723
|
+
// MIDI handling
|
|
2269
1724
|
this.fPitchwheelLabel = [];
|
|
2270
1725
|
this.fCtrlLabel = new Array(128).fill(null).map(() => []);
|
|
2271
1726
|
this.fPathTable = {};
|
|
2272
|
-
this.fProcessing = false;
|
|
2273
|
-
this.fDestroyed = false;
|
|
2274
|
-
this.fFirstCall = true;
|
|
2275
1727
|
this.fUICallback = (item) => {
|
|
2276
1728
|
if (item.type === "hbargraph" || item.type === "vbargraph") {
|
|
2277
1729
|
this.fOutputsItems.push(item.address);
|
|
@@ -2300,10 +1752,20 @@ var FaustBaseWebAudioDsp = class {
|
|
|
2300
1752
|
this.fSoundfiles.push({ name: item.label, url: item.url, index: item.index, basePtr: -1 });
|
|
2301
1753
|
}
|
|
2302
1754
|
};
|
|
1755
|
+
// Audio callback
|
|
1756
|
+
this.fProcessing = false;
|
|
1757
|
+
this.fDestroyed = false;
|
|
1758
|
+
this.fFirstCall = true;
|
|
1759
|
+
this.fBufferSize = bufferSize;
|
|
1760
|
+
this.fPtrSize = sampleSize;
|
|
1761
|
+
this.fSampleSize = sampleSize;
|
|
1762
|
+
this.fSoundfileBuffers = soundfiles;
|
|
2303
1763
|
}
|
|
1764
|
+
// Tools
|
|
2304
1765
|
static remap(v, mn0, mx0, mn1, mx1) {
|
|
2305
1766
|
return (v - mn0) / (mx0 - mn0) * (mx1 - mn1) + mn1;
|
|
2306
1767
|
}
|
|
1768
|
+
// JSON parsing functions
|
|
2307
1769
|
static parseUI(ui, callback) {
|
|
2308
1770
|
ui.forEach((group) => this.parseGroup(group, callback));
|
|
2309
1771
|
}
|
|
@@ -2322,51 +1784,98 @@ var FaustBaseWebAudioDsp = class {
|
|
|
2322
1784
|
callback(item);
|
|
2323
1785
|
}
|
|
2324
1786
|
}
|
|
2325
|
-
|
|
1787
|
+
/** Split the soundfile names and return an array of names */
|
|
1788
|
+
static splitSoundfileNames(input) {
|
|
2326
1789
|
let trimmed = input.replace(/^\{|\}$/g, "");
|
|
2327
1790
|
return trimmed.split(";").map((str) => str.length <= 2 ? "" : str.substring(1, str.length - 1));
|
|
2328
1791
|
}
|
|
2329
|
-
|
|
2330
|
-
const soundfilesEntry =
|
|
1792
|
+
static extractUrlsFromMeta(dspMeta) {
|
|
1793
|
+
const soundfilesEntry = dspMeta.meta.find((entry) => entry.soundfiles !== void 0);
|
|
2331
1794
|
if (soundfilesEntry) {
|
|
2332
1795
|
return soundfilesEntry.soundfiles.split(";").filter((url) => url !== "");
|
|
2333
1796
|
} else {
|
|
2334
1797
|
return [];
|
|
2335
1798
|
}
|
|
2336
1799
|
}
|
|
2337
|
-
|
|
1800
|
+
/**
|
|
1801
|
+
* Load a soundfile possibly containing several parts in the DSP struct.
|
|
1802
|
+
* Soundfile pointers are located at 'index' offset, to be read in the JSON file.
|
|
1803
|
+
* The DSP struct is located at baseDSP in the wasm memory,
|
|
1804
|
+
* either a monophonic DSP, or a voice in a polyphonic context.
|
|
1805
|
+
*
|
|
1806
|
+
* @param allocator : the wasm memory allocator
|
|
1807
|
+
* @param baseDSP : the base DSP in the wasm memory
|
|
1808
|
+
* @param name : the name of the soundfile
|
|
1809
|
+
* @param url : the url of the soundfile
|
|
1810
|
+
*/
|
|
1811
|
+
loadSoundfile(allocator, baseDSP, name, url) {
|
|
2338
1812
|
console.log(`Soundfile ${name} paths: ${url}`);
|
|
2339
|
-
const
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
1813
|
+
const soundfileIds = _FaustBaseWebAudioDsp.splitSoundfileNames(url);
|
|
1814
|
+
const item = this.fSoundfiles.find((item2) => item2.url === url);
|
|
1815
|
+
if (!item)
|
|
1816
|
+
throw new Error(`Soundfile with ${url} cannot be found !}`);
|
|
1817
|
+
if (item.basePtr !== -1) {
|
|
1818
|
+
const HEAP32 = allocator.getInt32Array();
|
|
1819
|
+
console.log(`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);
|
|
1820
|
+
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
1821
|
+
} else {
|
|
1822
|
+
const soundfile = this.createSoundfile(allocator, soundfileIds, this.fSoundfileBuffers);
|
|
1823
|
+
if (soundfile) {
|
|
1824
|
+
const HEAP32 = soundfile.getHEAP32();
|
|
1825
|
+
item.basePtr = soundfile.getPtr();
|
|
1826
|
+
console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);
|
|
2351
1827
|
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
2352
1828
|
} else {
|
|
2353
|
-
|
|
2354
|
-
if (soundfile) {
|
|
2355
|
-
const HEAP32 = soundfile.getHEAP32();
|
|
2356
|
-
item.basePtr = soundfile.getPtr();
|
|
2357
|
-
console.log(`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`);
|
|
2358
|
-
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
2359
|
-
} else {
|
|
2360
|
-
console.log(`Soundfile ${name} for ${url} cannot be created !}`);
|
|
2361
|
-
}
|
|
1829
|
+
console.log(`Soundfile ${name} for ${url} cannot be created !}`);
|
|
2362
1830
|
}
|
|
2363
|
-
} else {
|
|
2364
|
-
console.log(`Soundfile with ${url} cannot be found !}`);
|
|
2365
1831
|
}
|
|
2366
1832
|
}
|
|
2367
|
-
|
|
1833
|
+
createSoundfile(allocator, soundfileIdList, soundfiles, maxChan = Soundfile.MAX_CHAN) {
|
|
1834
|
+
let curChan = 1;
|
|
1835
|
+
let totalLength = 0;
|
|
1836
|
+
for (const soundfileId of soundfileIdList) {
|
|
1837
|
+
let chan = 0;
|
|
1838
|
+
let len = 0;
|
|
1839
|
+
const audioData = soundfiles[soundfileId];
|
|
1840
|
+
if (audioData) {
|
|
1841
|
+
chan = audioData.audioBuffer.length;
|
|
1842
|
+
len = audioData.audioBuffer[0].length;
|
|
1843
|
+
} else {
|
|
1844
|
+
len = Soundfile.BUFFER_SIZE;
|
|
1845
|
+
chan = 1;
|
|
1846
|
+
}
|
|
1847
|
+
curChan = Math.max(curChan, chan);
|
|
1848
|
+
totalLength += len;
|
|
1849
|
+
}
|
|
1850
|
+
totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;
|
|
1851
|
+
const soundfile = new Soundfile(allocator, this.fSampleSize, curChan, totalLength, maxChan, soundfileIdList.length);
|
|
1852
|
+
let offset = 0;
|
|
1853
|
+
for (let part = 0; part < soundfileIdList.length; part++) {
|
|
1854
|
+
const soundfileId = soundfileIdList[part];
|
|
1855
|
+
const audioData = soundfiles[soundfileId];
|
|
1856
|
+
if (audioData) {
|
|
1857
|
+
soundfile.copyToOut(part, maxChan, offset, audioData);
|
|
1858
|
+
offset += audioData.audioBuffer[0].length;
|
|
1859
|
+
} else {
|
|
1860
|
+
offset = soundfile.emptyFile(part, offset);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
for (let part = soundfileIdList.length; part < Soundfile.MAX_SOUNDFILE_PARTS; part++) {
|
|
1864
|
+
offset = soundfile.emptyFile(part, offset);
|
|
1865
|
+
}
|
|
1866
|
+
soundfile.shareBuffers(curChan, maxChan);
|
|
1867
|
+
return soundfile;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Init soundfiles memory.
|
|
1871
|
+
*
|
|
1872
|
+
* @param allocator : the wasm memory allocator
|
|
1873
|
+
* @param sfReader : the soundfile reader
|
|
1874
|
+
* @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
|
|
1875
|
+
*/
|
|
1876
|
+
initSoundfileMemory(allocator, baseDSP) {
|
|
2368
1877
|
for (const { name, url } of this.fSoundfiles) {
|
|
2369
|
-
|
|
1878
|
+
this.loadSoundfile(allocator, baseDSP, name, url);
|
|
2370
1879
|
}
|
|
2371
1880
|
;
|
|
2372
1881
|
}
|
|
@@ -2379,6 +1888,7 @@ var FaustBaseWebAudioDsp = class {
|
|
|
2379
1888
|
});
|
|
2380
1889
|
}
|
|
2381
1890
|
}
|
|
1891
|
+
// Public API
|
|
2382
1892
|
metadata(handler) {
|
|
2383
1893
|
if (this.fJSONDsp.meta) {
|
|
2384
1894
|
this.fJSONDsp.meta.forEach((meta) => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]]));
|
|
@@ -2429,7 +1939,7 @@ var FaustBaseWebAudioDsp = class {
|
|
|
2429
1939
|
if (this.fCtrlLabel[ctrl].length) {
|
|
2430
1940
|
this.fCtrlLabel[ctrl].forEach((ctrl2) => {
|
|
2431
1941
|
const { path } = ctrl2;
|
|
2432
|
-
this.setParamValue(path,
|
|
1942
|
+
this.setParamValue(path, _FaustBaseWebAudioDsp.remap(value, 0, 127, ctrl2.min, ctrl2.max));
|
|
2433
1943
|
if (this.fOutputHandler)
|
|
2434
1944
|
this.fOutputHandler(path, this.getParamValue(path));
|
|
2435
1945
|
});
|
|
@@ -2439,7 +1949,7 @@ var FaustBaseWebAudioDsp = class {
|
|
|
2439
1949
|
if (this.fPlotHandler)
|
|
2440
1950
|
this.fCachedEvents.push({ type: "pitchWheel", data: [channel, wheel] });
|
|
2441
1951
|
this.fPitchwheelLabel.forEach((pw) => {
|
|
2442
|
-
this.setParamValue(pw.path,
|
|
1952
|
+
this.setParamValue(pw.path, _FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max));
|
|
2443
1953
|
if (this.fOutputHandler)
|
|
2444
1954
|
this.fOutputHandler(pw.path, this.getParamValue(pw.path));
|
|
2445
1955
|
});
|
|
@@ -2481,20 +1991,17 @@ var FaustBaseWebAudioDsp = class {
|
|
|
2481
1991
|
}
|
|
2482
1992
|
};
|
|
2483
1993
|
var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
2484
|
-
constructor(instance, sampleRate, sampleSize, bufferSize) {
|
|
2485
|
-
super(sampleSize, bufferSize);
|
|
1994
|
+
constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) {
|
|
1995
|
+
super(sampleSize, bufferSize, soundfiles);
|
|
2486
1996
|
this.fInstance = instance;
|
|
2487
|
-
console.log(
|
|
1997
|
+
console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);
|
|
2488
1998
|
this.fJSONDsp = JSON.parse(this.fInstance.json);
|
|
2489
1999
|
FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);
|
|
2490
2000
|
this.fEndMemory = this.initMemory();
|
|
2491
2001
|
this.fInstance.api.init(this.fDSP, sampleRate);
|
|
2492
|
-
|
|
2493
|
-
async init(context) {
|
|
2494
|
-
if (this.fSoundfiles.length > 0 && context) {
|
|
2002
|
+
if (this.fSoundfiles.length > 0) {
|
|
2495
2003
|
const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);
|
|
2496
|
-
|
|
2497
|
-
await this.initSoundfileMemory(allocator, sfReader, this.fDSP);
|
|
2004
|
+
this.initSoundfileMemory(allocator, this.fDSP);
|
|
2498
2005
|
}
|
|
2499
2006
|
}
|
|
2500
2007
|
initMemory() {
|
|
@@ -2536,6 +2043,7 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2536
2043
|
this.fAudioOutputs: ${this.fAudioOutputs}
|
|
2537
2044
|
this.fDSP: ${this.fDSP}`;
|
|
2538
2045
|
}
|
|
2046
|
+
// Public API
|
|
2539
2047
|
compute(input, output) {
|
|
2540
2048
|
if (this.fDestroyed)
|
|
2541
2049
|
return false;
|
|
@@ -2611,28 +2119,45 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2611
2119
|
return this.fJSONDsp.ui;
|
|
2612
2120
|
}
|
|
2613
2121
|
};
|
|
2614
|
-
var FaustWebAudioDspVoice = class {
|
|
2122
|
+
var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice {
|
|
2615
2123
|
constructor($dsp, api, inputItems, pathTable, sampleRate) {
|
|
2616
|
-
|
|
2617
|
-
FaustWebAudioDspVoice.kFreeVoice = -1;
|
|
2618
|
-
FaustWebAudioDspVoice.kReleaseVoice = -2;
|
|
2619
|
-
FaustWebAudioDspVoice.kLegatoVoice = -3;
|
|
2620
|
-
FaustWebAudioDspVoice.kNoVoice = -4;
|
|
2621
|
-
FaustWebAudioDspVoice.VOICE_STOP_LEVEL = 5e-4;
|
|
2622
|
-
this.fCurNote = FaustWebAudioDspVoice.kFreeVoice;
|
|
2623
|
-
this.fNextNote = this.fNextVel = -1;
|
|
2624
|
-
this.fLevel = 0;
|
|
2625
|
-
this.fDate = this.fRelease = 0;
|
|
2626
|
-
this.fDSP = $dsp;
|
|
2627
|
-
this.fAPI = api;
|
|
2124
|
+
this.fFreqLabel = [];
|
|
2628
2125
|
this.fGateLabel = [];
|
|
2629
2126
|
this.fGainLabel = [];
|
|
2630
|
-
this.fFreqLabel = [];
|
|
2631
2127
|
this.fKeyLabel = [];
|
|
2632
2128
|
this.fVelLabel = [];
|
|
2129
|
+
// Voice DSP code
|
|
2130
|
+
// Accessed by PolyDSPImp class
|
|
2131
|
+
this.fCurNote = _FaustWebAudioDspVoice.kFreeVoice;
|
|
2132
|
+
this.fNextNote = -1;
|
|
2133
|
+
this.fNextVel = -1;
|
|
2134
|
+
this.fDate = 0;
|
|
2135
|
+
this.fLevel = 0;
|
|
2136
|
+
this.fRelease = 0;
|
|
2137
|
+
this.fDSP = $dsp;
|
|
2138
|
+
this.fAPI = api;
|
|
2633
2139
|
this.fAPI.init(this.fDSP, sampleRate);
|
|
2634
2140
|
this.extractPaths(inputItems, pathTable);
|
|
2635
2141
|
}
|
|
2142
|
+
// Voice state
|
|
2143
|
+
static get kActiveVoice() {
|
|
2144
|
+
return 0;
|
|
2145
|
+
}
|
|
2146
|
+
static get kFreeVoice() {
|
|
2147
|
+
return -1;
|
|
2148
|
+
}
|
|
2149
|
+
static get kReleaseVoice() {
|
|
2150
|
+
return -2;
|
|
2151
|
+
}
|
|
2152
|
+
static get kLegatoVoice() {
|
|
2153
|
+
return -3;
|
|
2154
|
+
}
|
|
2155
|
+
static get kNoVoice() {
|
|
2156
|
+
return -4;
|
|
2157
|
+
}
|
|
2158
|
+
static get VOICE_STOP_LEVEL() {
|
|
2159
|
+
return 5e-4;
|
|
2160
|
+
}
|
|
2636
2161
|
static midiToFreq(note) {
|
|
2637
2162
|
return 440 * 2 ** ((note - 69) / 12);
|
|
2638
2163
|
}
|
|
@@ -2654,14 +2179,15 @@ var FaustWebAudioDspVoice = class {
|
|
|
2654
2179
|
}
|
|
2655
2180
|
});
|
|
2656
2181
|
}
|
|
2182
|
+
// Public API
|
|
2657
2183
|
keyOn(pitch, velocity, legato = false) {
|
|
2658
2184
|
if (legato) {
|
|
2659
2185
|
this.fNextNote = pitch;
|
|
2660
2186
|
this.fNextVel = velocity;
|
|
2661
2187
|
} else {
|
|
2662
|
-
this.fFreqLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index,
|
|
2188
|
+
this.fFreqLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, _FaustWebAudioDspVoice.midiToFreq(pitch)));
|
|
2663
2189
|
this.fGateLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, 1));
|
|
2664
|
-
this.fGainLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index,
|
|
2190
|
+
this.fGainLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, _FaustWebAudioDspVoice.normalizeVelocity(velocity)));
|
|
2665
2191
|
this.fKeyLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, pitch));
|
|
2666
2192
|
this.fVelLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, velocity));
|
|
2667
2193
|
this.fCurNote = pitch;
|
|
@@ -2670,10 +2196,10 @@ var FaustWebAudioDspVoice = class {
|
|
|
2670
2196
|
keyOff(hard = false) {
|
|
2671
2197
|
this.fGateLabel.forEach((index) => this.fAPI.setParamValue(this.fDSP, index, 0));
|
|
2672
2198
|
if (hard) {
|
|
2673
|
-
this.fCurNote =
|
|
2199
|
+
this.fCurNote = _FaustWebAudioDspVoice.kFreeVoice;
|
|
2674
2200
|
} else {
|
|
2675
2201
|
this.fRelease = this.fAPI.getSampleRate(this.fDSP) / 2;
|
|
2676
|
-
this.fCurNote =
|
|
2202
|
+
this.fCurNote = _FaustWebAudioDspVoice.kReleaseVoice;
|
|
2677
2203
|
}
|
|
2678
2204
|
}
|
|
2679
2205
|
computeLegato(bufferSize, $inputs, $outputZero, $outputsHalf) {
|
|
@@ -2693,11 +2219,11 @@ var FaustWebAudioDspVoice = class {
|
|
|
2693
2219
|
return this.fAPI.getParamValue(this.fDSP, index);
|
|
2694
2220
|
}
|
|
2695
2221
|
};
|
|
2696
|
-
var FaustPolyWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
2697
|
-
constructor(instance, sampleRate, sampleSize, bufferSize) {
|
|
2698
|
-
super(sampleSize, bufferSize);
|
|
2222
|
+
var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudioDsp {
|
|
2223
|
+
constructor(instance, sampleRate, sampleSize, bufferSize, soundfiles) {
|
|
2224
|
+
super(sampleSize, bufferSize, soundfiles);
|
|
2699
2225
|
this.fInstance = instance;
|
|
2700
|
-
console.log(
|
|
2226
|
+
console.log(`sampleSize: ${sampleSize} bufferSize: ${bufferSize}`);
|
|
2701
2227
|
this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);
|
|
2702
2228
|
this.fJSONEffect = this.fInstance.effectAPI && this.fInstance.effectJSON ? JSON.parse(this.fInstance.effectJSON) : null;
|
|
2703
2229
|
FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);
|
|
@@ -2716,13 +2242,10 @@ var FaustPolyWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2716
2242
|
}
|
|
2717
2243
|
if (this.fInstance.effectAPI)
|
|
2718
2244
|
this.fInstance.effectAPI.init(this.fEffect, sampleRate);
|
|
2719
|
-
|
|
2720
|
-
async init(context) {
|
|
2721
|
-
if (this.fSoundfiles.length > 0 && context) {
|
|
2245
|
+
if (this.fSoundfiles.length > 0) {
|
|
2722
2246
|
const allocator = new WasmAllocator(this.fInstance.memory, this.fEndMemory);
|
|
2723
|
-
const sfReader = new SoundfileReader(allocator, context, this.fSampleSize);
|
|
2724
2247
|
for (let voice = 0; voice < this.fInstance.voices; voice++) {
|
|
2725
|
-
|
|
2248
|
+
this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);
|
|
2726
2249
|
}
|
|
2727
2250
|
}
|
|
2728
2251
|
}
|
|
@@ -2820,6 +2343,7 @@ var FaustPolyWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2820
2343
|
}
|
|
2821
2344
|
return FaustWebAudioDspVoice.kNoVoice;
|
|
2822
2345
|
}
|
|
2346
|
+
// Public API
|
|
2823
2347
|
compute(input, output) {
|
|
2824
2348
|
if (this.fDestroyed)
|
|
2825
2349
|
return false;
|
|
@@ -2886,7 +2410,7 @@ var FaustPolyWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2886
2410
|
return o.address === p;
|
|
2887
2411
|
} else {
|
|
2888
2412
|
for (const k in o) {
|
|
2889
|
-
if (
|
|
2413
|
+
if (_FaustPolyWebAudioDsp.findPath(o[k], p))
|
|
2890
2414
|
return true;
|
|
2891
2415
|
}
|
|
2892
2416
|
return false;
|
|
@@ -2895,14 +2419,14 @@ var FaustPolyWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
2895
2419
|
setParamValue(path, value) {
|
|
2896
2420
|
if (this.fPlotHandler)
|
|
2897
2421
|
this.fCachedEvents.push({ type: "param", data: { path, value } });
|
|
2898
|
-
if (this.fJSONEffect &&
|
|
2422
|
+
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
2899
2423
|
this.fInstance.effectAPI.setParamValue(this.fEffect, this.fPathTable[path], value);
|
|
2900
2424
|
} else {
|
|
2901
2425
|
this.fVoiceTable.forEach((voice) => voice.setParamValue(this.fPathTable[path], value));
|
|
2902
2426
|
}
|
|
2903
2427
|
}
|
|
2904
2428
|
getParamValue(path) {
|
|
2905
|
-
if (this.fJSONEffect &&
|
|
2429
|
+
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
2906
2430
|
return this.fInstance.effectAPI.getParamValue(this.fEffect, this.fPathTable[path]);
|
|
2907
2431
|
} else {
|
|
2908
2432
|
return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);
|
|
@@ -2990,6 +2514,7 @@ var FaustOfflineProcessor = class {
|
|
|
2990
2514
|
this.fInputs = new Array(this.fDSPCode.getNumInputs()).fill(null).map(() => new Float32Array(bufferSize));
|
|
2991
2515
|
this.fOutputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(bufferSize));
|
|
2992
2516
|
}
|
|
2517
|
+
// Public API
|
|
2993
2518
|
getParameterDescriptors() {
|
|
2994
2519
|
const params = [];
|
|
2995
2520
|
const callback = (item) => {
|
|
@@ -3077,12 +2602,20 @@ var FaustOfflineProcessor = class {
|
|
|
3077
2602
|
destroy() {
|
|
3078
2603
|
this.fDSPCode.destroy();
|
|
3079
2604
|
}
|
|
3080
|
-
|
|
2605
|
+
/**
|
|
2606
|
+
* Render frames in an array.
|
|
2607
|
+
*
|
|
2608
|
+
* @param inputs - input signal
|
|
2609
|
+
* @param length - the number of frames to render (default: bufferSize)
|
|
2610
|
+
* @param onUpdate - a callback after each buffer calculated, with an argument "current sample"
|
|
2611
|
+
* @return an array of Float32Array with the rendered frames
|
|
2612
|
+
*/
|
|
2613
|
+
render(inputs = [], length = this.fBufferSize, onUpdate) {
|
|
3081
2614
|
let l = 0;
|
|
3082
|
-
const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(
|
|
2615
|
+
const outputs = new Array(this.fDSPCode.getNumOutputs()).fill(null).map(() => new Float32Array(length));
|
|
3083
2616
|
this.fDSPCode.start();
|
|
3084
|
-
while (l <
|
|
3085
|
-
const sliceLength = Math.min(
|
|
2617
|
+
while (l < length) {
|
|
2618
|
+
const sliceLength = Math.min(length - l, this.fBufferSize);
|
|
3086
2619
|
for (let i = 0; i < this.fDSPCode.getNumInputs(); i++) {
|
|
3087
2620
|
let input;
|
|
3088
2621
|
if (inputs[i]) {
|
|
@@ -3154,12 +2687,12 @@ var FaustSvgDiagrams_default = FaustSvgDiagrams;
|
|
|
3154
2687
|
|
|
3155
2688
|
// src/FaustCmajor.ts
|
|
3156
2689
|
var FaustCmajor = class {
|
|
3157
|
-
constructor(
|
|
3158
|
-
this.
|
|
2690
|
+
constructor(compiler) {
|
|
2691
|
+
this.fCompiler = compiler;
|
|
3159
2692
|
}
|
|
3160
2693
|
compile(name, code, args) {
|
|
3161
|
-
const fs = this.
|
|
3162
|
-
const success = this.
|
|
2694
|
+
const fs = this.fCompiler.fs();
|
|
2695
|
+
const success = this.fCompiler.generateAuxFiles(name, code, `-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`);
|
|
3163
2696
|
return success ? fs.readFile(`${name}.cmajor`, { encoding: "utf8" }) : "";
|
|
3164
2697
|
}
|
|
3165
2698
|
};
|
|
@@ -3215,11 +2748,11 @@ var LibFaust_default = LibFaust;
|
|
|
3215
2748
|
var WavEncoder = class {
|
|
3216
2749
|
static encode(audioBuffer, options) {
|
|
3217
2750
|
const numberOfChannels = audioBuffer.length;
|
|
3218
|
-
const
|
|
2751
|
+
const length = audioBuffer[0].length;
|
|
3219
2752
|
const { shared, float } = options;
|
|
3220
2753
|
const bitDepth = float ? 32 : options.bitDepth | 0 || 16;
|
|
3221
2754
|
const byteDepth = bitDepth >> 3;
|
|
3222
|
-
const byteLength =
|
|
2755
|
+
const byteLength = length * numberOfChannels * byteDepth;
|
|
3223
2756
|
const AB = shared ? globalThis.SharedArrayBuffer || globalThis.ArrayBuffer : globalThis.ArrayBuffer;
|
|
3224
2757
|
const ab = new AB((44 + byteLength) * Uint8Array.BYTES_PER_ELEMENT);
|
|
3225
2758
|
const dataView = new DataView(ab);
|
|
@@ -3230,7 +2763,7 @@ var WavEncoder = class {
|
|
|
3230
2763
|
numberOfChannels,
|
|
3231
2764
|
sampleRate: options.sampleRate,
|
|
3232
2765
|
symmetric: !!options.symmetric,
|
|
3233
|
-
length
|
|
2766
|
+
length,
|
|
3234
2767
|
bitDepth,
|
|
3235
2768
|
byteDepth
|
|
3236
2769
|
};
|
|
@@ -3239,7 +2772,7 @@ var WavEncoder = class {
|
|
|
3239
2772
|
return ab;
|
|
3240
2773
|
}
|
|
3241
2774
|
static writeHeader(writer, format) {
|
|
3242
|
-
const { formatId, sampleRate, bitDepth, numberOfChannels, length
|
|
2775
|
+
const { formatId, sampleRate, bitDepth, numberOfChannels, length, byteDepth } = format;
|
|
3243
2776
|
writer.string("RIFF");
|
|
3244
2777
|
writer.uint32(writer.dataView.byteLength - 8);
|
|
3245
2778
|
writer.string("WAVE");
|
|
@@ -3252,11 +2785,11 @@ var WavEncoder = class {
|
|
|
3252
2785
|
writer.uint16(numberOfChannels * byteDepth);
|
|
3253
2786
|
writer.uint16(bitDepth);
|
|
3254
2787
|
writer.string("data");
|
|
3255
|
-
writer.uint32(
|
|
2788
|
+
writer.uint32(length * numberOfChannels * byteDepth);
|
|
3256
2789
|
return writer.pos;
|
|
3257
2790
|
}
|
|
3258
2791
|
static writeData(writer, audioBuffer, format) {
|
|
3259
|
-
const { bitDepth, float, length
|
|
2792
|
+
const { bitDepth, float, length, numberOfChannels, symmetric } = format;
|
|
3260
2793
|
if (bitDepth === 32 && float) {
|
|
3261
2794
|
const { dataView, pos } = writer;
|
|
3262
2795
|
const ab = dataView.buffer;
|
|
@@ -3267,7 +2800,7 @@ var WavEncoder = class {
|
|
|
3267
2800
|
}
|
|
3268
2801
|
for (let ch = 0; ch < numberOfChannels; ch++) {
|
|
3269
2802
|
const channel = audioBuffer[ch];
|
|
3270
|
-
for (let i = 0; i <
|
|
2803
|
+
for (let i = 0; i < length; i++) {
|
|
3271
2804
|
f32View[i * numberOfChannels + ch] = channel[i];
|
|
3272
2805
|
}
|
|
3273
2806
|
}
|
|
@@ -3279,7 +2812,7 @@ var WavEncoder = class {
|
|
|
3279
2812
|
throw new TypeError("Not supported bit depth: " + bitDepth);
|
|
3280
2813
|
}
|
|
3281
2814
|
const write = writer[methodName].bind(writer);
|
|
3282
|
-
for (let i = 0; i <
|
|
2815
|
+
for (let i = 0; i < length; i++) {
|
|
3283
2816
|
for (let j = 0; j < numberOfChannels; j++) {
|
|
3284
2817
|
write(audioBuffer[j][i]);
|
|
3285
2818
|
}
|
|
@@ -3313,14 +2846,22 @@ var Writer = class {
|
|
|
3313
2846
|
value = Math.max(-1, Math.min(value, 1));
|
|
3314
2847
|
value = (value * 0.5 + 0.5) * 255;
|
|
3315
2848
|
value = Math.round(value) | 0;
|
|
3316
|
-
this.dataView.setUint8(
|
|
2849
|
+
this.dataView.setUint8(
|
|
2850
|
+
this.pos,
|
|
2851
|
+
value
|
|
2852
|
+
/* , true*/
|
|
2853
|
+
);
|
|
3317
2854
|
this.pos += 1;
|
|
3318
2855
|
}
|
|
3319
2856
|
pcm8s(valueIn) {
|
|
3320
2857
|
let value = valueIn;
|
|
3321
2858
|
value = Math.round(value * 128) + 128;
|
|
3322
2859
|
value = Math.max(0, Math.min(value, 255));
|
|
3323
|
-
this.dataView.setUint8(
|
|
2860
|
+
this.dataView.setUint8(
|
|
2861
|
+
this.pos,
|
|
2862
|
+
value
|
|
2863
|
+
/* , true*/
|
|
2864
|
+
);
|
|
3324
2865
|
this.pos += 1;
|
|
3325
2866
|
}
|
|
3326
2867
|
pcm16(valueIn) {
|
|
@@ -3435,24 +2976,24 @@ var WavDecoder = class {
|
|
|
3435
2976
|
}
|
|
3436
2977
|
static decodeData(reader, chunkSizeIn, format, options) {
|
|
3437
2978
|
const chunkSize = Math.min(chunkSizeIn, reader.remain());
|
|
3438
|
-
const
|
|
2979
|
+
const length = Math.floor(chunkSize / format.blockSize);
|
|
3439
2980
|
const numberOfChannels = format.numberOfChannels;
|
|
3440
2981
|
const sampleRate = format.sampleRate;
|
|
3441
2982
|
const channelData = new Array(numberOfChannels);
|
|
3442
2983
|
for (let ch = 0; ch < numberOfChannels; ch++) {
|
|
3443
2984
|
const AB = options.shared ? globalThis.SharedArrayBuffer || globalThis.ArrayBuffer : globalThis.ArrayBuffer;
|
|
3444
|
-
const ab = new AB(
|
|
2985
|
+
const ab = new AB(length * Float32Array.BYTES_PER_ELEMENT);
|
|
3445
2986
|
channelData[ch] = new Float32Array(ab);
|
|
3446
2987
|
}
|
|
3447
|
-
this.readPCM(reader, channelData,
|
|
2988
|
+
this.readPCM(reader, channelData, length, format, options);
|
|
3448
2989
|
return {
|
|
3449
2990
|
numberOfChannels,
|
|
3450
|
-
length
|
|
2991
|
+
length,
|
|
3451
2992
|
sampleRate,
|
|
3452
2993
|
channelData
|
|
3453
2994
|
};
|
|
3454
2995
|
}
|
|
3455
|
-
static readPCM(reader, channelData,
|
|
2996
|
+
static readPCM(reader, channelData, length, format, options) {
|
|
3456
2997
|
const bitDepth = format.bitDepth;
|
|
3457
2998
|
const decoderOption = format.float ? "f" : options.symmetric ? "s" : "";
|
|
3458
2999
|
const methodName = "pcm" + bitDepth + decoderOption;
|
|
@@ -3461,7 +3002,7 @@ var WavDecoder = class {
|
|
|
3461
3002
|
}
|
|
3462
3003
|
const read = reader[methodName].bind(reader);
|
|
3463
3004
|
const numberOfChannels = format.numberOfChannels;
|
|
3464
|
-
for (let i = 0; i <
|
|
3005
|
+
for (let i = 0; i < length; i++) {
|
|
3465
3006
|
for (let ch = 0; ch < numberOfChannels; ch++) {
|
|
3466
3007
|
channelData[ch][i] = read();
|
|
3467
3008
|
}
|
|
@@ -3567,6 +3108,118 @@ var Reader = class {
|
|
|
3567
3108
|
};
|
|
3568
3109
|
var WavDecoder_default = WavDecoder;
|
|
3569
3110
|
|
|
3111
|
+
// src/SoundfileReader.ts
|
|
3112
|
+
var SoundfileReader = class {
|
|
3113
|
+
static get fallbackPaths() {
|
|
3114
|
+
return [location.href, location.origin, "http://127.0.0.1:8000"];
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Convert an audio buffer to audio data.
|
|
3118
|
+
*
|
|
3119
|
+
* @param audioBuffer : the audio buffer to convert
|
|
3120
|
+
* @returns : the audio data
|
|
3121
|
+
*/
|
|
3122
|
+
static toAudioData(audioBuffer) {
|
|
3123
|
+
const { sampleRate, numberOfChannels } = audioBuffer;
|
|
3124
|
+
return {
|
|
3125
|
+
sampleRate,
|
|
3126
|
+
audioBuffer: new Array(numberOfChannels).fill(null).map((v, i) => audioBuffer.getChannelData(i))
|
|
3127
|
+
};
|
|
3128
|
+
}
|
|
3129
|
+
/**
|
|
3130
|
+
* Extract the URLs from the metadata.
|
|
3131
|
+
*
|
|
3132
|
+
* @param dspMeta : the metadata
|
|
3133
|
+
* @returns : the URLs
|
|
3134
|
+
*/
|
|
3135
|
+
static findSoundfilesFromMeta(dspMeta) {
|
|
3136
|
+
const soundfiles = {};
|
|
3137
|
+
const callback = (item) => {
|
|
3138
|
+
if (item.type === "soundfile") {
|
|
3139
|
+
const urls = FaustBaseWebAudioDsp.splitSoundfileNames(item.url);
|
|
3140
|
+
urls.forEach((url) => soundfiles[url] = null);
|
|
3141
|
+
}
|
|
3142
|
+
};
|
|
3143
|
+
FaustBaseWebAudioDsp.parseUI(dspMeta.ui, callback);
|
|
3144
|
+
return soundfiles;
|
|
3145
|
+
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Check if the file exists.
|
|
3148
|
+
*
|
|
3149
|
+
* @param url : the url of the file to check
|
|
3150
|
+
* @returns : true if the file exists, otherwise false
|
|
3151
|
+
*/
|
|
3152
|
+
static async checkFileExists(url) {
|
|
3153
|
+
try {
|
|
3154
|
+
console.log(`"checkFileExists" url: ${url}`);
|
|
3155
|
+
const response = await fetch(url, { method: "HEAD" });
|
|
3156
|
+
return response.ok;
|
|
3157
|
+
} catch (error) {
|
|
3158
|
+
console.error("Fetch error:", error);
|
|
3159
|
+
return false;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Fetch the soundfile.
|
|
3164
|
+
*
|
|
3165
|
+
* @param url : the url of the soundfile
|
|
3166
|
+
* @param audioCtx : the audio context
|
|
3167
|
+
* @returns : the audio data
|
|
3168
|
+
*/
|
|
3169
|
+
static async fetchSoundfile(url, audioCtx) {
|
|
3170
|
+
console.log(`Loading sound file from ${url}`);
|
|
3171
|
+
const response = await fetch(url);
|
|
3172
|
+
if (!response.ok)
|
|
3173
|
+
throw new Error(`Failed to load sound file from ${url}: ${response.statusText}`);
|
|
3174
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3175
|
+
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
|
3176
|
+
return this.toAudioData(audioBuffer);
|
|
3177
|
+
}
|
|
3178
|
+
/**
|
|
3179
|
+
* Load the soundfile.
|
|
3180
|
+
*
|
|
3181
|
+
* @param filename : the filename
|
|
3182
|
+
* @param metaUrls : the metadata URLs
|
|
3183
|
+
* @param soundfiles : the soundfiles
|
|
3184
|
+
* @param audioCtx : the audio context
|
|
3185
|
+
*/
|
|
3186
|
+
static async loadSoundfile(filename, metaUrls, soundfiles, audioCtx) {
|
|
3187
|
+
if (soundfiles[filename])
|
|
3188
|
+
return;
|
|
3189
|
+
const urlsToCheck = [filename, ...[...metaUrls, ...this.fallbackPaths].map((path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href)];
|
|
3190
|
+
const checkResults = await Promise.all(urlsToCheck.map((url) => this.checkFileExists(url)));
|
|
3191
|
+
const successIndex = checkResults.findIndex((r) => !!r);
|
|
3192
|
+
if (successIndex === -1)
|
|
3193
|
+
throw new Error(`Failed to load sound file ${filename}, all check failed.`);
|
|
3194
|
+
soundfiles[filename] = await this.fetchSoundfile(urlsToCheck[successIndex], audioCtx);
|
|
3195
|
+
}
|
|
3196
|
+
/**
|
|
3197
|
+
* Load the soundfiles, public API.
|
|
3198
|
+
*
|
|
3199
|
+
* @param dspMeta : the metadata
|
|
3200
|
+
* @param soundfilesIn : the soundfiles
|
|
3201
|
+
* @param audioCtx : the audio context
|
|
3202
|
+
* @returns : the soundfiles
|
|
3203
|
+
*/
|
|
3204
|
+
static async loadSoundfiles(dspMeta, soundfilesIn, audioCtx) {
|
|
3205
|
+
const metaUrls = FaustBaseWebAudioDsp.extractUrlsFromMeta(dspMeta);
|
|
3206
|
+
const soundfiles = this.findSoundfilesFromMeta(dspMeta);
|
|
3207
|
+
for (const id in soundfiles) {
|
|
3208
|
+
if (soundfilesIn[id]) {
|
|
3209
|
+
soundfiles[id] = soundfilesIn[id];
|
|
3210
|
+
continue;
|
|
3211
|
+
}
|
|
3212
|
+
try {
|
|
3213
|
+
await this.loadSoundfile(id, metaUrls, soundfiles, audioCtx);
|
|
3214
|
+
} catch (error) {
|
|
3215
|
+
console.error(error);
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
return soundfiles;
|
|
3219
|
+
}
|
|
3220
|
+
};
|
|
3221
|
+
var SoundfileReader_default = SoundfileReader;
|
|
3222
|
+
|
|
3570
3223
|
// src/FaustAudioWorkletNode.ts
|
|
3571
3224
|
var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null) {
|
|
3572
3225
|
constructor(context, name, factory, options, nodeOptions = {}) {
|
|
@@ -3603,6 +3256,7 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3603
3256
|
}
|
|
3604
3257
|
};
|
|
3605
3258
|
}
|
|
3259
|
+
// Public API
|
|
3606
3260
|
setOutputParamHandler(handler) {
|
|
3607
3261
|
this.fOutputHandler = handler;
|
|
3608
3262
|
}
|
|
@@ -3632,6 +3286,7 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
3632
3286
|
getNumOutputs() {
|
|
3633
3287
|
return this.fJSONDsp.outputs;
|
|
3634
3288
|
}
|
|
3289
|
+
// Implemented in subclasses
|
|
3635
3290
|
compute(inputs, outputs) {
|
|
3636
3291
|
return false;
|
|
3637
3292
|
}
|
|
@@ -3729,6 +3384,7 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
|
3729
3384
|
FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
|
|
3730
3385
|
}
|
|
3731
3386
|
}
|
|
3387
|
+
// Public API
|
|
3732
3388
|
keyOn(channel, pitch, velocity) {
|
|
3733
3389
|
const e = { type: "keyOn", data: [channel, pitch, velocity] };
|
|
3734
3390
|
this.port.postMessage(e);
|
|
@@ -3790,6 +3446,7 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
3790
3446
|
};
|
|
3791
3447
|
this.start();
|
|
3792
3448
|
}
|
|
3449
|
+
// Public API
|
|
3793
3450
|
compute(input, output) {
|
|
3794
3451
|
return this.fDSPCode.compute(input, output);
|
|
3795
3452
|
}
|
|
@@ -3874,7 +3531,7 @@ var FaustPolyScriptProcessorNode = class extends FaustScriptProcessorNode {
|
|
|
3874
3531
|
};
|
|
3875
3532
|
|
|
3876
3533
|
// src/FaustDspGenerator.ts
|
|
3877
|
-
var _FaustMonoDspGenerator = class {
|
|
3534
|
+
var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
3878
3535
|
constructor() {
|
|
3879
3536
|
this.factory = null;
|
|
3880
3537
|
}
|
|
@@ -3893,10 +3550,10 @@ var _FaustMonoDspGenerator = class {
|
|
|
3893
3550
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
3894
3551
|
const meta = JSON.parse(factory.json);
|
|
3895
3552
|
const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
3553
|
+
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
|
|
3896
3554
|
if (sp) {
|
|
3897
3555
|
const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
|
|
3898
|
-
const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize);
|
|
3899
|
-
await monoDsp.init(context);
|
|
3556
|
+
const monoDsp = new FaustMonoWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, factory.soundfiles);
|
|
3900
3557
|
const sp2 = context.createScriptProcessor(bufferSize, monoDsp.getNumInputs(), monoDsp.getNumOutputs());
|
|
3901
3558
|
Object.setPrototypeOf(sp2, FaustMonoScriptProcessorNode.prototype);
|
|
3902
3559
|
sp2.init(monoDsp);
|
|
@@ -3915,15 +3572,23 @@ const faustData = ${JSON.stringify({
|
|
|
3915
3572
|
poly: false
|
|
3916
3573
|
})};
|
|
3917
3574
|
// Implementation needed classes of functions
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3575
|
+
var ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
3576
|
+
var FaustDspInstance = ${FaustDspInstance.name};
|
|
3577
|
+
var ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
3578
|
+
var FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};
|
|
3579
|
+
var ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}
|
|
3580
|
+
var FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};
|
|
3581
|
+
var ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()}
|
|
3582
|
+
var FaustWasmInstantiator = ${FaustWasmInstantiator_default.name};
|
|
3583
|
+
var ${Soundfile.name} = ${Soundfile.toString()}
|
|
3584
|
+
var Soundfile = ${Soundfile.name};
|
|
3585
|
+
var ${WasmAllocator.name} = ${WasmAllocator.toString()}
|
|
3586
|
+
var WasmAllocator = ${WasmAllocator.name};
|
|
3922
3587
|
// Put them in dependencies
|
|
3923
3588
|
const dependencies = {
|
|
3924
|
-
FaustBaseWebAudioDsp
|
|
3925
|
-
FaustMonoWebAudioDsp
|
|
3926
|
-
FaustWasmInstantiator
|
|
3589
|
+
FaustBaseWebAudioDsp,
|
|
3590
|
+
FaustMonoWebAudioDsp,
|
|
3591
|
+
FaustWasmInstantiator
|
|
3927
3592
|
};
|
|
3928
3593
|
// Generate the actual AudioWorkletProcessor code
|
|
3929
3594
|
(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
@@ -3945,6 +3610,7 @@ const dependencies = {
|
|
|
3945
3610
|
throw new Error("Code is not compiled, please define the factory or call `await this.compile()` first.");
|
|
3946
3611
|
const meta = JSON.parse(factory.json);
|
|
3947
3612
|
const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
3613
|
+
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(meta, factory.soundfiles || {}, context);
|
|
3948
3614
|
if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
|
|
3949
3615
|
_FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
|
|
3950
3616
|
if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
|
|
@@ -3958,16 +3624,24 @@ const faustData = ${JSON.stringify({
|
|
|
3958
3624
|
fftOptions
|
|
3959
3625
|
})};
|
|
3960
3626
|
// Implementation needed classes of functions
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3627
|
+
var ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
3628
|
+
var FaustDspInstance = ${FaustDspInstance.name};
|
|
3629
|
+
var ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
3630
|
+
var FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};
|
|
3631
|
+
var ${FaustMonoWebAudioDsp.name} = ${FaustMonoWebAudioDsp.toString()}
|
|
3632
|
+
var FaustMonoWebAudioDsp = ${FaustMonoWebAudioDsp.name};
|
|
3633
|
+
var ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()}
|
|
3634
|
+
var FaustWasmInstantiator = ${FaustWasmInstantiator_default.name};
|
|
3635
|
+
var ${Soundfile.name} = ${Soundfile.toString()}
|
|
3636
|
+
var Soundfile = ${Soundfile.name};
|
|
3637
|
+
var ${WasmAllocator.name} = ${WasmAllocator.toString()}
|
|
3638
|
+
var WasmAllocator = ${WasmAllocator.name};
|
|
3639
|
+
var FFTUtils = ${fftUtils.toString()}
|
|
3966
3640
|
// Put them in dependencies
|
|
3967
3641
|
const dependencies = {
|
|
3968
|
-
FaustBaseWebAudioDsp
|
|
3969
|
-
FaustMonoWebAudioDsp
|
|
3970
|
-
FaustWasmInstantiator
|
|
3642
|
+
FaustBaseWebAudioDsp,
|
|
3643
|
+
FaustMonoWebAudioDsp,
|
|
3644
|
+
FaustWasmInstantiator,
|
|
3971
3645
|
FFTUtils
|
|
3972
3646
|
};
|
|
3973
3647
|
// Generate the actual AudioWorkletProcessor code
|
|
@@ -4033,8 +3707,7 @@ const dependencies = {
|
|
|
4033
3707
|
const meta = JSON.parse(factory.json);
|
|
4034
3708
|
const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
|
|
4035
3709
|
const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
4036
|
-
const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize);
|
|
4037
|
-
await monoDsp.init(null);
|
|
3710
|
+
const monoDsp = new FaustMonoWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, factory.soundfiles);
|
|
4038
3711
|
return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
|
|
4039
3712
|
}
|
|
4040
3713
|
getMeta() {
|
|
@@ -4047,9 +3720,10 @@ const dependencies = {
|
|
|
4047
3720
|
return this.getMeta().ui;
|
|
4048
3721
|
}
|
|
4049
3722
|
};
|
|
3723
|
+
// Set of all created WorkletProcessors, each of them has to be unique
|
|
3724
|
+
_FaustMonoDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map();
|
|
4050
3725
|
var FaustMonoDspGenerator = _FaustMonoDspGenerator;
|
|
4051
|
-
|
|
4052
|
-
var _FaustPolyDspGenerator = class {
|
|
3726
|
+
var _FaustPolyDspGenerator = class _FaustPolyDspGenerator {
|
|
4053
3727
|
constructor() {
|
|
4054
3728
|
this.voiceFactory = null;
|
|
4055
3729
|
this.effectFactory = null;
|
|
@@ -4062,43 +3736,43 @@ var _FaustPolyDspGenerator = class {
|
|
|
4062
3736
|
this.effectFactory = await compiler.createPolyDSPFactory(name, effectCodeAux, args);
|
|
4063
3737
|
if (this.effectFactory) {
|
|
4064
3738
|
const effectJSON = JSON.parse(this.effectFactory.json);
|
|
4065
|
-
const dspCode =
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
const effectCode =
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
3739
|
+
const dspCode = `// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
|
|
3740
|
+
// so that the effect can process the 2 channels of the voice
|
|
3741
|
+
adaptOut(1,1,1) = _;
|
|
3742
|
+
adaptOut(1,1,2) = _ <: _,0; // The left channel only is kept
|
|
3743
|
+
adaptOut(1,2,1) = _ <: _,_;
|
|
3744
|
+
adaptOut(1,2,2) = _ <: _,_;
|
|
3745
|
+
adaptOut(2,1,1) = _,_;
|
|
3746
|
+
adaptOut(2,1,2) = _,_;
|
|
3747
|
+
adaptOut(2,2,1) = _,_;
|
|
3748
|
+
adaptOut(2,2,2) = _,_;
|
|
3749
|
+
adaptor(F) = adaptOut(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
|
|
3750
|
+
dsp_code = environment{
|
|
3751
|
+
${dspCodeAux}
|
|
3752
|
+
};
|
|
3753
|
+
process = dsp_code.process : adaptor(dsp_code.process);
|
|
3754
|
+
`;
|
|
3755
|
+
const effectCode = `// Inputs
|
|
3756
|
+
adaptIn(1,1,1) = _;
|
|
3757
|
+
adaptIn(1,1,2) = _,_ :> _;
|
|
3758
|
+
adaptIn(1,2,1) = _,_;
|
|
3759
|
+
adaptIn(1,2,2) = _,_;
|
|
3760
|
+
adaptIn(2,1,1) = _,_ :> _;
|
|
3761
|
+
adaptIn(2,1,2) = _,_ :> _;
|
|
3762
|
+
adaptIn(2,2,1) = _,_;
|
|
3763
|
+
adaptIn(2,2,2) = _,_;
|
|
3764
|
+
// Outputs
|
|
3765
|
+
adaptOut(1,1) = _ <: _,0; // The left channel only is kept
|
|
3766
|
+
adaptOut(1,2) = _,_;
|
|
3767
|
+
adaptOut(2,1) = _ <: _,0; // The left channel only is kept
|
|
3768
|
+
adaptOut(2,2) = _,_;
|
|
3769
|
+
adaptorIns(F) = adaptIn(outputs(F),${effectJSON.inputs},${effectJSON.outputs});
|
|
3770
|
+
adaptorOuts = adaptOut(${effectJSON.inputs},${effectJSON.outputs});
|
|
3771
|
+
dsp_code = environment{
|
|
3772
|
+
${dspCodeAux}
|
|
3773
|
+
};
|
|
3774
|
+
process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
3775
|
+
`;
|
|
4102
3776
|
this.voiceFactory = await compiler.createPolyDSPFactory(name, dspCode, args);
|
|
4103
3777
|
try {
|
|
4104
3778
|
this.effectFactory = await compiler.createPolyDSPFactory(name, effectCode, args + " -inpl");
|
|
@@ -4129,10 +3803,13 @@ var _FaustPolyDspGenerator = class {
|
|
|
4129
3803
|
const voiceMeta = JSON.parse(voiceFactory.json);
|
|
4130
3804
|
const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
|
|
4131
3805
|
const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
|
|
3806
|
+
voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(voiceMeta, voiceFactory.soundfiles || {}, context);
|
|
3807
|
+
if (effectFactory)
|
|
3808
|
+
effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(effectMeta, effectFactory.soundfiles || {}, context);
|
|
4132
3809
|
if (sp) {
|
|
4133
3810
|
const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0);
|
|
4134
|
-
const
|
|
4135
|
-
|
|
3811
|
+
const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
|
|
3812
|
+
const polyDsp = new FaustPolyWebAudioDsp(instance, context.sampleRate, sampleSize, bufferSize, soundfiles);
|
|
4136
3813
|
const sp2 = context.createScriptProcessor(bufferSize, polyDsp.getNumInputs(), polyDsp.getNumOutputs());
|
|
4137
3814
|
Object.setPrototypeOf(sp2, FaustPolyScriptProcessorNode.prototype);
|
|
4138
3815
|
sp2.init(polyDsp);
|
|
@@ -4152,16 +3829,25 @@ const faustData = ${JSON.stringify({
|
|
|
4152
3829
|
effectMeta
|
|
4153
3830
|
})};
|
|
4154
3831
|
// Implementation needed classes of functions
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
3832
|
+
var ${FaustDspInstance.name} = ${FaustDspInstance.toString()}
|
|
3833
|
+
var FaustDspInstance = ${FaustDspInstance.name};
|
|
3834
|
+
var ${FaustBaseWebAudioDsp.name} = ${FaustBaseWebAudioDsp.toString()}
|
|
3835
|
+
var FaustBaseWebAudioDsp = ${FaustBaseWebAudioDsp.name};
|
|
3836
|
+
var ${FaustPolyWebAudioDsp.name} = ${FaustPolyWebAudioDsp.toString()}
|
|
3837
|
+
var FaustPolyWebAudioDsp = ${FaustPolyWebAudioDsp.name};
|
|
3838
|
+
var ${FaustWebAudioDspVoice.name} = ${FaustWebAudioDspVoice.toString()}
|
|
3839
|
+
var FaustWebAudioDspVoice = ${FaustWebAudioDspVoice.name};
|
|
3840
|
+
var ${FaustWasmInstantiator_default.name} = ${FaustWasmInstantiator_default.toString()}
|
|
3841
|
+
var FaustWasmInstantiator = ${FaustWasmInstantiator_default.name};
|
|
3842
|
+
var ${Soundfile.name} = ${Soundfile.toString()}
|
|
3843
|
+
var Soundfile = ${Soundfile.name};
|
|
3844
|
+
var ${WasmAllocator.name} = ${WasmAllocator.toString()}
|
|
3845
|
+
var WasmAllocator = ${WasmAllocator.name};
|
|
4160
3846
|
// Put them in dependencies
|
|
4161
3847
|
const dependencies = {
|
|
4162
|
-
FaustBaseWebAudioDsp
|
|
4163
|
-
FaustPolyWebAudioDsp
|
|
4164
|
-
FaustWasmInstantiator
|
|
3848
|
+
FaustBaseWebAudioDsp,
|
|
3849
|
+
FaustPolyWebAudioDsp,
|
|
3850
|
+
FaustWasmInstantiator
|
|
4165
3851
|
};
|
|
4166
3852
|
// Generate the actual AudioWorkletProcessor code
|
|
4167
3853
|
(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
@@ -4211,7 +3897,8 @@ const dependencies = {
|
|
|
4211
3897
|
const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
|
|
4212
3898
|
const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory || void 0);
|
|
4213
3899
|
const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
|
|
4214
|
-
const
|
|
3900
|
+
const soundfiles = { ...effectFactory == null ? void 0 : effectFactory.soundfiles, ...voiceFactory.soundfiles };
|
|
3901
|
+
const polyDsp = new FaustPolyWebAudioDsp(instance, sampleRate, sampleSize, bufferSize, soundfiles);
|
|
4215
3902
|
return new FaustPolyOfflineProcessor(polyDsp, bufferSize);
|
|
4216
3903
|
}
|
|
4217
3904
|
getMeta() {
|
|
@@ -4245,8 +3932,9 @@ const dependencies = {
|
|
|
4245
3932
|
return this.getMeta().ui;
|
|
4246
3933
|
}
|
|
4247
3934
|
};
|
|
3935
|
+
// Set of all created WorkletProcessors, each of them has to be unique
|
|
3936
|
+
_FaustPolyDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map();
|
|
4248
3937
|
var FaustPolyDspGenerator = _FaustPolyDspGenerator;
|
|
4249
|
-
FaustPolyDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map();
|
|
4250
3938
|
export {
|
|
4251
3939
|
FaustAudioWorkletNode,
|
|
4252
3940
|
FaustBaseWebAudioDsp,
|
|
@@ -4269,6 +3957,9 @@ export {
|
|
|
4269
3957
|
FaustWasmInstantiator_default as FaustWasmInstantiator,
|
|
4270
3958
|
FaustWebAudioDspVoice,
|
|
4271
3959
|
LibFaust_default as LibFaust,
|
|
3960
|
+
Soundfile,
|
|
3961
|
+
SoundfileReader_default as SoundfileReader,
|
|
3962
|
+
WasmAllocator,
|
|
4272
3963
|
WavDecoder_default as WavDecoder,
|
|
4273
3964
|
WavEncoder_default as WavEncoder,
|
|
4274
3965
|
ab2str,
|
|
@@ -4277,18 +3968,4 @@ export {
|
|
|
4277
3968
|
instantiateFaustModuleFromFile_default as instantiateFaustModuleFromFile,
|
|
4278
3969
|
str2ab
|
|
4279
3970
|
};
|
|
4280
|
-
/*! *****************************************************************************
|
|
4281
|
-
Copyright (c) Microsoft Corporation.
|
|
4282
|
-
|
|
4283
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
4284
|
-
purpose with or without fee is hereby granted.
|
|
4285
|
-
|
|
4286
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
4287
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
4288
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
4289
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
4290
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
4291
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
4292
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
4293
|
-
***************************************************************************** */
|
|
4294
3971
|
//# sourceMappingURL=index.js.map
|