@grame/faustwasm 0.12.2 → 0.13.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/.prettierrc +5 -0
- package/README.md +21 -3
- package/assets/standalone/faustwasm/index.d.ts +38 -16
- package/assets/standalone/faustwasm/index.js +1574 -404
- package/assets/standalone/faustwasm/index.js.map +2 -2
- package/dist/cjs/index.d.ts +38 -16
- package/dist/cjs/index.js +1573 -404
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs-bundle/index.d.ts +38 -16
- package/dist/cjs-bundle/index.js +1576 -406
- package/dist/cjs-bundle/index.js.map +2 -2
- package/dist/esm/index.d.ts +38 -16
- package/dist/esm/index.js +1574 -404
- package/dist/esm/index.js.map +2 -2
- package/dist/esm-bundle/index.d.ts +38 -16
- package/dist/esm-bundle/index.js +1576 -406
- package/dist/esm-bundle/index.js.map +2 -2
- package/eslint.config.js +11 -0
- package/package.json +57 -51
- package/sound.cpp +163 -0
- package/sound.dsp +4 -0
- package/sound.json +1 -0
- package/sound.wasm +0 -0
- package/src/FaustAudioWorkletCommunicator.ts +150 -143
- package/src/FaustAudioWorkletNode.ts +173 -75
- package/src/FaustAudioWorkletProcessor.ts +218 -90
- package/src/FaustCmajor.ts +9 -3
- package/src/FaustCompiler.ts +112 -35
- package/src/FaustDspGenerator.ts +561 -117
- package/src/FaustDspInstance.ts +58 -24
- package/src/FaustFFTAudioWorkletProcessor.ts +822 -612
- package/src/FaustOfflineProcessor.ts +187 -56
- package/src/FaustScriptProcessorNode.ts +156 -49
- package/src/FaustSensors.ts +426 -96
- package/src/FaustSvgDiagrams.ts +18 -5
- package/src/FaustWasmInstantiator.ts +224 -70
- package/src/FaustWebAudioDsp.ts +1060 -349
- package/src/LibFaust.ts +13 -4
- package/src/SoundfileReader.ts +175 -131
- package/src/WavDecoder.ts +42 -20
- package/src/WavEncoder.ts +35 -21
- package/src/copyWebStandaloneAssets.d.ts +20 -5
- package/src/copyWebStandaloneAssets.js +203 -75
- package/src/exports-bundle.ts +5 -5
- package/src/exports.ts +24 -24
- package/src/faust2CmajorFiles.d.ts +7 -3
- package/src/faust2cmajorFiles.js +10 -8
- package/src/faust2svgFiles.d.ts +7 -3
- package/src/faust2svgFiles.js +9 -7
- package/src/faust2wasmFiles.d.ts +10 -5
- package/src/faust2wasmFiles.js +34 -17
- package/src/faust2wavFiles.d.ts +12 -3
- package/src/faust2wavFiles.js +25 -12
- package/src/index-bundle-iife.ts +2 -2
- package/src/index-bundle.ts +1 -1
- package/src/index.ts +1 -1
- package/src/instantiateFaustModule.ts +43 -36
- package/src/instantiateFaustModuleFromFile.ts +30 -14
- package/src/types.ts +101 -25
- package/test/faustlive-wasm/faustwasm/index.d.ts +38 -16
- package/test/faustlive-wasm/faustwasm/index.js +1574 -404
- package/test/faustlive-wasm/faustwasm/index.js.map +2 -2
- package/test/web/create-faust-node.html +53 -0
- package/test/web/create-faust-node.js +186 -0
- package/test/organ/create-node.js +0 -252
- package/test/organ/dsp-meta.json +0 -131
- package/test/organ/dsp-module.wasm +0 -0
- package/test/organ/faust-pwa.js +0 -344
- package/test/organ/faust-ui/index.css +0 -442
- package/test/organ/faust-ui/index.css.map +0 -1
- package/test/organ/faust-ui/index.d.ts +0 -1
- package/test/organ/faust-ui/index.js +0 -3756
- package/test/organ/faust-ui/index.js.map +0 -1
- package/test/organ/faustwasm/index.d.ts +0 -1705
- package/test/organ/faustwasm/index.js +0 -4773
- package/test/organ/faustwasm/index.js.map +0 -7
- package/test/organ/icon.png +0 -0
- package/test/organ/index.html +0 -76
- package/test/organ/index.js +0 -69
- package/test/organ/manifest.json +0 -17
- package/test/organ/service-worker.js +0 -165
package/dist/esm-bundle/index.js
CHANGED
|
@@ -36,7 +36,7 @@ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot
|
|
|
36
36
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
37
37
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
38
38
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
39
|
-
var __toBinary = /* @__PURE__ */ (() => {
|
|
39
|
+
var __toBinary = Uint8Array.fromBase64 || /* @__PURE__ */ (() => {
|
|
40
40
|
var table = new Uint8Array(128);
|
|
41
41
|
for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;
|
|
42
42
|
return (base64) => {
|
|
@@ -5806,7 +5806,9 @@ var instantiateFaustModuleFromFile = async (jsFile, dataFile = jsFile.replace(/c
|
|
|
5806
5806
|
jsCode = `${jsCode}
|
|
5807
5807
|
export default ${(_a = jsCode.match(jsCodeHead)) == null ? void 0 : _a[1]};
|
|
5808
5808
|
`;
|
|
5809
|
-
const jsFileMod = URL.createObjectURL(
|
|
5809
|
+
const jsFileMod = URL.createObjectURL(
|
|
5810
|
+
new Blob([jsCode], { type: "text/javascript" })
|
|
5811
|
+
);
|
|
5810
5812
|
FaustModule = (await import(
|
|
5811
5813
|
/* webpackIgnore: true */
|
|
5812
5814
|
jsFileMod
|
|
@@ -5860,21 +5862,32 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
5860
5862
|
FaustWasmInstantiator: FaustWasmInstantiator2,
|
|
5861
5863
|
FaustAudioWorkletProcessorCommunicator: FaustAudioWorkletProcessorCommunicator2
|
|
5862
5864
|
} = dependencies;
|
|
5863
|
-
const {
|
|
5864
|
-
processorName,
|
|
5865
|
-
dspName,
|
|
5866
|
-
dspMeta,
|
|
5867
|
-
effectMeta,
|
|
5868
|
-
poly
|
|
5869
|
-
} = faustData;
|
|
5865
|
+
const { processorName, dspName, dspMeta, effectMeta, poly } = faustData;
|
|
5870
5866
|
const analysePolyParameters = (item) => {
|
|
5871
|
-
const polyKeywords = [
|
|
5867
|
+
const polyKeywords = [
|
|
5868
|
+
"/gate",
|
|
5869
|
+
"/freq",
|
|
5870
|
+
"/gain",
|
|
5871
|
+
"/key",
|
|
5872
|
+
"/vel",
|
|
5873
|
+
"/velocity"
|
|
5874
|
+
];
|
|
5872
5875
|
const isPolyReserved = "address" in item && !!polyKeywords.find((k) => item.address.endsWith(k));
|
|
5873
5876
|
if (poly && isPolyReserved) return null;
|
|
5874
5877
|
if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") {
|
|
5875
|
-
return {
|
|
5878
|
+
return {
|
|
5879
|
+
name: item.address,
|
|
5880
|
+
defaultValue: item.init || 0,
|
|
5881
|
+
minValue: item.min || 0,
|
|
5882
|
+
maxValue: item.max || 0
|
|
5883
|
+
};
|
|
5876
5884
|
} else if (item.type === "button" || item.type === "checkbox") {
|
|
5877
|
-
return {
|
|
5885
|
+
return {
|
|
5886
|
+
name: item.address,
|
|
5887
|
+
defaultValue: item.init || 0,
|
|
5888
|
+
minValue: 0,
|
|
5889
|
+
maxValue: 1
|
|
5890
|
+
};
|
|
5878
5891
|
}
|
|
5879
5892
|
return null;
|
|
5880
5893
|
};
|
|
@@ -5882,7 +5895,9 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
5882
5895
|
constructor(options) {
|
|
5883
5896
|
super(options);
|
|
5884
5897
|
this.paramValuesCache = {};
|
|
5885
|
-
this.fCommunicator = new FaustAudioWorkletProcessorCommunicator2(
|
|
5898
|
+
this.fCommunicator = new FaustAudioWorkletProcessorCommunicator2(
|
|
5899
|
+
this.port
|
|
5900
|
+
);
|
|
5886
5901
|
const { parameterDescriptors } = this.constructor;
|
|
5887
5902
|
parameterDescriptors.forEach((pd) => {
|
|
5888
5903
|
this.paramValuesCache[pd.name] = pd.defaultValue || 0;
|
|
@@ -5898,7 +5913,8 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
5898
5913
|
if (param) params.push(param);
|
|
5899
5914
|
};
|
|
5900
5915
|
FaustBaseWebAudioDsp2.parseUI(dspMeta.ui, callback);
|
|
5901
|
-
if (effectMeta)
|
|
5916
|
+
if (effectMeta)
|
|
5917
|
+
FaustBaseWebAudioDsp2.parseUI(effectMeta.ui, callback);
|
|
5902
5918
|
return params;
|
|
5903
5919
|
}
|
|
5904
5920
|
setupWamEventHandler() {
|
|
@@ -5906,12 +5922,15 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
5906
5922
|
if (!this.wamInfo) return;
|
|
5907
5923
|
const { moduleId, instanceId } = this.wamInfo;
|
|
5908
5924
|
const { webAudioModules } = globalThis;
|
|
5909
|
-
const ModuleScope = webAudioModules.getModuleScope(
|
|
5925
|
+
const ModuleScope = webAudioModules.getModuleScope(
|
|
5926
|
+
moduleId
|
|
5927
|
+
);
|
|
5910
5928
|
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
5911
5929
|
if (!paramMgrProcessor) return;
|
|
5912
5930
|
if (paramMgrProcessor.handleEvent) return;
|
|
5913
5931
|
paramMgrProcessor.handleEvent = (event) => {
|
|
5914
|
-
if (event.type === "wam-midi")
|
|
5932
|
+
if (event.type === "wam-midi")
|
|
5933
|
+
this.midiMessage(event.data.bytes);
|
|
5915
5934
|
};
|
|
5916
5935
|
}
|
|
5917
5936
|
process(inputs, outputs, parameters) {
|
|
@@ -5971,7 +5990,14 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
5971
5990
|
// Plot handler set on demand
|
|
5972
5991
|
case "setPlotHandler": {
|
|
5973
5992
|
if (msg.data) {
|
|
5974
|
-
this.fDSPCode.setPlotHandler(
|
|
5993
|
+
this.fDSPCode.setPlotHandler(
|
|
5994
|
+
(output, index, events) => this.port.postMessage({
|
|
5995
|
+
type: "plot",
|
|
5996
|
+
value: output,
|
|
5997
|
+
index,
|
|
5998
|
+
events
|
|
5999
|
+
})
|
|
6000
|
+
);
|
|
5975
6001
|
} else {
|
|
5976
6002
|
this.fDSPCode.setPlotHandler(null);
|
|
5977
6003
|
}
|
|
@@ -6033,10 +6059,18 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6033
6059
|
const { FaustMonoWebAudioDsp: FaustMonoWebAudioDsp2 } = dependencies;
|
|
6034
6060
|
const { factory, sampleSize } = options.processorOptions;
|
|
6035
6061
|
const instance = FaustWasmInstantiator2.createSyncMonoDSPInstance(factory);
|
|
6036
|
-
this.fDSPCode = new FaustMonoWebAudioDsp2(
|
|
6062
|
+
this.fDSPCode = new FaustMonoWebAudioDsp2(
|
|
6063
|
+
instance,
|
|
6064
|
+
sampleRate,
|
|
6065
|
+
sampleSize,
|
|
6066
|
+
128,
|
|
6067
|
+
factory.soundfiles
|
|
6068
|
+
);
|
|
6037
6069
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6038
6070
|
this.port.start();
|
|
6039
|
-
this.fDSPCode.setOutputParamHandler(
|
|
6071
|
+
this.fDSPCode.setOutputParamHandler(
|
|
6072
|
+
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6073
|
+
);
|
|
6040
6074
|
this.fDSPCode.start();
|
|
6041
6075
|
}
|
|
6042
6076
|
}
|
|
@@ -6058,13 +6092,35 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6058
6092
|
}
|
|
6059
6093
|
};
|
|
6060
6094
|
const { FaustPolyWebAudioDsp: FaustPolyWebAudioDsp3 } = dependencies;
|
|
6061
|
-
const {
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6095
|
+
const {
|
|
6096
|
+
voiceFactory,
|
|
6097
|
+
mixerModule,
|
|
6098
|
+
voices,
|
|
6099
|
+
effectFactory,
|
|
6100
|
+
sampleSize
|
|
6101
|
+
} = options.processorOptions;
|
|
6102
|
+
const instance = FaustWasmInstantiator2.createSyncPolyDSPInstance(
|
|
6103
|
+
voiceFactory,
|
|
6104
|
+
mixerModule,
|
|
6105
|
+
voices,
|
|
6106
|
+
effectFactory
|
|
6107
|
+
);
|
|
6108
|
+
const soundfiles = {
|
|
6109
|
+
...effectFactory == null ? void 0 : effectFactory.soundfiles,
|
|
6110
|
+
...voiceFactory.soundfiles
|
|
6111
|
+
};
|
|
6112
|
+
this.fDSPCode = new FaustPolyWebAudioDsp3(
|
|
6113
|
+
instance,
|
|
6114
|
+
sampleRate,
|
|
6115
|
+
sampleSize,
|
|
6116
|
+
128,
|
|
6117
|
+
soundfiles
|
|
6118
|
+
);
|
|
6065
6119
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6066
6120
|
this.port.start();
|
|
6067
|
-
this.fDSPCode.setOutputParamHandler(
|
|
6121
|
+
this.fDSPCode.setOutputParamHandler(
|
|
6122
|
+
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6123
|
+
);
|
|
6068
6124
|
this.fDSPCode.start();
|
|
6069
6125
|
}
|
|
6070
6126
|
midiMessage(data) {
|
|
@@ -6072,7 +6128,8 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6072
6128
|
const channel = data[0] & 15;
|
|
6073
6129
|
const data1 = data[1];
|
|
6074
6130
|
const data2 = data[2];
|
|
6075
|
-
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
6131
|
+
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
6132
|
+
this.keyOff(channel, data1, data2);
|
|
6076
6133
|
else if (cmd === 9) this.keyOn(channel, data1, data2);
|
|
6077
6134
|
else super.midiMessage(data);
|
|
6078
6135
|
}
|
|
@@ -6090,7 +6147,10 @@ var getFaustAudioWorkletProcessor = (dependencies, faustData, register = true) =
|
|
|
6090
6147
|
const Processor = poly ? FaustPolyAudioWorkletProcessor : FaustMonoAudioWorkletProcessor;
|
|
6091
6148
|
if (register) {
|
|
6092
6149
|
try {
|
|
6093
|
-
registerProcessor(
|
|
6150
|
+
registerProcessor(
|
|
6151
|
+
processorName || dspName || (poly ? "mydsp_poly" : "mydsp"),
|
|
6152
|
+
Processor
|
|
6153
|
+
);
|
|
6094
6154
|
} catch (error) {
|
|
6095
6155
|
console.warn(error);
|
|
6096
6156
|
}
|
|
@@ -6109,19 +6169,8 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6109
6169
|
FaustAudioWorkletProcessorCommunicator: FaustAudioWorkletProcessorCommunicator2,
|
|
6110
6170
|
FFTUtils
|
|
6111
6171
|
} = dependencies;
|
|
6112
|
-
const {
|
|
6113
|
-
|
|
6114
|
-
dspName,
|
|
6115
|
-
dspMeta,
|
|
6116
|
-
fftOptions
|
|
6117
|
-
} = faustData;
|
|
6118
|
-
const {
|
|
6119
|
-
windowFunctions,
|
|
6120
|
-
getFFT,
|
|
6121
|
-
fftToSignal,
|
|
6122
|
-
signalToFFT,
|
|
6123
|
-
signalToNoFFT
|
|
6124
|
-
} = FFTUtils;
|
|
6172
|
+
const { processorName, dspName, dspMeta, fftOptions } = faustData;
|
|
6173
|
+
const { windowFunctions, getFFT, fftToSignal, signalToFFT, signalToNoFFT } = FFTUtils;
|
|
6125
6174
|
const ceil = (x, to) => Math.abs(to) < 1 ? Math.ceil(x * (1 / to)) / (1 / to) : Math.ceil(x / to) * to;
|
|
6126
6175
|
const mod = (x, y) => (x % y + y) % y;
|
|
6127
6176
|
const apply = (array, windowFunction) => {
|
|
@@ -6129,7 +6178,13 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6129
6178
|
array[i] *= windowFunction(i, array.length);
|
|
6130
6179
|
}
|
|
6131
6180
|
};
|
|
6132
|
-
const fftParamKeywords = [
|
|
6181
|
+
const fftParamKeywords = [
|
|
6182
|
+
"/fftSize",
|
|
6183
|
+
"/fftHopSize",
|
|
6184
|
+
"/fftOverlap",
|
|
6185
|
+
"/windowFunction",
|
|
6186
|
+
"/noIFFT"
|
|
6187
|
+
];
|
|
6133
6188
|
const setTypedArray = (to, from, offsetTo = 0, offsetFrom = 0) => {
|
|
6134
6189
|
const toLength = to.length;
|
|
6135
6190
|
const fromLength = from.length;
|
|
@@ -6138,7 +6193,11 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6138
6193
|
let $to = mod(offsetTo, toLength) || 0;
|
|
6139
6194
|
let $from = mod(offsetFrom, fromLength) || 0;
|
|
6140
6195
|
while (spilled < spillLength) {
|
|
6141
|
-
const $spillLength = Math.min(
|
|
6196
|
+
const $spillLength = Math.min(
|
|
6197
|
+
spillLength - spilled,
|
|
6198
|
+
toLength - $to,
|
|
6199
|
+
fromLength - $from
|
|
6200
|
+
);
|
|
6142
6201
|
const $fromEnd = $from + $spillLength;
|
|
6143
6202
|
if ($from === 0 && $fromEnd === fromLength) to.set(from, $to);
|
|
6144
6203
|
else to.set(from.subarray($from, $fromEnd), $to);
|
|
@@ -6152,9 +6211,19 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6152
6211
|
const isFFTReserved = "address" in item && !!fftParamKeywords.find((k) => item.address.endsWith(k));
|
|
6153
6212
|
if (isFFTReserved) return null;
|
|
6154
6213
|
if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") {
|
|
6155
|
-
return {
|
|
6214
|
+
return {
|
|
6215
|
+
name: item.address,
|
|
6216
|
+
defaultValue: item.init || 0,
|
|
6217
|
+
minValue: item.min || 0,
|
|
6218
|
+
maxValue: item.max || 0
|
|
6219
|
+
};
|
|
6156
6220
|
} else if (item.type === "button" || item.type === "checkbox") {
|
|
6157
|
-
return {
|
|
6221
|
+
return {
|
|
6222
|
+
name: item.address,
|
|
6223
|
+
defaultValue: item.init || 0,
|
|
6224
|
+
minValue: 0,
|
|
6225
|
+
maxValue: 1
|
|
6226
|
+
};
|
|
6158
6227
|
}
|
|
6159
6228
|
return null;
|
|
6160
6229
|
};
|
|
@@ -6241,7 +6310,9 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6241
6310
|
};
|
|
6242
6311
|
this.port.addEventListener("message", this.handleMessageAux);
|
|
6243
6312
|
this.port.start();
|
|
6244
|
-
this.communicator = new FaustAudioWorkletProcessorCommunicator2(
|
|
6313
|
+
this.communicator = new FaustAudioWorkletProcessorCommunicator2(
|
|
6314
|
+
this.port
|
|
6315
|
+
);
|
|
6245
6316
|
const { parameterDescriptors } = this.constructor;
|
|
6246
6317
|
parameterDescriptors.forEach((pd) => {
|
|
6247
6318
|
this.paramValuesCache[pd.name] = pd.defaultValue || 0;
|
|
@@ -6303,35 +6374,55 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6303
6374
|
if (!this.wamInfo) return;
|
|
6304
6375
|
const { moduleId, instanceId } = this.wamInfo;
|
|
6305
6376
|
const { webAudioModules } = globalThis;
|
|
6306
|
-
const ModuleScope = webAudioModules.getModuleScope(
|
|
6377
|
+
const ModuleScope = webAudioModules.getModuleScope(
|
|
6378
|
+
moduleId
|
|
6379
|
+
);
|
|
6307
6380
|
const paramMgrProcessor = (_a = ModuleScope == null ? void 0 : ModuleScope.paramMgrProcessors) == null ? void 0 : _a[instanceId];
|
|
6308
6381
|
if (!paramMgrProcessor) return;
|
|
6309
6382
|
if (paramMgrProcessor.handleEvent) return;
|
|
6310
6383
|
paramMgrProcessor.handleEvent = (event) => {
|
|
6311
|
-
if (event.type === "wam-midi")
|
|
6384
|
+
if (event.type === "wam-midi")
|
|
6385
|
+
this.midiMessage(event.data.bytes);
|
|
6312
6386
|
};
|
|
6313
6387
|
}
|
|
6314
6388
|
processFFT() {
|
|
6315
6389
|
let samplesForFFT = mod(this.$inputWrite - this.$inputRead, this.fftBufferSize) || this.fftBufferSize;
|
|
6316
6390
|
while (samplesForFFT >= this.fftSize) {
|
|
6317
6391
|
let fftProcessorOutputs = [];
|
|
6318
|
-
this.fDSPCode.compute(
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6392
|
+
this.fDSPCode.compute(
|
|
6393
|
+
(inputs) => {
|
|
6394
|
+
for (let i = 0; i < Math.min(
|
|
6395
|
+
this.fftInput.length,
|
|
6396
|
+
Math.ceil(inputs.length / 3)
|
|
6397
|
+
); i++) {
|
|
6398
|
+
const ffted = this.rfft.forward((fftBuffer) => {
|
|
6399
|
+
setTypedArray(
|
|
6400
|
+
fftBuffer,
|
|
6401
|
+
this.fftInput[i],
|
|
6402
|
+
0,
|
|
6403
|
+
this.$inputRead
|
|
6404
|
+
);
|
|
6405
|
+
for (let j = 0; j < fftBuffer.length; j++) {
|
|
6406
|
+
fftBuffer[j] *= this.window[j];
|
|
6407
|
+
}
|
|
6408
|
+
});
|
|
6409
|
+
fftToSignal(
|
|
6410
|
+
ffted,
|
|
6411
|
+
inputs[i * 3],
|
|
6412
|
+
inputs[i * 3 + 1],
|
|
6413
|
+
inputs[i * 3 + 2]
|
|
6414
|
+
);
|
|
6415
|
+
}
|
|
6416
|
+
for (let i = this.fftInput.length * 3; i < inputs.length; i++) {
|
|
6417
|
+
if (i % 3 === 2)
|
|
6418
|
+
inputs[i].forEach((v, j) => inputs[i][j] = j);
|
|
6419
|
+
else inputs[i].fill(0);
|
|
6420
|
+
}
|
|
6421
|
+
},
|
|
6422
|
+
(outputs) => {
|
|
6423
|
+
fftProcessorOutputs = outputs;
|
|
6424
|
+
}
|
|
6425
|
+
);
|
|
6335
6426
|
this.$inputRead += this.fftHopSize;
|
|
6336
6427
|
this.$inputRead %= this.fftBufferSize;
|
|
6337
6428
|
samplesForFFT -= this.fftHopSize;
|
|
@@ -6339,10 +6430,18 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6339
6430
|
let iffted;
|
|
6340
6431
|
if (this.noIFFT) {
|
|
6341
6432
|
iffted = this.noIFFTBuffer;
|
|
6342
|
-
signalToNoFFT(
|
|
6433
|
+
signalToNoFFT(
|
|
6434
|
+
fftProcessorOutputs[i * 2] || this.fftProcessorZeros,
|
|
6435
|
+
fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros,
|
|
6436
|
+
iffted
|
|
6437
|
+
);
|
|
6343
6438
|
} else {
|
|
6344
6439
|
iffted = this.rfft.inverse((ifftBuffer) => {
|
|
6345
|
-
signalToFFT(
|
|
6440
|
+
signalToFFT(
|
|
6441
|
+
fftProcessorOutputs[i * 2] || this.fftProcessorZeros,
|
|
6442
|
+
fftProcessorOutputs[i * 2 + 1] || this.fftProcessorZeros,
|
|
6443
|
+
ifftBuffer
|
|
6444
|
+
);
|
|
6346
6445
|
});
|
|
6347
6446
|
}
|
|
6348
6447
|
for (let j = 0; j < iffted.length; j++) {
|
|
@@ -6352,12 +6451,14 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6352
6451
|
for (let j = 0; j < iffted.length - this.fftHopSize; j++) {
|
|
6353
6452
|
$ = mod(this.$outputWrite + j, this.fftBufferSize);
|
|
6354
6453
|
this.fftOutput[i][$] += iffted[j];
|
|
6355
|
-
if (i === 0)
|
|
6454
|
+
if (i === 0)
|
|
6455
|
+
this.windowSumSquare[$] += this.noIFFT ? this.window[j] : this.window[j] ** 2;
|
|
6356
6456
|
}
|
|
6357
6457
|
for (let j = iffted.length - this.fftHopSize; j < iffted.length; j++) {
|
|
6358
6458
|
$ = mod(this.$outputWrite + j, this.fftBufferSize);
|
|
6359
6459
|
this.fftOutput[i][$] = iffted[j];
|
|
6360
|
-
if (i === 0)
|
|
6460
|
+
if (i === 0)
|
|
6461
|
+
this.windowSumSquare[$] = this.noIFFT ? this.window[j] : this.window[j] ** 2;
|
|
6361
6462
|
}
|
|
6362
6463
|
}
|
|
6363
6464
|
this.$outputWrite += this.fftHopSize;
|
|
@@ -6373,10 +6474,18 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6373
6474
|
const outputChannels = (output == null ? void 0 : output.length) || 0;
|
|
6374
6475
|
const bufferSize = (input == null ? void 0 : input.length) ? Math.max(...input.map((c) => c.length)) || 128 : 128;
|
|
6375
6476
|
this.noIFFT = !!parameters.noIFFT[0];
|
|
6376
|
-
this.resetFFT(
|
|
6477
|
+
this.resetFFT(
|
|
6478
|
+
~~parameters.fftSize[0],
|
|
6479
|
+
~~parameters.fftOverlap[0],
|
|
6480
|
+
~~parameters.windowFunction[0],
|
|
6481
|
+
inputChannels,
|
|
6482
|
+
outputChannels,
|
|
6483
|
+
bufferSize
|
|
6484
|
+
);
|
|
6377
6485
|
if (!this.fDSPCode) return true;
|
|
6378
6486
|
for (const path in parameters) {
|
|
6379
|
-
if (
|
|
6487
|
+
if (fftParamKeywords.find((k) => `/${path}`.endsWith(k)))
|
|
6488
|
+
continue;
|
|
6380
6489
|
const [paramValue] = parameters[path];
|
|
6381
6490
|
if (paramValue !== this.paramValuesCache[path]) {
|
|
6382
6491
|
this.setParamValue(path, paramValue);
|
|
@@ -6402,7 +6511,11 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6402
6511
|
for (let i = 0; i < input.length; i++) {
|
|
6403
6512
|
const inputWindow = this.fftInput[i];
|
|
6404
6513
|
const channel = input[i].length ? input[i] : new Float32Array(bufferSize);
|
|
6405
|
-
$inputWrite = setTypedArray(
|
|
6514
|
+
$inputWrite = setTypedArray(
|
|
6515
|
+
inputWindow,
|
|
6516
|
+
channel,
|
|
6517
|
+
this.$inputWrite
|
|
6518
|
+
);
|
|
6406
6519
|
}
|
|
6407
6520
|
this.$inputWrite = $inputWrite;
|
|
6408
6521
|
} else {
|
|
@@ -6411,7 +6524,12 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6411
6524
|
}
|
|
6412
6525
|
this.processFFT();
|
|
6413
6526
|
for (let i = 0; i < output.length; i++) {
|
|
6414
|
-
setTypedArray(
|
|
6527
|
+
setTypedArray(
|
|
6528
|
+
output[i],
|
|
6529
|
+
this.fftOutput[i],
|
|
6530
|
+
0,
|
|
6531
|
+
this.$outputRead
|
|
6532
|
+
);
|
|
6415
6533
|
let div = 0;
|
|
6416
6534
|
for (let j = 0; j < bufferSize; j++) {
|
|
6417
6535
|
div = this.windowSumSquare[mod(this.$outputRead + j, this.fftBufferSize)];
|
|
@@ -6421,7 +6539,12 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6421
6539
|
this.$outputRead += bufferSize;
|
|
6422
6540
|
this.$outputRead %= this.fftBufferSize;
|
|
6423
6541
|
if (this.fPlotHandler) {
|
|
6424
|
-
this.port.postMessage({
|
|
6542
|
+
this.port.postMessage({
|
|
6543
|
+
type: "plot",
|
|
6544
|
+
value: output,
|
|
6545
|
+
index: this.fBufferNum++,
|
|
6546
|
+
events: this.fCachedEvents
|
|
6547
|
+
});
|
|
6425
6548
|
this.fCachedEvents = [];
|
|
6426
6549
|
}
|
|
6427
6550
|
return true;
|
|
@@ -6469,8 +6592,15 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6469
6592
|
this.$inputRead = 0;
|
|
6470
6593
|
this.$outputWrite = 0;
|
|
6471
6594
|
this.$outputRead = -latency;
|
|
6472
|
-
this.fftBufferSize = Math.max(
|
|
6473
|
-
|
|
6595
|
+
this.fftBufferSize = Math.max(
|
|
6596
|
+
fftSize * 2 - this.fftHopSize,
|
|
6597
|
+
bufferSize * 2
|
|
6598
|
+
);
|
|
6599
|
+
if (!fftSizeChanged && this.fftHopSizeParam)
|
|
6600
|
+
(_a = this.fDSPCode) == null ? void 0 : _a.setParamValue(
|
|
6601
|
+
this.fftHopSizeParam,
|
|
6602
|
+
this.fftHopSize
|
|
6603
|
+
);
|
|
6474
6604
|
}
|
|
6475
6605
|
if (fftSizeChanged) {
|
|
6476
6606
|
(_b = this.rfft) == null ? void 0 : _b.dispose();
|
|
@@ -6506,7 +6636,9 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6506
6636
|
}
|
|
6507
6637
|
if (this.fftOutput.length < outputChannels) {
|
|
6508
6638
|
for (let i = this.fftOutput.length; i < outputChannels; i++) {
|
|
6509
|
-
this.fftOutput[i] = new Float32Array(
|
|
6639
|
+
this.fftOutput[i] = new Float32Array(
|
|
6640
|
+
this.fftBufferSize
|
|
6641
|
+
);
|
|
6510
6642
|
}
|
|
6511
6643
|
}
|
|
6512
6644
|
}
|
|
@@ -6515,20 +6647,38 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6515
6647
|
var _a, _b;
|
|
6516
6648
|
(_a = this.fDSPCode) == null ? void 0 : _a.stop();
|
|
6517
6649
|
(_b = this.fDSPCode) == null ? void 0 : _b.destroy();
|
|
6518
|
-
this.fDSPCode = new FaustMonoWebAudioDsp2(
|
|
6519
|
-
|
|
6650
|
+
this.fDSPCode = new FaustMonoWebAudioDsp2(
|
|
6651
|
+
this.dspInstance,
|
|
6652
|
+
sampleRate,
|
|
6653
|
+
this.sampleSize,
|
|
6654
|
+
this.fftProcessorBufferSize,
|
|
6655
|
+
this.soundfiles
|
|
6656
|
+
);
|
|
6657
|
+
this.fDSPCode.setOutputParamHandler(
|
|
6658
|
+
(path, value) => this.port.postMessage({ path, value, type: "param" })
|
|
6659
|
+
);
|
|
6520
6660
|
this.fDSPCode.setPlotHandler(this.fPlotHandler);
|
|
6521
6661
|
const params = this.fDSPCode.getParams();
|
|
6522
6662
|
this.fDSPCode.start();
|
|
6523
6663
|
for (const path in this.paramValuesCache) {
|
|
6524
|
-
if (
|
|
6664
|
+
if (fftParamKeywords.find((k) => `/${path}`.endsWith(k)))
|
|
6665
|
+
continue;
|
|
6525
6666
|
this.fDSPCode.setParamValue(path, this.paramValuesCache[path]);
|
|
6526
6667
|
}
|
|
6527
6668
|
const fftSizeParam = params.find((s) => s.endsWith("/fftSize"));
|
|
6528
|
-
if (fftSizeParam)
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6669
|
+
if (fftSizeParam)
|
|
6670
|
+
this.fDSPCode.setParamValue(fftSizeParam, this.fftSize);
|
|
6671
|
+
this.fftHopSizeParam = params.find(
|
|
6672
|
+
(s) => s.endsWith("/fftHopSize")
|
|
6673
|
+
);
|
|
6674
|
+
if (this.fftHopSizeParam)
|
|
6675
|
+
this.fDSPCode.setParamValue(
|
|
6676
|
+
this.fftHopSizeParam,
|
|
6677
|
+
this.fftHopSize
|
|
6678
|
+
);
|
|
6679
|
+
this.fftProcessorZeros = new Float32Array(
|
|
6680
|
+
this.fftProcessorBufferSize
|
|
6681
|
+
);
|
|
6532
6682
|
}
|
|
6533
6683
|
destroy() {
|
|
6534
6684
|
var _a, _b, _c;
|
|
@@ -6541,7 +6691,10 @@ var getFaustFFTAudioWorkletProcessor = (dependencies, faustData, register = true
|
|
|
6541
6691
|
const Processor = FaustFFTAudioWorkletProcessor;
|
|
6542
6692
|
if (register) {
|
|
6543
6693
|
try {
|
|
6544
|
-
registerProcessor(
|
|
6694
|
+
registerProcessor(
|
|
6695
|
+
processorName || dspName || "myfftdsp",
|
|
6696
|
+
Processor
|
|
6697
|
+
);
|
|
6545
6698
|
} catch (error) {
|
|
6546
6699
|
console.warn(error);
|
|
6547
6700
|
}
|
|
@@ -6950,7 +7103,11 @@ var _FaustCompiler = class _FaustCompiler {
|
|
|
6950
7103
|
const table = {};
|
|
6951
7104
|
this.gFactories.forEach((factory, shaKey) => {
|
|
6952
7105
|
const { code, json, poly } = factory;
|
|
6953
|
-
table[shaKey] = {
|
|
7106
|
+
table[shaKey] = {
|
|
7107
|
+
code: btoa(ab2str(code)),
|
|
7108
|
+
json: JSON.parse(json),
|
|
7109
|
+
poly
|
|
7110
|
+
};
|
|
6954
7111
|
});
|
|
6955
7112
|
return table;
|
|
6956
7113
|
}
|
|
@@ -6969,7 +7126,19 @@ var _FaustCompiler = class _FaustCompiler {
|
|
|
6969
7126
|
const factory = table[shaKey];
|
|
6970
7127
|
const { code, json, poly } = factory;
|
|
6971
7128
|
const ab = str2ab(atob(code));
|
|
6972
|
-
awaited.push(
|
|
7129
|
+
awaited.push(
|
|
7130
|
+
WebAssembly.compile(ab).then(
|
|
7131
|
+
(module) => this.gFactories.set(shaKey, {
|
|
7132
|
+
shaKey,
|
|
7133
|
+
cfactory: 0,
|
|
7134
|
+
code: ab,
|
|
7135
|
+
module,
|
|
7136
|
+
json: JSON.stringify(json),
|
|
7137
|
+
poly,
|
|
7138
|
+
soundfiles: {}
|
|
7139
|
+
})
|
|
7140
|
+
)
|
|
7141
|
+
);
|
|
6973
7142
|
}
|
|
6974
7143
|
return Promise.all(awaited);
|
|
6975
7144
|
}
|
|
@@ -6996,16 +7165,31 @@ var _FaustCompiler = class _FaustCompiler {
|
|
|
6996
7165
|
if (_FaustCompiler.gFactories.size > 10) {
|
|
6997
7166
|
_FaustCompiler.gFactories.clear();
|
|
6998
7167
|
}
|
|
6999
|
-
|
|
7168
|
+
const shaKey = await sha256(
|
|
7169
|
+
name + code + args + (poly ? "poly" : "mono")
|
|
7170
|
+
);
|
|
7000
7171
|
if (_FaustCompiler.gFactories.has(shaKey)) {
|
|
7001
7172
|
return _FaustCompiler.gFactories.get(shaKey) || null;
|
|
7002
7173
|
} else {
|
|
7003
7174
|
try {
|
|
7004
|
-
const faustDspWasm = this.fLibFaust.createDSPFactory(
|
|
7175
|
+
const faustDspWasm = this.fLibFaust.createDSPFactory(
|
|
7176
|
+
name,
|
|
7177
|
+
code,
|
|
7178
|
+
args,
|
|
7179
|
+
!poly
|
|
7180
|
+
);
|
|
7005
7181
|
const ui8Code = this.intVec2intArray(faustDspWasm.data);
|
|
7006
7182
|
faustDspWasm.data.delete();
|
|
7007
7183
|
const module = await WebAssembly.compile(ui8Code);
|
|
7008
|
-
const factory = {
|
|
7184
|
+
const factory = {
|
|
7185
|
+
shaKey,
|
|
7186
|
+
cfactory: faustDspWasm.cfactory,
|
|
7187
|
+
code: ui8Code,
|
|
7188
|
+
module,
|
|
7189
|
+
json: faustDspWasm.json,
|
|
7190
|
+
poly,
|
|
7191
|
+
soundfiles: {}
|
|
7192
|
+
};
|
|
7009
7193
|
this.deleteDSPFactory(factory);
|
|
7010
7194
|
_FaustCompiler.gFactories.set(shaKey, factory);
|
|
7011
7195
|
return factory;
|
|
@@ -7059,18 +7243,28 @@ var _FaustCompiler = class _FaustCompiler {
|
|
|
7059
7243
|
async getAsyncInternalMixerModule(isDouble = false) {
|
|
7060
7244
|
const bufferKey = isDouble ? "mixer64Buffer" : "mixer32Buffer";
|
|
7061
7245
|
const moduleKey = isDouble ? "mixer64Module" : "mixer32Module";
|
|
7062
|
-
if (this[moduleKey])
|
|
7246
|
+
if (this[moduleKey])
|
|
7247
|
+
return {
|
|
7248
|
+
mixerBuffer: this[bufferKey],
|
|
7249
|
+
mixerModule: this[moduleKey]
|
|
7250
|
+
};
|
|
7063
7251
|
const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm";
|
|
7064
7252
|
const mixerBuffer = this.fs().readFile(path, { encoding: "binary" });
|
|
7065
7253
|
this[bufferKey] = mixerBuffer;
|
|
7066
|
-
const mixerModule = await WebAssembly.compile(
|
|
7254
|
+
const mixerModule = await WebAssembly.compile(
|
|
7255
|
+
new Uint8Array(mixerBuffer)
|
|
7256
|
+
);
|
|
7067
7257
|
this[moduleKey] = mixerModule;
|
|
7068
7258
|
return { mixerBuffer, mixerModule };
|
|
7069
7259
|
}
|
|
7070
7260
|
getSyncInternalMixerModule(isDouble = false) {
|
|
7071
7261
|
const bufferKey = isDouble ? "mixer64Buffer" : "mixer32Buffer";
|
|
7072
7262
|
const moduleKey = isDouble ? "mixer64Module" : "mixer32Module";
|
|
7073
|
-
if (this[moduleKey])
|
|
7263
|
+
if (this[moduleKey])
|
|
7264
|
+
return {
|
|
7265
|
+
mixerBuffer: this[bufferKey],
|
|
7266
|
+
mixerModule: this[moduleKey]
|
|
7267
|
+
};
|
|
7074
7268
|
const path = isDouble ? "/usr/rsrc/mixer64.wasm" : "/usr/rsrc/mixer32.wasm";
|
|
7075
7269
|
const mixerBuffer = this.fs().readFile(path, { encoding: "binary" });
|
|
7076
7270
|
this[bufferKey] = mixerBuffer;
|
|
@@ -7207,7 +7401,8 @@ var FaustWasmInstantiator = class {
|
|
|
7207
7401
|
};
|
|
7208
7402
|
const effectSize = effectMeta ? effectMeta.size : 0;
|
|
7209
7403
|
let memorySize = pow2limit(
|
|
7210
|
-
effectSize + dspMeta.size * voices + (dspMeta.inputs + dspMeta.outputs * 2) *
|
|
7404
|
+
effectSize + dspMeta.size * voices + (dspMeta.inputs + dspMeta.outputs * 2) * // + 2 for effect
|
|
7405
|
+
(ptrSize + bufferSize * sampleSize)
|
|
7211
7406
|
) / 65536;
|
|
7212
7407
|
memorySize = Math.max(2, memorySize);
|
|
7213
7408
|
return new WebAssembly.Memory({ initial: memorySize });
|
|
@@ -7232,14 +7427,23 @@ var FaustWasmInstantiator = class {
|
|
|
7232
7427
|
const voiceMeta = JSON.parse(voiceFactory.json);
|
|
7233
7428
|
const effectMeta = effectFactory && effectFactory.json ? JSON.parse(effectFactory.json) : null;
|
|
7234
7429
|
const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
|
|
7235
|
-
return this.createWasmMemoryPoly(
|
|
7430
|
+
return this.createWasmMemoryPoly(
|
|
7431
|
+
voices,
|
|
7432
|
+
sampleSize,
|
|
7433
|
+
voiceMeta,
|
|
7434
|
+
effectMeta,
|
|
7435
|
+
8192
|
|
7436
|
+
);
|
|
7236
7437
|
}
|
|
7237
7438
|
static createMixerAux(mixerModule, memory) {
|
|
7238
7439
|
const mixerImport = {
|
|
7239
7440
|
imports: { print: console.log },
|
|
7240
7441
|
memory: { memory }
|
|
7241
7442
|
};
|
|
7242
|
-
const mixerInstance = new WebAssembly.Instance(
|
|
7443
|
+
const mixerInstance = new WebAssembly.Instance(
|
|
7444
|
+
mixerModule,
|
|
7445
|
+
mixerImport
|
|
7446
|
+
);
|
|
7243
7447
|
const mixerFunctions = mixerInstance.exports;
|
|
7244
7448
|
return mixerFunctions;
|
|
7245
7449
|
}
|
|
@@ -7247,7 +7451,9 @@ var FaustWasmInstantiator = class {
|
|
|
7247
7451
|
static async loadDSPFactory(wasmPath, jsonPath) {
|
|
7248
7452
|
const wasmFile = await fetch(wasmPath);
|
|
7249
7453
|
if (!wasmFile.ok) {
|
|
7250
|
-
throw new Error(
|
|
7454
|
+
throw new Error(
|
|
7455
|
+
`=> exception raised while running loadDSPFactory, file not found: ${wasmPath}`
|
|
7456
|
+
);
|
|
7251
7457
|
}
|
|
7252
7458
|
try {
|
|
7253
7459
|
const wasmBuffer = await wasmFile.arrayBuffer();
|
|
@@ -7257,7 +7463,13 @@ var FaustWasmInstantiator = class {
|
|
|
7257
7463
|
const meta = JSON.parse(json);
|
|
7258
7464
|
const cOptions = meta.compile_options;
|
|
7259
7465
|
const poly = cOptions.indexOf("wasm-e") !== -1;
|
|
7260
|
-
return {
|
|
7466
|
+
return {
|
|
7467
|
+
cfactory: 0,
|
|
7468
|
+
code: new Uint8Array(wasmBuffer),
|
|
7469
|
+
module,
|
|
7470
|
+
json,
|
|
7471
|
+
poly
|
|
7472
|
+
};
|
|
7261
7473
|
} catch (e) {
|
|
7262
7474
|
throw e;
|
|
7263
7475
|
}
|
|
@@ -7266,7 +7478,9 @@ var FaustWasmInstantiator = class {
|
|
|
7266
7478
|
try {
|
|
7267
7479
|
let mixerBuffer = null;
|
|
7268
7480
|
if (fs) {
|
|
7269
|
-
mixerBuffer = new Uint8Array(
|
|
7481
|
+
mixerBuffer = new Uint8Array(
|
|
7482
|
+
fs.readFile(mixerPath, { encoding: "binary" })
|
|
7483
|
+
);
|
|
7270
7484
|
} else {
|
|
7271
7485
|
const mixerFile = await fetch(mixerPath);
|
|
7272
7486
|
mixerBuffer = await mixerFile.arrayBuffer();
|
|
@@ -7281,10 +7495,20 @@ var FaustWasmInstantiator = class {
|
|
|
7281
7495
|
const isDetected = pattern.test(factory.json);
|
|
7282
7496
|
if (isDetected) {
|
|
7283
7497
|
const memory = this.createMemoryMono(factory);
|
|
7284
|
-
const instance = await WebAssembly.instantiate(
|
|
7285
|
-
|
|
7498
|
+
const instance = await WebAssembly.instantiate(
|
|
7499
|
+
factory.module,
|
|
7500
|
+
this.createWasmImport(memory)
|
|
7501
|
+
);
|
|
7502
|
+
return this.createMonoDSPInstanceAux(
|
|
7503
|
+
instance,
|
|
7504
|
+
factory.json,
|
|
7505
|
+
memory
|
|
7506
|
+
);
|
|
7286
7507
|
} else {
|
|
7287
|
-
const instance = await WebAssembly.instantiate(
|
|
7508
|
+
const instance = await WebAssembly.instantiate(
|
|
7509
|
+
factory.module,
|
|
7510
|
+
this.createWasmImport()
|
|
7511
|
+
);
|
|
7288
7512
|
return this.createMonoDSPInstanceAux(instance, factory.json);
|
|
7289
7513
|
}
|
|
7290
7514
|
}
|
|
@@ -7293,21 +7517,41 @@ var FaustWasmInstantiator = class {
|
|
|
7293
7517
|
const isDetected = pattern.test(factory.json);
|
|
7294
7518
|
if (isDetected) {
|
|
7295
7519
|
const memory = this.createMemoryMono(factory);
|
|
7296
|
-
const instance = new WebAssembly.Instance(
|
|
7297
|
-
|
|
7520
|
+
const instance = new WebAssembly.Instance(
|
|
7521
|
+
factory.module,
|
|
7522
|
+
this.createWasmImport(memory)
|
|
7523
|
+
);
|
|
7524
|
+
return this.createMonoDSPInstanceAux(
|
|
7525
|
+
instance,
|
|
7526
|
+
factory.json,
|
|
7527
|
+
memory
|
|
7528
|
+
);
|
|
7298
7529
|
} else {
|
|
7299
|
-
const instance = new WebAssembly.Instance(
|
|
7530
|
+
const instance = new WebAssembly.Instance(
|
|
7531
|
+
factory.module,
|
|
7532
|
+
this.createWasmImport()
|
|
7533
|
+
);
|
|
7300
7534
|
return this.createMonoDSPInstanceAux(instance, factory.json);
|
|
7301
7535
|
}
|
|
7302
7536
|
}
|
|
7303
7537
|
static async createAsyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory) {
|
|
7304
|
-
const memory = this.createMemoryPoly(
|
|
7305
|
-
|
|
7538
|
+
const memory = this.createMemoryPoly(
|
|
7539
|
+
voices,
|
|
7540
|
+
voiceFactory,
|
|
7541
|
+
effectFactory
|
|
7542
|
+
);
|
|
7543
|
+
const voiceInstance = await WebAssembly.instantiate(
|
|
7544
|
+
voiceFactory.module,
|
|
7545
|
+
this.createWasmImport(memory)
|
|
7546
|
+
);
|
|
7306
7547
|
const voiceFunctions = voiceInstance.exports;
|
|
7307
7548
|
const voiceAPI = new FaustDspInstance(voiceFunctions);
|
|
7308
7549
|
const mixerAPI = this.createMixerAux(mixerModule, memory);
|
|
7309
7550
|
if (effectFactory) {
|
|
7310
|
-
const effectInstance = await WebAssembly.instantiate(
|
|
7551
|
+
const effectInstance = await WebAssembly.instantiate(
|
|
7552
|
+
effectFactory.module,
|
|
7553
|
+
this.createWasmImport(memory)
|
|
7554
|
+
);
|
|
7311
7555
|
const effectFunctions = effectInstance.exports;
|
|
7312
7556
|
const effectAPI = new FaustDspInstance(effectFunctions);
|
|
7313
7557
|
return {
|
|
@@ -7330,13 +7574,23 @@ var FaustWasmInstantiator = class {
|
|
|
7330
7574
|
}
|
|
7331
7575
|
}
|
|
7332
7576
|
static createSyncPolyDSPInstance(voiceFactory, mixerModule, voices, effectFactory) {
|
|
7333
|
-
const memory = this.createMemoryPoly(
|
|
7334
|
-
|
|
7577
|
+
const memory = this.createMemoryPoly(
|
|
7578
|
+
voices,
|
|
7579
|
+
voiceFactory,
|
|
7580
|
+
effectFactory
|
|
7581
|
+
);
|
|
7582
|
+
const voiceInstance = new WebAssembly.Instance(
|
|
7583
|
+
voiceFactory.module,
|
|
7584
|
+
this.createWasmImport(memory)
|
|
7585
|
+
);
|
|
7335
7586
|
const voiceFunctions = voiceInstance.exports;
|
|
7336
7587
|
const voiceAPI = new FaustDspInstance(voiceFunctions);
|
|
7337
7588
|
const mixerAPI = this.createMixerAux(mixerModule, memory);
|
|
7338
7589
|
if (effectFactory) {
|
|
7339
|
-
const effectInstance = new WebAssembly.Instance(
|
|
7590
|
+
const effectInstance = new WebAssembly.Instance(
|
|
7591
|
+
effectFactory.module,
|
|
7592
|
+
this.createWasmImport(memory)
|
|
7593
|
+
);
|
|
7340
7594
|
const effectFunctions = effectInstance.exports;
|
|
7341
7595
|
const effectAPI = new FaustDspInstance(effectFunctions);
|
|
7342
7596
|
return {
|
|
@@ -7365,7 +7619,7 @@ var FaustWasmInstantiator_default = FaustWasmInstantiator;
|
|
|
7365
7619
|
var FaustSensors = class _FaustSensors {
|
|
7366
7620
|
/**
|
|
7367
7621
|
* Function to convert a number to an axis type
|
|
7368
|
-
*
|
|
7622
|
+
*
|
|
7369
7623
|
* @param value number
|
|
7370
7624
|
* @returns axis type
|
|
7371
7625
|
*/
|
|
@@ -7384,7 +7638,7 @@ var FaustSensors = class _FaustSensors {
|
|
|
7384
7638
|
}
|
|
7385
7639
|
/**
|
|
7386
7640
|
* Function to convert a number to a curve type
|
|
7387
|
-
*
|
|
7641
|
+
*
|
|
7388
7642
|
* @param value number
|
|
7389
7643
|
* @returns curve type
|
|
7390
7644
|
*/
|
|
@@ -7436,7 +7690,7 @@ var FaustSensors = class _FaustSensors {
|
|
|
7436
7690
|
}
|
|
7437
7691
|
}
|
|
7438
7692
|
returnMappedValue(v) {
|
|
7439
|
-
|
|
7693
|
+
const x = this.fRange.clip(v);
|
|
7440
7694
|
return this.fOffset + x * this.fCoef;
|
|
7441
7695
|
}
|
|
7442
7696
|
getLowHigh(amin, amax) {
|
|
@@ -7453,17 +7707,37 @@ var FaustSensors = class _FaustSensors {
|
|
|
7453
7707
|
if (!this._Interpolator3pt) {
|
|
7454
7708
|
this._Interpolator3pt = class {
|
|
7455
7709
|
constructor(lo, mid, hi, v1, vMid, v2) {
|
|
7456
|
-
this.fSegment1 = new _FaustSensors.Interpolator(
|
|
7457
|
-
|
|
7710
|
+
this.fSegment1 = new _FaustSensors.Interpolator(
|
|
7711
|
+
lo,
|
|
7712
|
+
mid,
|
|
7713
|
+
v1,
|
|
7714
|
+
vMid
|
|
7715
|
+
);
|
|
7716
|
+
this.fSegment2 = new _FaustSensors.Interpolator(
|
|
7717
|
+
mid,
|
|
7718
|
+
hi,
|
|
7719
|
+
vMid,
|
|
7720
|
+
v2
|
|
7721
|
+
);
|
|
7458
7722
|
this.fMid = mid;
|
|
7459
7723
|
}
|
|
7460
7724
|
returnMappedValue(x) {
|
|
7461
7725
|
return x < this.fMid ? this.fSegment1.returnMappedValue(x) : this.fSegment2.returnMappedValue(x);
|
|
7462
7726
|
}
|
|
7463
7727
|
getMappingValues(amin, amid, amax) {
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
|
|
7728
|
+
const lowHighSegment1 = this.fSegment1.getLowHigh(
|
|
7729
|
+
amin,
|
|
7730
|
+
amid
|
|
7731
|
+
);
|
|
7732
|
+
const lowHighSegment2 = this.fSegment2.getLowHigh(
|
|
7733
|
+
amid,
|
|
7734
|
+
amax
|
|
7735
|
+
);
|
|
7736
|
+
return {
|
|
7737
|
+
amin: lowHighSegment1.amin,
|
|
7738
|
+
amid: lowHighSegment2.amin,
|
|
7739
|
+
amax: lowHighSegment2.amax
|
|
7740
|
+
};
|
|
7467
7741
|
}
|
|
7468
7742
|
};
|
|
7469
7743
|
}
|
|
@@ -7477,8 +7751,22 @@ var FaustSensors = class _FaustSensors {
|
|
|
7477
7751
|
this._UpConverter = class {
|
|
7478
7752
|
constructor(amin, amid, amax, fmin, fmid, fmax) {
|
|
7479
7753
|
this.fActive = true;
|
|
7480
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7481
|
-
|
|
7754
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7755
|
+
amin,
|
|
7756
|
+
amid,
|
|
7757
|
+
amax,
|
|
7758
|
+
fmin,
|
|
7759
|
+
fmid,
|
|
7760
|
+
fmax
|
|
7761
|
+
);
|
|
7762
|
+
this.fF2A = new _FaustSensors.Interpolator3pt(
|
|
7763
|
+
fmin,
|
|
7764
|
+
fmid,
|
|
7765
|
+
fmax,
|
|
7766
|
+
amin,
|
|
7767
|
+
amid,
|
|
7768
|
+
amax
|
|
7769
|
+
);
|
|
7482
7770
|
}
|
|
7483
7771
|
uiToFaust(x) {
|
|
7484
7772
|
return this.fA2F.returnMappedValue(x);
|
|
@@ -7487,8 +7775,22 @@ var FaustSensors = class _FaustSensors {
|
|
|
7487
7775
|
return this.fF2A.returnMappedValue(x);
|
|
7488
7776
|
}
|
|
7489
7777
|
setMappingValues(amin, amid, amax, min, init, max) {
|
|
7490
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7491
|
-
|
|
7778
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7779
|
+
amin,
|
|
7780
|
+
amid,
|
|
7781
|
+
amax,
|
|
7782
|
+
min,
|
|
7783
|
+
init,
|
|
7784
|
+
max
|
|
7785
|
+
);
|
|
7786
|
+
this.fF2A = new _FaustSensors.Interpolator3pt(
|
|
7787
|
+
min,
|
|
7788
|
+
init,
|
|
7789
|
+
max,
|
|
7790
|
+
amin,
|
|
7791
|
+
amid,
|
|
7792
|
+
amax
|
|
7793
|
+
);
|
|
7492
7794
|
}
|
|
7493
7795
|
getMappingValues(amin, amid, amax) {
|
|
7494
7796
|
return this.fA2F.getMappingValues(amin, amid, amax);
|
|
@@ -7511,8 +7813,22 @@ var FaustSensors = class _FaustSensors {
|
|
|
7511
7813
|
this._DownConverter = class {
|
|
7512
7814
|
constructor(amin, amid, amax, fmin, fmid, fmax) {
|
|
7513
7815
|
this.fActive = true;
|
|
7514
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7515
|
-
|
|
7816
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7817
|
+
amin,
|
|
7818
|
+
amid,
|
|
7819
|
+
amax,
|
|
7820
|
+
fmax,
|
|
7821
|
+
fmid,
|
|
7822
|
+
fmin
|
|
7823
|
+
);
|
|
7824
|
+
this.fF2A = new _FaustSensors.Interpolator3pt(
|
|
7825
|
+
fmin,
|
|
7826
|
+
fmid,
|
|
7827
|
+
fmax,
|
|
7828
|
+
amax,
|
|
7829
|
+
amid,
|
|
7830
|
+
amin
|
|
7831
|
+
);
|
|
7516
7832
|
}
|
|
7517
7833
|
uiToFaust(x) {
|
|
7518
7834
|
return this.fA2F.returnMappedValue(x);
|
|
@@ -7521,8 +7837,22 @@ var FaustSensors = class _FaustSensors {
|
|
|
7521
7837
|
return this.fF2A.returnMappedValue(x);
|
|
7522
7838
|
}
|
|
7523
7839
|
setMappingValues(amin, amid, amax, min, init, max) {
|
|
7524
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7525
|
-
|
|
7840
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7841
|
+
amin,
|
|
7842
|
+
amid,
|
|
7843
|
+
amax,
|
|
7844
|
+
max,
|
|
7845
|
+
init,
|
|
7846
|
+
min
|
|
7847
|
+
);
|
|
7848
|
+
this.fF2A = new _FaustSensors.Interpolator3pt(
|
|
7849
|
+
min,
|
|
7850
|
+
init,
|
|
7851
|
+
max,
|
|
7852
|
+
amax,
|
|
7853
|
+
amid,
|
|
7854
|
+
amin
|
|
7855
|
+
);
|
|
7526
7856
|
}
|
|
7527
7857
|
getMappingValues(amin, amid, amax) {
|
|
7528
7858
|
return this.fA2F.getMappingValues(amin, amid, amax);
|
|
@@ -7545,8 +7875,20 @@ var FaustSensors = class _FaustSensors {
|
|
|
7545
7875
|
this._UpDownConverter = class {
|
|
7546
7876
|
constructor(amin, amid, amax, fmin, fmid, fmax) {
|
|
7547
7877
|
this.fActive = true;
|
|
7548
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7549
|
-
|
|
7878
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7879
|
+
amin,
|
|
7880
|
+
amid,
|
|
7881
|
+
amax,
|
|
7882
|
+
fmin,
|
|
7883
|
+
fmax,
|
|
7884
|
+
fmin
|
|
7885
|
+
);
|
|
7886
|
+
this.fF2A = new _FaustSensors.Interpolator(
|
|
7887
|
+
fmin,
|
|
7888
|
+
fmax,
|
|
7889
|
+
amin,
|
|
7890
|
+
amax
|
|
7891
|
+
);
|
|
7550
7892
|
}
|
|
7551
7893
|
uiToFaust(x) {
|
|
7552
7894
|
return this.fA2F.returnMappedValue(x);
|
|
@@ -7555,8 +7897,20 @@ var FaustSensors = class _FaustSensors {
|
|
|
7555
7897
|
return this.fF2A.returnMappedValue(x);
|
|
7556
7898
|
}
|
|
7557
7899
|
setMappingValues(amin, amid, amax, min, init, max) {
|
|
7558
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7559
|
-
|
|
7900
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7901
|
+
amin,
|
|
7902
|
+
amid,
|
|
7903
|
+
amax,
|
|
7904
|
+
min,
|
|
7905
|
+
max,
|
|
7906
|
+
min
|
|
7907
|
+
);
|
|
7908
|
+
this.fF2A = new _FaustSensors.Interpolator(
|
|
7909
|
+
min,
|
|
7910
|
+
max,
|
|
7911
|
+
amin,
|
|
7912
|
+
amax
|
|
7913
|
+
);
|
|
7560
7914
|
}
|
|
7561
7915
|
getMappingValues(amin, amid, amax) {
|
|
7562
7916
|
return this.fA2F.getMappingValues(amin, amid, amax);
|
|
@@ -7576,8 +7930,20 @@ var FaustSensors = class _FaustSensors {
|
|
|
7576
7930
|
this._DownUpConverter = class {
|
|
7577
7931
|
constructor(amin, amid, amax, fmin, fmid, fmax) {
|
|
7578
7932
|
this.fActive = true;
|
|
7579
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7580
|
-
|
|
7933
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7934
|
+
amin,
|
|
7935
|
+
amid,
|
|
7936
|
+
amax,
|
|
7937
|
+
fmax,
|
|
7938
|
+
fmin,
|
|
7939
|
+
fmax
|
|
7940
|
+
);
|
|
7941
|
+
this.fF2A = new _FaustSensors.Interpolator(
|
|
7942
|
+
fmin,
|
|
7943
|
+
fmax,
|
|
7944
|
+
amin,
|
|
7945
|
+
amax
|
|
7946
|
+
);
|
|
7581
7947
|
}
|
|
7582
7948
|
uiToFaust(x) {
|
|
7583
7949
|
return this.fA2F.returnMappedValue(x);
|
|
@@ -7586,8 +7952,20 @@ var FaustSensors = class _FaustSensors {
|
|
|
7586
7952
|
return this.fF2A.returnMappedValue(x);
|
|
7587
7953
|
}
|
|
7588
7954
|
setMappingValues(amin, amid, amax, min, init, max) {
|
|
7589
|
-
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7590
|
-
|
|
7955
|
+
this.fA2F = new _FaustSensors.Interpolator3pt(
|
|
7956
|
+
amin,
|
|
7957
|
+
amid,
|
|
7958
|
+
amax,
|
|
7959
|
+
max,
|
|
7960
|
+
min,
|
|
7961
|
+
max
|
|
7962
|
+
);
|
|
7963
|
+
this.fF2A = new _FaustSensors.Interpolator(
|
|
7964
|
+
min,
|
|
7965
|
+
max,
|
|
7966
|
+
amin,
|
|
7967
|
+
amax
|
|
7968
|
+
);
|
|
7591
7969
|
}
|
|
7592
7970
|
getMappingValues(amin, amid, amax) {
|
|
7593
7971
|
return this.fA2F.getMappingValues(amin, amid, amax);
|
|
@@ -7610,15 +7988,50 @@ var FaustSensors = class _FaustSensors {
|
|
|
7610
7988
|
static buildHandler(curve, amin, amid, amax, min, init, max) {
|
|
7611
7989
|
switch (curve) {
|
|
7612
7990
|
case 0 /* Up */:
|
|
7613
|
-
return new _FaustSensors.UpConverter(
|
|
7991
|
+
return new _FaustSensors.UpConverter(
|
|
7992
|
+
amin,
|
|
7993
|
+
amid,
|
|
7994
|
+
amax,
|
|
7995
|
+
min,
|
|
7996
|
+
init,
|
|
7997
|
+
max
|
|
7998
|
+
);
|
|
7614
7999
|
case 1 /* Down */:
|
|
7615
|
-
return new _FaustSensors.DownConverter(
|
|
8000
|
+
return new _FaustSensors.DownConverter(
|
|
8001
|
+
amin,
|
|
8002
|
+
amid,
|
|
8003
|
+
amax,
|
|
8004
|
+
min,
|
|
8005
|
+
init,
|
|
8006
|
+
max
|
|
8007
|
+
);
|
|
7616
8008
|
case 2 /* UpDown */:
|
|
7617
|
-
return new _FaustSensors.UpDownConverter(
|
|
8009
|
+
return new _FaustSensors.UpDownConverter(
|
|
8010
|
+
amin,
|
|
8011
|
+
amid,
|
|
8012
|
+
amax,
|
|
8013
|
+
min,
|
|
8014
|
+
init,
|
|
8015
|
+
max
|
|
8016
|
+
);
|
|
7618
8017
|
case 3 /* DownUp */:
|
|
7619
|
-
return new _FaustSensors.DownUpConverter(
|
|
8018
|
+
return new _FaustSensors.DownUpConverter(
|
|
8019
|
+
amin,
|
|
8020
|
+
amid,
|
|
8021
|
+
amax,
|
|
8022
|
+
min,
|
|
8023
|
+
init,
|
|
8024
|
+
max
|
|
8025
|
+
);
|
|
7620
8026
|
default:
|
|
7621
|
-
return new _FaustSensors.UpConverter(
|
|
8027
|
+
return new _FaustSensors.UpConverter(
|
|
8028
|
+
amin,
|
|
8029
|
+
amid,
|
|
8030
|
+
amax,
|
|
8031
|
+
min,
|
|
8032
|
+
init,
|
|
8033
|
+
max
|
|
8034
|
+
);
|
|
7622
8035
|
}
|
|
7623
8036
|
}
|
|
7624
8037
|
};
|
|
@@ -7633,7 +8046,7 @@ var WasmAllocator = class {
|
|
|
7633
8046
|
* Allocates a block of memory of the specified size, returning the pointer to the
|
|
7634
8047
|
* beginning of the block. The block is allocated at the current offset and the
|
|
7635
8048
|
* offset is incremented by the size of the block.
|
|
7636
|
-
*
|
|
8049
|
+
*
|
|
7637
8050
|
* @param sizeInBytes The size of the block to allocate in bytes.
|
|
7638
8051
|
* @returns The offset (pointer) to the beginning of the allocated block.
|
|
7639
8052
|
*/
|
|
@@ -7642,7 +8055,9 @@ var WasmAllocator = class {
|
|
|
7642
8055
|
const newOffset = currentOffset + sizeInBytes;
|
|
7643
8056
|
const totalMemoryBytes = this.memory.buffer.byteLength;
|
|
7644
8057
|
if (newOffset > totalMemoryBytes) {
|
|
7645
|
-
const neededPages = Math.ceil(
|
|
8058
|
+
const neededPages = Math.ceil(
|
|
8059
|
+
(newOffset - totalMemoryBytes) / 65536
|
|
8060
|
+
);
|
|
7646
8061
|
console.log(`GROW: ${neededPages} pages`);
|
|
7647
8062
|
this.memory.grow(neededPages);
|
|
7648
8063
|
}
|
|
@@ -7651,7 +8066,7 @@ var WasmAllocator = class {
|
|
|
7651
8066
|
}
|
|
7652
8067
|
/**
|
|
7653
8068
|
* Returns the underlying buffer object.
|
|
7654
|
-
*
|
|
8069
|
+
*
|
|
7655
8070
|
* @returns The buffer object.
|
|
7656
8071
|
*/
|
|
7657
8072
|
getBuffer() {
|
|
@@ -7659,7 +8074,7 @@ var WasmAllocator = class {
|
|
|
7659
8074
|
}
|
|
7660
8075
|
/**
|
|
7661
8076
|
* Returns the Int32 view of the underlying buffer object.
|
|
7662
|
-
*
|
|
8077
|
+
*
|
|
7663
8078
|
* @returns The view of the memory buffer as Int32Array.
|
|
7664
8079
|
*/
|
|
7665
8080
|
getInt32Array() {
|
|
@@ -7667,7 +8082,7 @@ var WasmAllocator = class {
|
|
|
7667
8082
|
}
|
|
7668
8083
|
/**
|
|
7669
8084
|
* Returns the Int64 view of the underlying buffer object.
|
|
7670
|
-
*
|
|
8085
|
+
*
|
|
7671
8086
|
* @returns The view of the memory buffer as BigInt64Array.
|
|
7672
8087
|
*/
|
|
7673
8088
|
getInt64Array() {
|
|
@@ -7675,7 +8090,7 @@ var WasmAllocator = class {
|
|
|
7675
8090
|
}
|
|
7676
8091
|
/**
|
|
7677
8092
|
* Returns the Float32 view of the underlying buffer object.
|
|
7678
|
-
*
|
|
8093
|
+
*
|
|
7679
8094
|
* @returns The view of the memory buffer as Float32Array.
|
|
7680
8095
|
*/
|
|
7681
8096
|
getFloat32Array() {
|
|
@@ -7683,7 +8098,7 @@ var WasmAllocator = class {
|
|
|
7683
8098
|
}
|
|
7684
8099
|
/**
|
|
7685
8100
|
* Returns the Float64 view of the underlying buffer object..
|
|
7686
|
-
*
|
|
8101
|
+
*
|
|
7687
8102
|
* @returns The view of the memory buffer as Float64Array.
|
|
7688
8103
|
*/
|
|
7689
8104
|
getFloat64Array() {
|
|
@@ -7712,11 +8127,19 @@ var Soundfile = class _Soundfile {
|
|
|
7712
8127
|
this.fIntSize = this.fSampleSize;
|
|
7713
8128
|
this.fPtrSize = 4;
|
|
7714
8129
|
this.fAllocator = allocator;
|
|
7715
|
-
console.log(
|
|
8130
|
+
console.log(
|
|
8131
|
+
`Soundfile constructor: curChan: ${curChan}, length: ${length}, maxChan: ${maxChan}, totalParts: ${totalParts}`
|
|
8132
|
+
);
|
|
7716
8133
|
this.fPtr = allocator.alloc(4 * this.fPtrSize);
|
|
7717
|
-
this.fLength = allocator.alloc(
|
|
7718
|
-
|
|
7719
|
-
|
|
8134
|
+
this.fLength = allocator.alloc(
|
|
8135
|
+
_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize
|
|
8136
|
+
);
|
|
8137
|
+
this.fSR = allocator.alloc(
|
|
8138
|
+
_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize
|
|
8139
|
+
);
|
|
8140
|
+
this.fOffset = allocator.alloc(
|
|
8141
|
+
_Soundfile.MAX_SOUNDFILE_PARTS * this.fIntSize
|
|
8142
|
+
);
|
|
7720
8143
|
this.fBuffers = this.allocBuffers(curChan, length, maxChan);
|
|
7721
8144
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
7722
8145
|
HEAP32[this.fPtr >> 2] = this.fBuffers;
|
|
@@ -7732,7 +8155,9 @@ var Soundfile = class _Soundfile {
|
|
|
7732
8155
|
const buffers = this.fAllocator.alloc(maxChan * this.fPtrSize);
|
|
7733
8156
|
console.log(`allocBuffers buffers: ${buffers}`);
|
|
7734
8157
|
for (let chan = 0; chan < curChan; chan++) {
|
|
7735
|
-
const buffer = this.fAllocator.alloc(
|
|
8158
|
+
const buffer = this.fAllocator.alloc(
|
|
8159
|
+
length * this.fSampleSize
|
|
8160
|
+
);
|
|
7736
8161
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
7737
8162
|
HEAP32[(buffers >> 2) + chan] = buffer;
|
|
7738
8163
|
}
|
|
@@ -7752,11 +8177,17 @@ var Soundfile = class _Soundfile {
|
|
|
7752
8177
|
HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;
|
|
7753
8178
|
} else {
|
|
7754
8179
|
const HEAP64 = this.fAllocator.getInt64Array();
|
|
7755
|
-
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
7756
|
-
|
|
8180
|
+
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
8181
|
+
audioData.audioBuffer[0].length
|
|
8182
|
+
);
|
|
8183
|
+
HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
8184
|
+
audioData.sampleRate
|
|
8185
|
+
);
|
|
7757
8186
|
HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);
|
|
7758
8187
|
}
|
|
7759
|
-
console.log(
|
|
8188
|
+
console.log(
|
|
8189
|
+
`copyToOut: part: ${part}, maxChannels: ${maxChannels}, offset: ${offset}, buffer: ${audioData}`
|
|
8190
|
+
);
|
|
7760
8191
|
if (this.fSampleSize === 8) {
|
|
7761
8192
|
this.copyToOutReal64(maxChannels, offset, audioData);
|
|
7762
8193
|
} else {
|
|
@@ -7771,7 +8202,9 @@ var Soundfile = class _Soundfile {
|
|
|
7771
8202
|
const output = HEAP32[(this.fBuffers >> 2) + chan];
|
|
7772
8203
|
const begin = output + offset * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
7773
8204
|
const end = output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
7774
|
-
console.log(
|
|
8205
|
+
console.log(
|
|
8206
|
+
`copyToOutReal32 begin: ${begin}, end: ${end}, delta: ${end - begin}`
|
|
8207
|
+
);
|
|
7775
8208
|
const outputReal = HEAPF.subarray(
|
|
7776
8209
|
output + offset * this.fSampleSize >> Math.log2(this.fSampleSize),
|
|
7777
8210
|
output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize)
|
|
@@ -7789,7 +8222,9 @@ var Soundfile = class _Soundfile {
|
|
|
7789
8222
|
const output = HEAP32[(this.fBuffers >> 2) + chan];
|
|
7790
8223
|
const begin = output + offset * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
7791
8224
|
const end = output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize);
|
|
7792
|
-
console.log(
|
|
8225
|
+
console.log(
|
|
8226
|
+
`copyToOutReal64 begin: ${begin}, end: ${end}, delta: ${end - begin}`
|
|
8227
|
+
);
|
|
7793
8228
|
const outputReal = HEAPF.subarray(
|
|
7794
8229
|
output + offset * this.fSampleSize >> Math.log2(this.fSampleSize),
|
|
7795
8230
|
output + (offset + input.length) * this.fSampleSize >> Math.log2(this.fSampleSize)
|
|
@@ -7807,8 +8242,12 @@ var Soundfile = class _Soundfile {
|
|
|
7807
8242
|
HEAP32[(this.fOffset >> Math.log2(this.fIntSize)) + part] = offset;
|
|
7808
8243
|
} else {
|
|
7809
8244
|
const HEAP64 = this.fAllocator.getInt64Array();
|
|
7810
|
-
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
7811
|
-
|
|
8245
|
+
HEAP64[(this.fLength >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
8246
|
+
_Soundfile.BUFFER_SIZE
|
|
8247
|
+
);
|
|
8248
|
+
HEAP64[(this.fSR >> Math.log2(this.fIntSize)) + part] = BigInt(
|
|
8249
|
+
_Soundfile.SAMPLE_RATE
|
|
8250
|
+
);
|
|
7812
8251
|
HEAP64[(this.fOffset >> Math.log2(this.fIntSize)) + part] = BigInt(offset);
|
|
7813
8252
|
}
|
|
7814
8253
|
return offset + _Soundfile.BUFFER_SIZE;
|
|
@@ -7823,9 +8262,15 @@ var Soundfile = class _Soundfile {
|
|
|
7823
8262
|
const HEAP32 = this.fAllocator.getInt32Array();
|
|
7824
8263
|
if (mem) console.log(`HEAP32: ${HEAP32}`);
|
|
7825
8264
|
console.log(`HEAP32[this.fPtr >> 2]: ${HEAP32[this.fPtr >> 2]}`);
|
|
7826
|
-
console.log(
|
|
7827
|
-
|
|
7828
|
-
|
|
8265
|
+
console.log(
|
|
8266
|
+
`HEAP32[(this.fPtr + ptrSize) >> 2]: ${HEAP32[this.fPtr + this.fPtrSize >> 2]}`
|
|
8267
|
+
);
|
|
8268
|
+
console.log(
|
|
8269
|
+
`HEAP32[(this.fPtr + 2 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 2 * this.fPtrSize >> 2]}`
|
|
8270
|
+
);
|
|
8271
|
+
console.log(
|
|
8272
|
+
`HEAP32[(this.fPtr + 3 * ptrSize) >> 2]: ${HEAP32[this.fPtr + 3 * this.fPtrSize >> 2]}`
|
|
8273
|
+
);
|
|
7829
8274
|
}
|
|
7830
8275
|
// Return the pointer to the soundfile structure in wasm memory
|
|
7831
8276
|
getPtr() {
|
|
@@ -7884,46 +8329,112 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
7884
8329
|
if (strMidi === "pitchwheel") {
|
|
7885
8330
|
const matched = strMidi.match(/^pitchwheel\s(\d+)/);
|
|
7886
8331
|
if (matched) {
|
|
7887
|
-
this.fPitchwheelLabel.push({
|
|
8332
|
+
this.fPitchwheelLabel.push({
|
|
8333
|
+
path: item.address,
|
|
8334
|
+
chan: parseInt(matched[1]),
|
|
8335
|
+
min: item.min,
|
|
8336
|
+
max: item.max
|
|
8337
|
+
});
|
|
7888
8338
|
} else {
|
|
7889
|
-
this.fPitchwheelLabel.push({
|
|
8339
|
+
this.fPitchwheelLabel.push({
|
|
8340
|
+
path: item.address,
|
|
8341
|
+
chan: 0,
|
|
8342
|
+
min: item.min,
|
|
8343
|
+
max: item.max
|
|
8344
|
+
});
|
|
7890
8345
|
}
|
|
7891
8346
|
} else {
|
|
7892
8347
|
const matched2 = strMidi.match(/^ctrl\s(\d+)\s(\d+)/);
|
|
7893
8348
|
const matched1 = strMidi.match(/^ctrl\s(\d+)/);
|
|
7894
|
-
const matchedKey = strMidi.match(
|
|
7895
|
-
|
|
7896
|
-
|
|
8349
|
+
const matchedKey = strMidi.match(
|
|
8350
|
+
/^key\s+(\d+)(?:\s+(\d+))?$/
|
|
8351
|
+
);
|
|
8352
|
+
const matchedKeyOn = strMidi.match(
|
|
8353
|
+
/^keyon\s+(\d+)(?:\s+(\d+))?$/
|
|
8354
|
+
);
|
|
8355
|
+
const matchedKeyOff = strMidi.match(
|
|
8356
|
+
/^keyoff\s+(\d+)(?:\s+(\d+))?$/
|
|
8357
|
+
);
|
|
7897
8358
|
if (matched2) {
|
|
7898
|
-
this.fCtrlLabel[parseInt(matched2[1])].push({
|
|
8359
|
+
this.fCtrlLabel[parseInt(matched2[1])].push({
|
|
8360
|
+
path: item.address,
|
|
8361
|
+
chan: parseInt(matched2[2]),
|
|
8362
|
+
min: item.min,
|
|
8363
|
+
max: item.max
|
|
8364
|
+
});
|
|
7899
8365
|
} else if (matched1) {
|
|
7900
|
-
this.fCtrlLabel[parseInt(matched1[1])].push({
|
|
8366
|
+
this.fCtrlLabel[parseInt(matched1[1])].push({
|
|
8367
|
+
path: item.address,
|
|
8368
|
+
chan: 0,
|
|
8369
|
+
min: item.min,
|
|
8370
|
+
max: item.max
|
|
8371
|
+
});
|
|
7901
8372
|
} else if (matchedKey) {
|
|
7902
8373
|
const note = parseInt(matchedKey[1]);
|
|
7903
8374
|
const channel = matchedKey[2] ? parseInt(matchedKey[2]) : 0;
|
|
7904
|
-
this.fMidiKeyLabel[note].push({
|
|
8375
|
+
this.fMidiKeyLabel[note].push({
|
|
8376
|
+
path: item.address,
|
|
8377
|
+
chan: channel,
|
|
8378
|
+
min: (_a = item.min) != null ? _a : 0,
|
|
8379
|
+
max: (_b = item.max) != null ? _b : 1
|
|
8380
|
+
});
|
|
7905
8381
|
} else if (matchedKeyOn) {
|
|
7906
8382
|
const note = parseInt(matchedKeyOn[1]);
|
|
7907
8383
|
const channel = matchedKeyOn[2] ? parseInt(matchedKeyOn[2]) : 0;
|
|
7908
|
-
this.fMidiKeyOnLabel[note].push({
|
|
8384
|
+
this.fMidiKeyOnLabel[note].push({
|
|
8385
|
+
path: item.address,
|
|
8386
|
+
chan: channel,
|
|
8387
|
+
min: (_c = item.min) != null ? _c : 0,
|
|
8388
|
+
max: (_d = item.max) != null ? _d : 1
|
|
8389
|
+
});
|
|
7909
8390
|
} else if (matchedKeyOff) {
|
|
7910
8391
|
const note = parseInt(matchedKeyOff[1]);
|
|
7911
8392
|
const channel = matchedKeyOff[2] ? parseInt(matchedKeyOff[2]) : 0;
|
|
7912
|
-
this.fMidiKeyOffLabel[note].push({
|
|
8393
|
+
this.fMidiKeyOffLabel[note].push({
|
|
8394
|
+
path: item.address,
|
|
8395
|
+
chan: channel,
|
|
8396
|
+
min: (_e = item.min) != null ? _e : 0,
|
|
8397
|
+
max: (_f = item.max) != null ? _f : 1
|
|
8398
|
+
});
|
|
7913
8399
|
}
|
|
7914
8400
|
}
|
|
7915
8401
|
}
|
|
7916
8402
|
if (acc) {
|
|
7917
8403
|
const numAcc = acc.trim().split(" ").map(Number);
|
|
7918
|
-
this.setupAccHandler(
|
|
8404
|
+
this.setupAccHandler(
|
|
8405
|
+
item.address,
|
|
8406
|
+
FaustSensors.convertToAxis(numAcc[0]),
|
|
8407
|
+
FaustSensors.convertToCurve(numAcc[1]),
|
|
8408
|
+
numAcc[2],
|
|
8409
|
+
numAcc[3],
|
|
8410
|
+
numAcc[4],
|
|
8411
|
+
item.min,
|
|
8412
|
+
item.init,
|
|
8413
|
+
item.max
|
|
8414
|
+
);
|
|
7919
8415
|
}
|
|
7920
8416
|
if (gyr) {
|
|
7921
8417
|
const numAcc = gyr.trim().split(" ").map(Number);
|
|
7922
|
-
this.setupGyrHandler(
|
|
8418
|
+
this.setupGyrHandler(
|
|
8419
|
+
item.address,
|
|
8420
|
+
FaustSensors.convertToAxis(numAcc[0]),
|
|
8421
|
+
FaustSensors.convertToCurve(numAcc[1]),
|
|
8422
|
+
numAcc[2],
|
|
8423
|
+
numAcc[3],
|
|
8424
|
+
numAcc[4],
|
|
8425
|
+
item.min,
|
|
8426
|
+
item.init,
|
|
8427
|
+
item.max
|
|
8428
|
+
);
|
|
7923
8429
|
}
|
|
7924
8430
|
});
|
|
7925
8431
|
} else if (item.type === "soundfile") {
|
|
7926
|
-
this.fSoundfiles.push({
|
|
8432
|
+
this.fSoundfiles.push({
|
|
8433
|
+
name: item.label,
|
|
8434
|
+
url: item.url,
|
|
8435
|
+
index: item.index,
|
|
8436
|
+
basePtr: -1
|
|
8437
|
+
});
|
|
7927
8438
|
}
|
|
7928
8439
|
};
|
|
7929
8440
|
// Audio callback
|
|
@@ -7962,8 +8473,10 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
7962
8473
|
}
|
|
7963
8474
|
/** Split the soundfile names and return an array of names */
|
|
7964
8475
|
static splitSoundfileNames(input) {
|
|
7965
|
-
|
|
7966
|
-
return trimmed.split(";").map(
|
|
8476
|
+
const trimmed = input.replace(/^\{|\}$/g, "");
|
|
8477
|
+
return trimmed.split(";").map(
|
|
8478
|
+
(str) => str.length <= 2 ? "" : str.substring(1, str.length - 1)
|
|
8479
|
+
);
|
|
7967
8480
|
}
|
|
7968
8481
|
get hasAccInput() {
|
|
7969
8482
|
return this.fAcc.x.length + this.fAcc.y.length + this.fAcc.z.length > 0;
|
|
@@ -7991,36 +8504,66 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
7991
8504
|
}
|
|
7992
8505
|
/** Build the accelerometer handler */
|
|
7993
8506
|
setupAccHandler(path, axis, curve, amin, amid, amax, min, init, max) {
|
|
7994
|
-
const handler = FaustSensors.buildHandler(
|
|
8507
|
+
const handler = FaustSensors.buildHandler(
|
|
8508
|
+
curve,
|
|
8509
|
+
amin,
|
|
8510
|
+
amid,
|
|
8511
|
+
amax,
|
|
8512
|
+
min,
|
|
8513
|
+
init,
|
|
8514
|
+
max
|
|
8515
|
+
);
|
|
7995
8516
|
switch (axis) {
|
|
7996
8517
|
case 0 /* x */:
|
|
7997
|
-
this.fAcc.x.push(
|
|
8518
|
+
this.fAcc.x.push(
|
|
8519
|
+
(val) => this.setParamValue(path, handler.uiToFaust(val))
|
|
8520
|
+
);
|
|
7998
8521
|
break;
|
|
7999
8522
|
case 1 /* y */:
|
|
8000
|
-
this.fAcc.y.push(
|
|
8523
|
+
this.fAcc.y.push(
|
|
8524
|
+
(val) => this.setParamValue(path, handler.uiToFaust(val))
|
|
8525
|
+
);
|
|
8001
8526
|
break;
|
|
8002
8527
|
case 2 /* z */:
|
|
8003
|
-
this.fAcc.z.push(
|
|
8528
|
+
this.fAcc.z.push(
|
|
8529
|
+
(val) => this.setParamValue(path, handler.uiToFaust(val))
|
|
8530
|
+
);
|
|
8004
8531
|
break;
|
|
8005
8532
|
}
|
|
8006
8533
|
}
|
|
8007
8534
|
/** Build the gyroscope handler */
|
|
8008
8535
|
setupGyrHandler(path, axis, curve, amin, amid, amax, min, init, max) {
|
|
8009
|
-
const handler = FaustSensors.buildHandler(
|
|
8536
|
+
const handler = FaustSensors.buildHandler(
|
|
8537
|
+
curve,
|
|
8538
|
+
amin,
|
|
8539
|
+
amid,
|
|
8540
|
+
amax,
|
|
8541
|
+
min,
|
|
8542
|
+
init,
|
|
8543
|
+
max
|
|
8544
|
+
);
|
|
8010
8545
|
switch (axis) {
|
|
8011
8546
|
case 0 /* x */:
|
|
8012
|
-
this.fGyr.x.push(
|
|
8547
|
+
this.fGyr.x.push(
|
|
8548
|
+
(val) => this.setParamValue(path, handler.uiToFaust(val))
|
|
8549
|
+
);
|
|
8013
8550
|
break;
|
|
8014
8551
|
case 1 /* y */:
|
|
8015
|
-
this.fGyr.y.push(
|
|
8552
|
+
this.fGyr.y.push(
|
|
8553
|
+
(val) => this.setParamValue(path, handler.uiToFaust(val))
|
|
8554
|
+
);
|
|
8016
8555
|
break;
|
|
8017
8556
|
case 2 /* z */:
|
|
8018
|
-
this.fGyr.z.push(
|
|
8557
|
+
this.fGyr.z.push(
|
|
8558
|
+
(val) => this.setParamValue(path, handler.uiToFaust(val))
|
|
8559
|
+
);
|
|
8019
8560
|
break;
|
|
8020
8561
|
}
|
|
8021
8562
|
}
|
|
8022
8563
|
static extractUrlsFromMeta(dspMeta) {
|
|
8023
|
-
const soundfilesEntry = dspMeta.meta.find(
|
|
8564
|
+
const soundfilesEntry = dspMeta.meta.find(
|
|
8565
|
+
(entry) => entry.soundfiles !== void 0
|
|
8566
|
+
);
|
|
8024
8567
|
if (soundfilesEntry) {
|
|
8025
8568
|
return soundfilesEntry.soundfiles.split(";").filter((url) => url !== "");
|
|
8026
8569
|
} else {
|
|
@@ -8030,9 +8573,9 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8030
8573
|
/**
|
|
8031
8574
|
* Load a soundfile possibly containing several parts in the DSP struct.
|
|
8032
8575
|
* Soundfile pointers are located at 'index' offset, to be read in the JSON file.
|
|
8033
|
-
* The DSP struct is located at baseDSP in the wasm memory,
|
|
8576
|
+
* The DSP struct is located at baseDSP in the wasm memory,
|
|
8034
8577
|
* either a monophonic DSP, or a voice in a polyphonic context.
|
|
8035
|
-
*
|
|
8578
|
+
*
|
|
8036
8579
|
* @param allocator : the wasm memory allocator
|
|
8037
8580
|
* @param baseDSP : the base DSP in the wasm memory
|
|
8038
8581
|
* @param name : the name of the soundfile
|
|
@@ -8045,17 +8588,27 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8045
8588
|
if (!item) throw new Error(`Soundfile with ${url} cannot be found !}`);
|
|
8046
8589
|
if (item.basePtr !== -1) {
|
|
8047
8590
|
const HEAP32 = allocator.getInt32Array();
|
|
8048
|
-
console.log(
|
|
8591
|
+
console.log(
|
|
8592
|
+
`Soundfile CACHE ${url}} : ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`
|
|
8593
|
+
);
|
|
8049
8594
|
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
8050
8595
|
} else {
|
|
8051
|
-
const soundfile = this.createSoundfile(
|
|
8596
|
+
const soundfile = this.createSoundfile(
|
|
8597
|
+
allocator,
|
|
8598
|
+
soundfileIds,
|
|
8599
|
+
this.fSoundfileBuffers
|
|
8600
|
+
);
|
|
8052
8601
|
if (soundfile) {
|
|
8053
8602
|
const HEAP32 = soundfile.getHEAP32();
|
|
8054
8603
|
item.basePtr = soundfile.getPtr();
|
|
8055
|
-
console.log(
|
|
8604
|
+
console.log(
|
|
8605
|
+
`Soundfile ${name} loaded at ${item.basePtr} in wasm memory with index ${item.index}`
|
|
8606
|
+
);
|
|
8056
8607
|
HEAP32[baseDSP + item.index >> 2] = item.basePtr;
|
|
8057
8608
|
} else {
|
|
8058
|
-
console.log(
|
|
8609
|
+
console.log(
|
|
8610
|
+
`Soundfile ${name} for ${url} cannot be created !}`
|
|
8611
|
+
);
|
|
8059
8612
|
}
|
|
8060
8613
|
}
|
|
8061
8614
|
}
|
|
@@ -8077,7 +8630,14 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8077
8630
|
totalLength += len;
|
|
8078
8631
|
}
|
|
8079
8632
|
totalLength += (Soundfile.MAX_SOUNDFILE_PARTS - soundfileIdList.length) * Soundfile.BUFFER_SIZE;
|
|
8080
|
-
const soundfile = new Soundfile(
|
|
8633
|
+
const soundfile = new Soundfile(
|
|
8634
|
+
allocator,
|
|
8635
|
+
this.fSampleSize,
|
|
8636
|
+
curChan,
|
|
8637
|
+
totalLength,
|
|
8638
|
+
maxChan,
|
|
8639
|
+
soundfileIdList.length
|
|
8640
|
+
);
|
|
8081
8641
|
let offset = 0;
|
|
8082
8642
|
for (let part = 0; part < soundfileIdList.length; part++) {
|
|
8083
8643
|
const soundfileId = soundfileIdList[part];
|
|
@@ -8095,31 +8655,34 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8095
8655
|
soundfile.shareBuffers(curChan, maxChan);
|
|
8096
8656
|
return soundfile;
|
|
8097
8657
|
}
|
|
8098
|
-
/**
|
|
8658
|
+
/**
|
|
8099
8659
|
* Init soundfiles memory.
|
|
8100
|
-
*
|
|
8660
|
+
*
|
|
8101
8661
|
* @param allocator : the wasm memory allocator
|
|
8102
8662
|
* @param baseDSP : the DSP struct (either a monophonic DSP of polyphonic voice) base DSP in the wasm memory
|
|
8103
|
-
|
|
8663
|
+
*/
|
|
8104
8664
|
initSoundfileMemory(allocator, baseDSP) {
|
|
8105
8665
|
for (const { name, url } of this.fSoundfiles) {
|
|
8106
8666
|
this.loadSoundfile(allocator, baseDSP, name, url);
|
|
8107
8667
|
}
|
|
8108
|
-
;
|
|
8109
8668
|
}
|
|
8110
8669
|
updateOutputs() {
|
|
8111
8670
|
if (this.fOutputsItems.length > 0 && this.fOutputHandler && this.fOutputsTimer-- === 0) {
|
|
8112
8671
|
this.fOutputsTimer = 5;
|
|
8113
|
-
this.fOutputsItems.forEach(
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8672
|
+
this.fOutputsItems.forEach(
|
|
8673
|
+
(item) => {
|
|
8674
|
+
var _a;
|
|
8675
|
+
return (_a = this.fOutputHandler) == null ? void 0 : _a.call(this, item, this.getParamValue(item));
|
|
8676
|
+
}
|
|
8677
|
+
);
|
|
8117
8678
|
}
|
|
8118
8679
|
}
|
|
8119
8680
|
// Public API
|
|
8120
8681
|
metadata(handler) {
|
|
8121
8682
|
if (this.fJSONDsp.meta) {
|
|
8122
|
-
this.fJSONDsp.meta.forEach(
|
|
8683
|
+
this.fJSONDsp.meta.forEach(
|
|
8684
|
+
(meta) => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]])
|
|
8685
|
+
);
|
|
8123
8686
|
}
|
|
8124
8687
|
}
|
|
8125
8688
|
compute(input, output) {
|
|
@@ -8165,68 +8728,127 @@ var FaustBaseWebAudioDsp = class _FaustBaseWebAudioDsp {
|
|
|
8165
8728
|
if (cmd === 11) return this.ctrlChange(channel, data1, data2);
|
|
8166
8729
|
if (cmd === 14) return this.pitchWheel(channel, data2 * 128 + data1);
|
|
8167
8730
|
if (cmd === 9) {
|
|
8168
|
-
if (data2 > 0)
|
|
8169
|
-
|
|
8170
|
-
else
|
|
8171
|
-
return this.keyOff(channel, data1, data2);
|
|
8731
|
+
if (data2 > 0) return this.keyOn(channel, data1, data2);
|
|
8732
|
+
else return this.keyOff(channel, data1, data2);
|
|
8172
8733
|
}
|
|
8173
8734
|
if (cmd === 8) {
|
|
8174
8735
|
return this.keyOff(channel, data1, data2);
|
|
8175
8736
|
}
|
|
8176
8737
|
}
|
|
8177
8738
|
ctrlChange(channel, ctrl, value) {
|
|
8178
|
-
if (this.fPlotHandler)
|
|
8739
|
+
if (this.fPlotHandler)
|
|
8740
|
+
this.fCachedEvents.push({
|
|
8741
|
+
type: "ctrlChange",
|
|
8742
|
+
data: [channel, ctrl, value]
|
|
8743
|
+
});
|
|
8179
8744
|
if (this.fCtrlLabel[ctrl].length) {
|
|
8180
8745
|
this.fCtrlLabel[ctrl].forEach((ctrl2) => {
|
|
8181
8746
|
const { path, chan } = ctrl2;
|
|
8182
8747
|
if (chan === 0 || channel === chan - 1) {
|
|
8183
|
-
this.setParamValue(
|
|
8184
|
-
|
|
8748
|
+
this.setParamValue(
|
|
8749
|
+
path,
|
|
8750
|
+
_FaustBaseWebAudioDsp.remap(
|
|
8751
|
+
value,
|
|
8752
|
+
0,
|
|
8753
|
+
127,
|
|
8754
|
+
ctrl2.min,
|
|
8755
|
+
ctrl2.max
|
|
8756
|
+
)
|
|
8757
|
+
);
|
|
8758
|
+
if (this.fOutputHandler)
|
|
8759
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
8185
8760
|
}
|
|
8186
8761
|
});
|
|
8187
8762
|
}
|
|
8188
8763
|
}
|
|
8189
8764
|
keyOn(channel, pitch, velocity) {
|
|
8190
|
-
if (this.fPlotHandler)
|
|
8765
|
+
if (this.fPlotHandler)
|
|
8766
|
+
this.fCachedEvents.push({
|
|
8767
|
+
type: "keyOn",
|
|
8768
|
+
data: [channel, pitch, velocity]
|
|
8769
|
+
});
|
|
8191
8770
|
this.fMidiKeyOnLabel[pitch].forEach((key) => {
|
|
8192
8771
|
const { path, chan } = key;
|
|
8193
8772
|
if (chan === 0 || channel === chan - 1) {
|
|
8194
|
-
this.setParamValue(
|
|
8195
|
-
|
|
8773
|
+
this.setParamValue(
|
|
8774
|
+
path,
|
|
8775
|
+
_FaustBaseWebAudioDsp.remap(
|
|
8776
|
+
velocity,
|
|
8777
|
+
0,
|
|
8778
|
+
127,
|
|
8779
|
+
key.min,
|
|
8780
|
+
key.max
|
|
8781
|
+
)
|
|
8782
|
+
);
|
|
8783
|
+
if (this.fOutputHandler)
|
|
8784
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
8196
8785
|
}
|
|
8197
8786
|
});
|
|
8198
8787
|
this.fMidiKeyLabel[pitch].forEach((key) => {
|
|
8199
8788
|
const { path, chan } = key;
|
|
8200
8789
|
if (chan === 0 || channel === chan - 1) {
|
|
8201
|
-
this.setParamValue(
|
|
8202
|
-
|
|
8790
|
+
this.setParamValue(
|
|
8791
|
+
path,
|
|
8792
|
+
_FaustBaseWebAudioDsp.remap(
|
|
8793
|
+
velocity,
|
|
8794
|
+
0,
|
|
8795
|
+
127,
|
|
8796
|
+
key.min,
|
|
8797
|
+
key.max
|
|
8798
|
+
)
|
|
8799
|
+
);
|
|
8800
|
+
if (this.fOutputHandler)
|
|
8801
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
8203
8802
|
}
|
|
8204
8803
|
});
|
|
8205
8804
|
}
|
|
8206
8805
|
keyOff(channel, pitch, velocity) {
|
|
8207
|
-
if (this.fPlotHandler)
|
|
8806
|
+
if (this.fPlotHandler)
|
|
8807
|
+
this.fCachedEvents.push({
|
|
8808
|
+
type: "keyOff",
|
|
8809
|
+
data: [channel, pitch, velocity]
|
|
8810
|
+
});
|
|
8208
8811
|
this.fMidiKeyOffLabel[pitch].forEach((key) => {
|
|
8209
8812
|
const { path, chan } = key;
|
|
8210
8813
|
if (chan === 0 || channel === chan - 1) {
|
|
8211
|
-
this.setParamValue(
|
|
8212
|
-
|
|
8814
|
+
this.setParamValue(
|
|
8815
|
+
path,
|
|
8816
|
+
_FaustBaseWebAudioDsp.remap(
|
|
8817
|
+
velocity,
|
|
8818
|
+
0,
|
|
8819
|
+
127,
|
|
8820
|
+
key.min,
|
|
8821
|
+
key.max
|
|
8822
|
+
)
|
|
8823
|
+
);
|
|
8824
|
+
if (this.fOutputHandler)
|
|
8825
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
8213
8826
|
}
|
|
8214
8827
|
});
|
|
8215
8828
|
this.fMidiKeyLabel[pitch].forEach((key) => {
|
|
8216
8829
|
const { path, chan } = key;
|
|
8217
8830
|
if (chan === 0 || channel === chan - 1) {
|
|
8218
8831
|
this.setParamValue(path, 0);
|
|
8219
|
-
if (this.fOutputHandler)
|
|
8832
|
+
if (this.fOutputHandler)
|
|
8833
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
8220
8834
|
}
|
|
8221
8835
|
});
|
|
8222
8836
|
}
|
|
8223
8837
|
pitchWheel(channel, wheel) {
|
|
8224
|
-
if (this.fPlotHandler)
|
|
8838
|
+
if (this.fPlotHandler)
|
|
8839
|
+
this.fCachedEvents.push({
|
|
8840
|
+
type: "pitchWheel",
|
|
8841
|
+
data: [channel, wheel]
|
|
8842
|
+
});
|
|
8225
8843
|
this.fPitchwheelLabel.forEach((pw) => {
|
|
8226
8844
|
const { path, chan } = pw;
|
|
8227
8845
|
if (chan === 0 || channel === chan - 1) {
|
|
8228
|
-
this.setParamValue(
|
|
8229
|
-
|
|
8846
|
+
this.setParamValue(
|
|
8847
|
+
path,
|
|
8848
|
+
_FaustBaseWebAudioDsp.remap(wheel, 0, 16383, pw.min, pw.max)
|
|
8849
|
+
);
|
|
8850
|
+
if (this.fOutputHandler)
|
|
8851
|
+
this.fOutputHandler(path, this.getParamValue(path));
|
|
8230
8852
|
}
|
|
8231
8853
|
});
|
|
8232
8854
|
}
|
|
@@ -8282,7 +8904,10 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
8282
8904
|
this.fEndMemory = this.initMemory();
|
|
8283
8905
|
this.fInstance.api.init(this.fDSP, sampleRate);
|
|
8284
8906
|
if (this.fSoundfiles.length > 0) {
|
|
8285
|
-
const allocator = new WasmAllocator(
|
|
8907
|
+
const allocator = new WasmAllocator(
|
|
8908
|
+
this.fInstance.memory,
|
|
8909
|
+
this.fEndMemory
|
|
8910
|
+
);
|
|
8286
8911
|
this.initSoundfileMemory(allocator, this.fDSP);
|
|
8287
8912
|
}
|
|
8288
8913
|
}
|
|
@@ -8301,18 +8926,30 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
8301
8926
|
for (let chan = 0; chan < this.getNumInputs(); chan++) {
|
|
8302
8927
|
HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;
|
|
8303
8928
|
}
|
|
8304
|
-
const dspInChans = HEAP32.subarray(
|
|
8929
|
+
const dspInChans = HEAP32.subarray(
|
|
8930
|
+
this.fAudioInputs >> 2,
|
|
8931
|
+
this.fAudioInputs + this.getNumInputs() * this.fPtrSize >> 2
|
|
8932
|
+
);
|
|
8305
8933
|
for (let chan = 0; chan < this.getNumInputs(); chan++) {
|
|
8306
|
-
this.fInChannels[chan] = HEAPF.subarray(
|
|
8934
|
+
this.fInChannels[chan] = HEAPF.subarray(
|
|
8935
|
+
dspInChans[chan] >> Math.log2(this.fSampleSize),
|
|
8936
|
+
dspInChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)
|
|
8937
|
+
);
|
|
8307
8938
|
}
|
|
8308
8939
|
}
|
|
8309
8940
|
if (this.getNumOutputs() > 0) {
|
|
8310
8941
|
for (let chan = 0; chan < this.getNumOutputs(); chan++) {
|
|
8311
8942
|
HEAP32[(this.fAudioOutputs >> 2) + chan] = $audioOutputs + this.fBufferSize * this.fSampleSize * chan;
|
|
8312
8943
|
}
|
|
8313
|
-
const dspOutChans = HEAP32.subarray(
|
|
8944
|
+
const dspOutChans = HEAP32.subarray(
|
|
8945
|
+
this.fAudioOutputs >> 2,
|
|
8946
|
+
this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize >> 2
|
|
8947
|
+
);
|
|
8314
8948
|
for (let chan = 0; chan < this.getNumOutputs(); chan++) {
|
|
8315
|
-
this.fOutChannels[chan] = HEAPF.subarray(
|
|
8949
|
+
this.fOutChannels[chan] = HEAPF.subarray(
|
|
8950
|
+
dspOutChans[chan] >> Math.log2(this.fSampleSize),
|
|
8951
|
+
dspOutChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)
|
|
8952
|
+
);
|
|
8316
8953
|
}
|
|
8317
8954
|
}
|
|
8318
8955
|
return endMemory;
|
|
@@ -8350,7 +8987,12 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
8350
8987
|
}
|
|
8351
8988
|
}
|
|
8352
8989
|
if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);
|
|
8353
|
-
this.fInstance.api.compute(
|
|
8990
|
+
this.fInstance.api.compute(
|
|
8991
|
+
this.fDSP,
|
|
8992
|
+
this.fBufferSize,
|
|
8993
|
+
this.fAudioInputs,
|
|
8994
|
+
this.fAudioOutputs
|
|
8995
|
+
);
|
|
8354
8996
|
this.updateOutputs();
|
|
8355
8997
|
let forPlot = this.fOutChannels;
|
|
8356
8998
|
if (typeof output === "function") {
|
|
@@ -8363,7 +9005,11 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
8363
9005
|
forPlot = output;
|
|
8364
9006
|
}
|
|
8365
9007
|
if (this.fPlotHandler) {
|
|
8366
|
-
this.fPlotHandler(
|
|
9008
|
+
this.fPlotHandler(
|
|
9009
|
+
forPlot,
|
|
9010
|
+
this.fBufferNum++,
|
|
9011
|
+
this.fCachedEvents.length ? this.fCachedEvents : void 0
|
|
9012
|
+
);
|
|
8367
9013
|
this.fCachedEvents = [];
|
|
8368
9014
|
}
|
|
8369
9015
|
return true;
|
|
@@ -8378,11 +9024,19 @@ var FaustMonoWebAudioDsp = class extends FaustBaseWebAudioDsp {
|
|
|
8378
9024
|
return this.fInstance.api.getNumOutputs(this.fDSP);
|
|
8379
9025
|
}
|
|
8380
9026
|
setParamValue(path, value) {
|
|
8381
|
-
if (this.fPlotHandler)
|
|
8382
|
-
|
|
9027
|
+
if (this.fPlotHandler)
|
|
9028
|
+
this.fCachedEvents.push({ type: "param", data: { path, value } });
|
|
9029
|
+
this.fInstance.api.setParamValue(
|
|
9030
|
+
this.fDSP,
|
|
9031
|
+
this.fPathTable[path],
|
|
9032
|
+
value
|
|
9033
|
+
);
|
|
8383
9034
|
}
|
|
8384
9035
|
getParamValue(path) {
|
|
8385
|
-
return this.fInstance.api.getParamValue(
|
|
9036
|
+
return this.fInstance.api.getParamValue(
|
|
9037
|
+
this.fDSP,
|
|
9038
|
+
this.fPathTable[path]
|
|
9039
|
+
);
|
|
8386
9040
|
}
|
|
8387
9041
|
getMeta() {
|
|
8388
9042
|
return this.fJSONDsp;
|
|
@@ -8463,16 +9117,36 @@ var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice {
|
|
|
8463
9117
|
this.fNextNote = pitch;
|
|
8464
9118
|
this.fNextVel = velocity;
|
|
8465
9119
|
} else {
|
|
8466
|
-
this.fFreqLabel.forEach(
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
9120
|
+
this.fFreqLabel.forEach(
|
|
9121
|
+
(index) => this.fAPI.setParamValue(
|
|
9122
|
+
this.fDSP,
|
|
9123
|
+
index,
|
|
9124
|
+
_FaustWebAudioDspVoice.midiToFreq(pitch)
|
|
9125
|
+
)
|
|
9126
|
+
);
|
|
9127
|
+
this.fGateLabel.forEach(
|
|
9128
|
+
(index) => this.fAPI.setParamValue(this.fDSP, index, 1)
|
|
9129
|
+
);
|
|
9130
|
+
this.fGainLabel.forEach(
|
|
9131
|
+
(index) => this.fAPI.setParamValue(
|
|
9132
|
+
this.fDSP,
|
|
9133
|
+
index,
|
|
9134
|
+
_FaustWebAudioDspVoice.normalizeVelocity(velocity)
|
|
9135
|
+
)
|
|
9136
|
+
);
|
|
9137
|
+
this.fKeyLabel.forEach(
|
|
9138
|
+
(index) => this.fAPI.setParamValue(this.fDSP, index, pitch)
|
|
9139
|
+
);
|
|
9140
|
+
this.fVelLabel.forEach(
|
|
9141
|
+
(index) => this.fAPI.setParamValue(this.fDSP, index, velocity)
|
|
9142
|
+
);
|
|
8471
9143
|
this.fCurNote = pitch;
|
|
8472
9144
|
}
|
|
8473
9145
|
}
|
|
8474
9146
|
keyOff(hard = false) {
|
|
8475
|
-
this.fGateLabel.forEach(
|
|
9147
|
+
this.fGateLabel.forEach(
|
|
9148
|
+
(index) => this.fAPI.setParamValue(this.fDSP, index, 0)
|
|
9149
|
+
);
|
|
8476
9150
|
if (hard) {
|
|
8477
9151
|
this.fCurNote = _FaustWebAudioDspVoice.kFreeVoice;
|
|
8478
9152
|
} else {
|
|
@@ -8480,8 +9154,10 @@ var FaustWebAudioDspVoice = class _FaustWebAudioDspVoice {
|
|
|
8480
9154
|
}
|
|
8481
9155
|
}
|
|
8482
9156
|
computeLegato(bufferSize, $inputs, $outputZero, $outputsHalf) {
|
|
8483
|
-
|
|
8484
|
-
this.fGateLabel.forEach(
|
|
9157
|
+
const size = bufferSize / 2;
|
|
9158
|
+
this.fGateLabel.forEach(
|
|
9159
|
+
(index) => this.fAPI.setParamValue(this.fDSP, index, 0)
|
|
9160
|
+
);
|
|
8485
9161
|
this.fAPI.compute(this.fDSP, size, $inputs, $outputZero);
|
|
8486
9162
|
this.keyOn(this.fNextNote, this.fNextVel);
|
|
8487
9163
|
this.fAPI.compute(this.fDSP, size, $inputs, $outputsHalf);
|
|
@@ -8504,21 +9180,28 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8504
9180
|
this.fJSONDsp = JSON.parse(this.fInstance.voiceJSON);
|
|
8505
9181
|
this.fJSONEffect = this.fInstance.effectAPI && this.fInstance.effectJSON ? JSON.parse(this.fInstance.effectJSON) : null;
|
|
8506
9182
|
FaustBaseWebAudioDsp.parseUI(this.fJSONDsp.ui, this.fUICallback);
|
|
8507
|
-
if (this.fJSONEffect)
|
|
9183
|
+
if (this.fJSONEffect)
|
|
9184
|
+
FaustBaseWebAudioDsp.parseUI(this.fJSONEffect.ui, this.fUICallback);
|
|
8508
9185
|
this.fEndMemory = this.initMemory();
|
|
8509
9186
|
this.fVoiceTable = [];
|
|
8510
9187
|
for (let voice = 0; voice < this.fInstance.voices; voice++) {
|
|
8511
|
-
this.fVoiceTable.push(
|
|
8512
|
-
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
9188
|
+
this.fVoiceTable.push(
|
|
9189
|
+
new FaustWebAudioDspVoice(
|
|
9190
|
+
this.fJSONDsp.size * voice,
|
|
9191
|
+
this.fInstance.voiceAPI,
|
|
9192
|
+
this.fInputsItems,
|
|
9193
|
+
this.fPathTable,
|
|
9194
|
+
sampleRate
|
|
9195
|
+
)
|
|
9196
|
+
);
|
|
9197
|
+
}
|
|
9198
|
+
if (this.fInstance.effectAPI)
|
|
9199
|
+
this.fInstance.effectAPI.init(this.fEffect, sampleRate);
|
|
8520
9200
|
if (this.fSoundfiles.length > 0) {
|
|
8521
|
-
const allocator = new WasmAllocator(
|
|
9201
|
+
const allocator = new WasmAllocator(
|
|
9202
|
+
this.fInstance.memory,
|
|
9203
|
+
this.fEndMemory
|
|
9204
|
+
);
|
|
8522
9205
|
for (let voice = 0; voice < this.fInstance.voices; voice++) {
|
|
8523
9206
|
this.initSoundfileMemory(allocator, this.fJSONDsp.size * voice);
|
|
8524
9207
|
}
|
|
@@ -8542,9 +9225,15 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8542
9225
|
for (let chan = 0; chan < this.getNumInputs(); chan++) {
|
|
8543
9226
|
HEAP32[(this.fAudioInputs >> 2) + chan] = $audioInputs + this.fBufferSize * this.fSampleSize * chan;
|
|
8544
9227
|
}
|
|
8545
|
-
const dspInChans = HEAP32.subarray(
|
|
9228
|
+
const dspInChans = HEAP32.subarray(
|
|
9229
|
+
this.fAudioInputs >> 2,
|
|
9230
|
+
this.fAudioInputs + this.getNumInputs() * this.fPtrSize >> 2
|
|
9231
|
+
);
|
|
8546
9232
|
for (let chan = 0; chan < this.getNumInputs(); chan++) {
|
|
8547
|
-
this.fInChannels[chan] = HEAPF.subarray(
|
|
9233
|
+
this.fInChannels[chan] = HEAPF.subarray(
|
|
9234
|
+
dspInChans[chan] >> Math.log2(this.fSampleSize),
|
|
9235
|
+
dspInChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)
|
|
9236
|
+
);
|
|
8548
9237
|
}
|
|
8549
9238
|
}
|
|
8550
9239
|
if (this.getNumOutputs() > 0) {
|
|
@@ -8553,9 +9242,15 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8553
9242
|
HEAP32[(this.fAudioMixing >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan;
|
|
8554
9243
|
HEAP32[(this.fAudioMixingHalf >> 2) + chan] = $audioMixing + this.fBufferSize * this.fSampleSize * chan + this.fBufferSize / 2 * this.fSampleSize;
|
|
8555
9244
|
}
|
|
8556
|
-
const dspOutChans = HEAP32.subarray(
|
|
9245
|
+
const dspOutChans = HEAP32.subarray(
|
|
9246
|
+
this.fAudioOutputs >> 2,
|
|
9247
|
+
this.fAudioOutputs + this.getNumOutputs() * this.fPtrSize >> 2
|
|
9248
|
+
);
|
|
8557
9249
|
for (let chan = 0; chan < this.getNumOutputs(); chan++) {
|
|
8558
|
-
this.fOutChannels[chan] = HEAPF.subarray(
|
|
9250
|
+
this.fOutChannels[chan] = HEAPF.subarray(
|
|
9251
|
+
dspOutChans[chan] >> Math.log2(this.fSampleSize),
|
|
9252
|
+
dspOutChans[chan] + this.fBufferSize * this.fSampleSize >> Math.log2(this.fSampleSize)
|
|
9253
|
+
);
|
|
8559
9254
|
}
|
|
8560
9255
|
}
|
|
8561
9256
|
return endMemory;
|
|
@@ -8578,8 +9273,8 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8578
9273
|
let voicePlaying = FaustWebAudioDspVoice.kNoVoice;
|
|
8579
9274
|
let oldestDatePlaying = Number.MAX_VALUE;
|
|
8580
9275
|
for (let i = 0; i < this.fInstance.voices; i++) {
|
|
8581
|
-
|
|
8582
|
-
|
|
9276
|
+
const curNote = this.fVoiceTable[i].fCurNote;
|
|
9277
|
+
const nextNote = this.fVoiceTable[i].fNextNote;
|
|
8583
9278
|
if (curNote === pitch || curNote === FaustWebAudioDspVoice.kLegatoVoice && nextNote === pitch) {
|
|
8584
9279
|
if (this.fVoiceTable[i].fDate < oldestDatePlaying) {
|
|
8585
9280
|
oldestDatePlaying = this.fVoiceTable[i].fDate;
|
|
@@ -8592,7 +9287,10 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8592
9287
|
getFreeVoice() {
|
|
8593
9288
|
for (let voice = 0; voice < this.fInstance.voices; voice++) {
|
|
8594
9289
|
if (this.fVoiceTable[voice].fCurNote === FaustWebAudioDspVoice.kFreeVoice) {
|
|
8595
|
-
return this.allocVoice(
|
|
9290
|
+
return this.allocVoice(
|
|
9291
|
+
voice,
|
|
9292
|
+
FaustWebAudioDspVoice.kActiveVoice
|
|
9293
|
+
);
|
|
8596
9294
|
}
|
|
8597
9295
|
}
|
|
8598
9296
|
let voiceRelease = FaustWebAudioDspVoice.kNoVoice;
|
|
@@ -8611,12 +9309,22 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8611
9309
|
}
|
|
8612
9310
|
}
|
|
8613
9311
|
if (oldestDateRelease !== Number.MAX_VALUE) {
|
|
8614
|
-
console.log(
|
|
8615
|
-
|
|
9312
|
+
console.log(
|
|
9313
|
+
`Steal release voice : voice_date = ${this.fVoiceTable[voiceRelease].fDate} voice = ${voiceRelease}`
|
|
9314
|
+
);
|
|
9315
|
+
return this.allocVoice(
|
|
9316
|
+
voiceRelease,
|
|
9317
|
+
FaustWebAudioDspVoice.kLegatoVoice
|
|
9318
|
+
);
|
|
8616
9319
|
}
|
|
8617
9320
|
if (oldestDatePlaying !== Number.MAX_VALUE) {
|
|
8618
|
-
console.log(
|
|
8619
|
-
|
|
9321
|
+
console.log(
|
|
9322
|
+
`Steal playing voice : voice_date = ${this.fVoiceTable[voicePlaying].fDate} voice = ${voicePlaying}`
|
|
9323
|
+
);
|
|
9324
|
+
return this.allocVoice(
|
|
9325
|
+
voicePlaying,
|
|
9326
|
+
FaustWebAudioDspVoice.kLegatoVoice
|
|
9327
|
+
);
|
|
8620
9328
|
}
|
|
8621
9329
|
return FaustWebAudioDspVoice.kNoVoice;
|
|
8622
9330
|
}
|
|
@@ -8641,21 +9349,54 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8641
9349
|
}
|
|
8642
9350
|
}
|
|
8643
9351
|
if (this.fComputeHandler) this.fComputeHandler(this.fBufferSize);
|
|
8644
|
-
this.fInstance.mixerAPI.clearOutput(
|
|
9352
|
+
this.fInstance.mixerAPI.clearOutput(
|
|
9353
|
+
this.fBufferSize,
|
|
9354
|
+
this.getNumOutputs(),
|
|
9355
|
+
this.fAudioOutputs
|
|
9356
|
+
);
|
|
8645
9357
|
this.fVoiceTable.forEach((voice) => {
|
|
8646
9358
|
if (voice.fCurNote === FaustWebAudioDspVoice.kLegatoVoice) {
|
|
8647
|
-
voice.computeLegato(
|
|
8648
|
-
|
|
8649
|
-
|
|
9359
|
+
voice.computeLegato(
|
|
9360
|
+
this.fBufferSize,
|
|
9361
|
+
this.fAudioInputs,
|
|
9362
|
+
this.fAudioMixing,
|
|
9363
|
+
this.fAudioMixingHalf
|
|
9364
|
+
);
|
|
9365
|
+
this.fInstance.mixerAPI.fadeOut(
|
|
9366
|
+
this.fBufferSize / 2,
|
|
9367
|
+
this.getNumOutputs(),
|
|
9368
|
+
this.fAudioMixing
|
|
9369
|
+
);
|
|
9370
|
+
voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(
|
|
9371
|
+
this.fBufferSize,
|
|
9372
|
+
this.getNumOutputs(),
|
|
9373
|
+
this.fAudioMixing,
|
|
9374
|
+
this.fAudioOutputs
|
|
9375
|
+
);
|
|
8650
9376
|
} else if (voice.fCurNote !== FaustWebAudioDspVoice.kFreeVoice) {
|
|
8651
|
-
voice.compute(
|
|
8652
|
-
|
|
9377
|
+
voice.compute(
|
|
9378
|
+
this.fBufferSize,
|
|
9379
|
+
this.fAudioInputs,
|
|
9380
|
+
this.fAudioMixing
|
|
9381
|
+
);
|
|
9382
|
+
voice.fLevel = this.fInstance.mixerAPI.mixCheckVoice(
|
|
9383
|
+
this.fBufferSize,
|
|
9384
|
+
this.getNumOutputs(),
|
|
9385
|
+
this.fAudioMixing,
|
|
9386
|
+
this.fAudioOutputs
|
|
9387
|
+
);
|
|
8653
9388
|
if (voice.fCurNote == FaustWebAudioDspVoice.kReleaseVoice && voice.fLevel < FaustWebAudioDspVoice.VOICE_STOP_LEVEL) {
|
|
8654
9389
|
voice.fCurNote = FaustWebAudioDspVoice.kFreeVoice;
|
|
8655
9390
|
}
|
|
8656
9391
|
}
|
|
8657
9392
|
});
|
|
8658
|
-
if (this.fInstance.effectAPI)
|
|
9393
|
+
if (this.fInstance.effectAPI)
|
|
9394
|
+
this.fInstance.effectAPI.compute(
|
|
9395
|
+
this.fEffect,
|
|
9396
|
+
this.fBufferSize,
|
|
9397
|
+
this.fAudioOutputs,
|
|
9398
|
+
this.fAudioOutputs
|
|
9399
|
+
);
|
|
8659
9400
|
this.updateOutputs();
|
|
8660
9401
|
if (output !== void 0) {
|
|
8661
9402
|
for (let chan = 0; chan < Math.min(this.getNumOutputs(), output.length); chan++) {
|
|
@@ -8663,7 +9404,11 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8663
9404
|
output[chan].set(dspOutput);
|
|
8664
9405
|
}
|
|
8665
9406
|
if (this.fPlotHandler) {
|
|
8666
|
-
this.fPlotHandler(
|
|
9407
|
+
this.fPlotHandler(
|
|
9408
|
+
output,
|
|
9409
|
+
this.fBufferNum++,
|
|
9410
|
+
this.fCachedEvents.length ? this.fCachedEvents : void 0
|
|
9411
|
+
);
|
|
8667
9412
|
this.fCachedEvents = [];
|
|
8668
9413
|
}
|
|
8669
9414
|
}
|
|
@@ -8688,16 +9433,26 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8688
9433
|
}
|
|
8689
9434
|
}
|
|
8690
9435
|
setParamValue(path, value) {
|
|
8691
|
-
if (this.fPlotHandler)
|
|
9436
|
+
if (this.fPlotHandler)
|
|
9437
|
+
this.fCachedEvents.push({ type: "param", data: { path, value } });
|
|
8692
9438
|
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
8693
|
-
this.fInstance.effectAPI.setParamValue(
|
|
9439
|
+
this.fInstance.effectAPI.setParamValue(
|
|
9440
|
+
this.fEffect,
|
|
9441
|
+
this.fPathTable[path],
|
|
9442
|
+
value
|
|
9443
|
+
);
|
|
8694
9444
|
} else {
|
|
8695
|
-
this.fVoiceTable.forEach(
|
|
9445
|
+
this.fVoiceTable.forEach(
|
|
9446
|
+
(voice) => voice.setParamValue(this.fPathTable[path], value)
|
|
9447
|
+
);
|
|
8696
9448
|
}
|
|
8697
9449
|
}
|
|
8698
9450
|
getParamValue(path) {
|
|
8699
9451
|
if (this.fJSONEffect && _FaustPolyWebAudioDsp.findPath(this.fJSONEffect.ui, path) && this.fInstance.effectAPI) {
|
|
8700
|
-
return this.fInstance.effectAPI.getParamValue(
|
|
9452
|
+
return this.fInstance.effectAPI.getParamValue(
|
|
9453
|
+
this.fEffect,
|
|
9454
|
+
this.fPathTable[path]
|
|
9455
|
+
);
|
|
8701
9456
|
} else {
|
|
8702
9457
|
return this.fVoiceTable[0].getParamValue(this.fPathTable[path]);
|
|
8703
9458
|
}
|
|
@@ -8707,22 +9462,24 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8707
9462
|
const e = this.fJSONEffect;
|
|
8708
9463
|
const r = { ...o };
|
|
8709
9464
|
if (e) {
|
|
8710
|
-
r.ui = [
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
9465
|
+
r.ui = [
|
|
9466
|
+
{
|
|
9467
|
+
type: "tgroup",
|
|
9468
|
+
label: "Sequencer",
|
|
9469
|
+
items: [
|
|
9470
|
+
{ type: "vgroup", label: "Instrument", items: o.ui },
|
|
9471
|
+
{ type: "vgroup", label: "Effect", items: e.ui }
|
|
9472
|
+
]
|
|
9473
|
+
}
|
|
9474
|
+
];
|
|
8718
9475
|
} else {
|
|
8719
|
-
r.ui = [
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
{ type: "vgroup", label: "Voices", items: o.ui }
|
|
8724
|
-
|
|
8725
|
-
|
|
9476
|
+
r.ui = [
|
|
9477
|
+
{
|
|
9478
|
+
type: "tgroup",
|
|
9479
|
+
label: "Polyphonic",
|
|
9480
|
+
items: [{ type: "vgroup", label: "Voices", items: o.ui }]
|
|
9481
|
+
}
|
|
9482
|
+
];
|
|
8726
9483
|
}
|
|
8727
9484
|
return r;
|
|
8728
9485
|
}
|
|
@@ -8740,7 +9497,8 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8740
9497
|
const channel = data[0] & 15;
|
|
8741
9498
|
const data1 = data[1];
|
|
8742
9499
|
const data2 = data[2];
|
|
8743
|
-
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
9500
|
+
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
9501
|
+
return this.keyOff(channel, data1, data2);
|
|
8744
9502
|
else if (cmd === 9) return this.keyOn(channel, data1, data2);
|
|
8745
9503
|
else super.midiMessage(data);
|
|
8746
9504
|
}
|
|
@@ -8752,12 +9510,24 @@ var FaustPolyWebAudioDsp = class _FaustPolyWebAudioDsp extends FaustBaseWebAudio
|
|
|
8752
9510
|
}
|
|
8753
9511
|
}
|
|
8754
9512
|
keyOn(channel, pitch, velocity) {
|
|
8755
|
-
if (this.fPlotHandler)
|
|
9513
|
+
if (this.fPlotHandler)
|
|
9514
|
+
this.fCachedEvents.push({
|
|
9515
|
+
type: "keyOn",
|
|
9516
|
+
data: [channel, pitch, velocity]
|
|
9517
|
+
});
|
|
8756
9518
|
const voice = this.getFreeVoice();
|
|
8757
|
-
this.fVoiceTable[voice].keyOn(
|
|
9519
|
+
this.fVoiceTable[voice].keyOn(
|
|
9520
|
+
pitch,
|
|
9521
|
+
velocity,
|
|
9522
|
+
this.fVoiceTable[voice].fCurNote == FaustWebAudioDspVoice.kLegatoVoice
|
|
9523
|
+
);
|
|
8758
9524
|
}
|
|
8759
9525
|
keyOff(channel, pitch, velocity) {
|
|
8760
|
-
if (this.fPlotHandler)
|
|
9526
|
+
if (this.fPlotHandler)
|
|
9527
|
+
this.fCachedEvents.push({
|
|
9528
|
+
type: "keyOff",
|
|
9529
|
+
data: [channel, pitch, velocity]
|
|
9530
|
+
});
|
|
8761
9531
|
const voice = this.getPlayingVoice(pitch);
|
|
8762
9532
|
if (voice !== FaustWebAudioDspVoice.kNoVoice) {
|
|
8763
9533
|
this.fVoiceTable[voice].keyOff();
|
|
@@ -8784,13 +9554,30 @@ var FaustOfflineProcessor = class {
|
|
|
8784
9554
|
const params = [];
|
|
8785
9555
|
const callback = (item) => {
|
|
8786
9556
|
let param = null;
|
|
8787
|
-
const polyKeywords = [
|
|
9557
|
+
const polyKeywords = [
|
|
9558
|
+
"/gate",
|
|
9559
|
+
"/freq",
|
|
9560
|
+
"/gain",
|
|
9561
|
+
"/key",
|
|
9562
|
+
"/vel",
|
|
9563
|
+
"/velocity"
|
|
9564
|
+
];
|
|
8788
9565
|
const isPolyReserved = "address" in item && !!polyKeywords.find((k) => item.address.endsWith(k));
|
|
8789
9566
|
if (this.fDSPCode instanceof FaustMonoWebAudioDsp || !isPolyReserved) {
|
|
8790
9567
|
if (item.type === "vslider" || item.type === "hslider" || item.type === "nentry") {
|
|
8791
|
-
param = {
|
|
9568
|
+
param = {
|
|
9569
|
+
name: item.address,
|
|
9570
|
+
defaultValue: item.init || 0,
|
|
9571
|
+
minValue: item.min || 0,
|
|
9572
|
+
maxValue: item.max || 0
|
|
9573
|
+
};
|
|
8792
9574
|
} else if (item.type === "button" || item.type === "checkbox") {
|
|
8793
|
-
param = {
|
|
9575
|
+
param = {
|
|
9576
|
+
name: item.address,
|
|
9577
|
+
defaultValue: item.init || 0,
|
|
9578
|
+
minValue: 0,
|
|
9579
|
+
maxValue: 1
|
|
9580
|
+
};
|
|
8794
9581
|
}
|
|
8795
9582
|
}
|
|
8796
9583
|
if (param) params.push(param);
|
|
@@ -8963,11 +9750,19 @@ var FaustSvgDiagrams = class {
|
|
|
8963
9750
|
files2.filter((file) => file !== "." && file !== "..").forEach((file) => fs.unlink(`/${name}-svg/${file}`));
|
|
8964
9751
|
} catch {
|
|
8965
9752
|
}
|
|
8966
|
-
const success = this.compiler.generateAuxFiles(
|
|
9753
|
+
const success = this.compiler.generateAuxFiles(
|
|
9754
|
+
name,
|
|
9755
|
+
code,
|
|
9756
|
+
`-lang wasm -o binary -svg ${args}`
|
|
9757
|
+
);
|
|
8967
9758
|
if (!success) throw new Error(this.compiler.getErrorMessage());
|
|
8968
9759
|
const svgs = {};
|
|
8969
9760
|
const files = fs.readdir(`/${name}-svg/`);
|
|
8970
|
-
files.filter((file) => file !== "." && file !== "..").forEach(
|
|
9761
|
+
files.filter((file) => file !== "." && file !== "..").forEach(
|
|
9762
|
+
(file) => svgs[file] = fs.readFile(`/${name}-svg/${file}`, {
|
|
9763
|
+
encoding: "utf8"
|
|
9764
|
+
})
|
|
9765
|
+
);
|
|
8971
9766
|
return svgs;
|
|
8972
9767
|
}
|
|
8973
9768
|
};
|
|
@@ -8980,7 +9775,11 @@ var FaustCmajor = class {
|
|
|
8980
9775
|
}
|
|
8981
9776
|
compile(name, code, args) {
|
|
8982
9777
|
const fs = this.fCompiler.fs();
|
|
8983
|
-
const success = this.fCompiler.generateAuxFiles(
|
|
9778
|
+
const success = this.fCompiler.generateAuxFiles(
|
|
9779
|
+
name,
|
|
9780
|
+
code,
|
|
9781
|
+
`-lang cmajor-hybrid -cn ${name} -o ${name}.cmajor`
|
|
9782
|
+
);
|
|
8984
9783
|
return success ? fs.readFile(`${name}.cmajor`, { encoding: "utf8" }) : "";
|
|
8985
9784
|
}
|
|
8986
9785
|
};
|
|
@@ -9003,7 +9802,12 @@ var LibFaust = class {
|
|
|
9003
9802
|
return this.fCompiler.version();
|
|
9004
9803
|
}
|
|
9005
9804
|
createDSPFactory(name, code, args, useInternalMemory) {
|
|
9006
|
-
return this.fCompiler.createDSPFactory(
|
|
9805
|
+
return this.fCompiler.createDSPFactory(
|
|
9806
|
+
name,
|
|
9807
|
+
code,
|
|
9808
|
+
args,
|
|
9809
|
+
useInternalMemory
|
|
9810
|
+
);
|
|
9007
9811
|
}
|
|
9008
9812
|
deleteDSPFactory(cFactory) {
|
|
9009
9813
|
return this.fCompiler.deleteDSPFactory(cFactory);
|
|
@@ -9060,7 +9864,14 @@ var WavEncoder = class {
|
|
|
9060
9864
|
return ab;
|
|
9061
9865
|
}
|
|
9062
9866
|
static writeHeader(writer, format) {
|
|
9063
|
-
const {
|
|
9867
|
+
const {
|
|
9868
|
+
formatId,
|
|
9869
|
+
sampleRate,
|
|
9870
|
+
bitDepth,
|
|
9871
|
+
numberOfChannels,
|
|
9872
|
+
length,
|
|
9873
|
+
byteDepth
|
|
9874
|
+
} = format;
|
|
9064
9875
|
writer.string("RIFF");
|
|
9065
9876
|
writer.uint32(writer.dataView.byteLength - 8);
|
|
9066
9877
|
writer.string("WAVE");
|
|
@@ -9099,7 +9910,9 @@ var WavEncoder = class {
|
|
|
9099
9910
|
if (!writer[methodName]) {
|
|
9100
9911
|
throw new TypeError("Not supported bit depth: " + bitDepth);
|
|
9101
9912
|
}
|
|
9102
|
-
const write = writer[methodName].bind(
|
|
9913
|
+
const write = writer[methodName].bind(
|
|
9914
|
+
writer
|
|
9915
|
+
);
|
|
9103
9916
|
for (let i = 0; i < length; i++) {
|
|
9104
9917
|
for (let j = 0; j < numberOfChannels; j++) {
|
|
9105
9918
|
write(audioBuffer[j][i]);
|
|
@@ -9234,7 +10047,12 @@ var WavDecoder = class {
|
|
|
9234
10047
|
if (chunkType === "fmt ") {
|
|
9235
10048
|
format = this.decodeFormat(reader, chunkSize);
|
|
9236
10049
|
} else if (chunkType === "data") {
|
|
9237
|
-
audioData = this.decodeData(
|
|
10050
|
+
audioData = this.decodeData(
|
|
10051
|
+
reader,
|
|
10052
|
+
chunkSize,
|
|
10053
|
+
format,
|
|
10054
|
+
options || {}
|
|
10055
|
+
);
|
|
9238
10056
|
} else {
|
|
9239
10057
|
reader.skip(chunkSize);
|
|
9240
10058
|
}
|
|
@@ -9247,8 +10065,10 @@ var WavDecoder = class {
|
|
|
9247
10065
|
3: "lpcm"
|
|
9248
10066
|
};
|
|
9249
10067
|
const formatId = reader.uint16();
|
|
9250
|
-
if (!
|
|
9251
|
-
throw new TypeError(
|
|
10068
|
+
if (!Object.prototype.hasOwnProperty.call(formats, formatId)) {
|
|
10069
|
+
throw new TypeError(
|
|
10070
|
+
"Unsupported format in WAV file: 0x" + formatId.toString(16)
|
|
10071
|
+
);
|
|
9252
10072
|
}
|
|
9253
10073
|
const format = {
|
|
9254
10074
|
formatId,
|
|
@@ -9400,7 +10220,11 @@ var WavDecoder_default = WavDecoder;
|
|
|
9400
10220
|
var SoundfileReader = class {
|
|
9401
10221
|
// Set the fallback paths
|
|
9402
10222
|
static get fallbackPaths() {
|
|
9403
|
-
return [
|
|
10223
|
+
return [
|
|
10224
|
+
location.href,
|
|
10225
|
+
this.getParentUrl(location.href),
|
|
10226
|
+
location.origin
|
|
10227
|
+
];
|
|
9404
10228
|
}
|
|
9405
10229
|
/**
|
|
9406
10230
|
* Extract the parent URL from an URL.
|
|
@@ -9412,7 +10236,7 @@ var SoundfileReader = class {
|
|
|
9412
10236
|
}
|
|
9413
10237
|
/**
|
|
9414
10238
|
* Convert an audio buffer to audio data.
|
|
9415
|
-
*
|
|
10239
|
+
*
|
|
9416
10240
|
* @param audioBuffer : the audio buffer to convert
|
|
9417
10241
|
* @returns : the audio data
|
|
9418
10242
|
*/
|
|
@@ -9425,7 +10249,7 @@ var SoundfileReader = class {
|
|
|
9425
10249
|
}
|
|
9426
10250
|
/**
|
|
9427
10251
|
* Extract the URLs from the metadata.
|
|
9428
|
-
*
|
|
10252
|
+
*
|
|
9429
10253
|
* @param dspMeta : the metadata
|
|
9430
10254
|
* @returns : the URLs
|
|
9431
10255
|
*/
|
|
@@ -9442,7 +10266,7 @@ var SoundfileReader = class {
|
|
|
9442
10266
|
}
|
|
9443
10267
|
/**
|
|
9444
10268
|
* Check if the file exists.
|
|
9445
|
-
*
|
|
10269
|
+
*
|
|
9446
10270
|
* @param url : the url of the file to check
|
|
9447
10271
|
* @returns : true if the file exists, otherwise false
|
|
9448
10272
|
*/
|
|
@@ -9459,7 +10283,7 @@ var SoundfileReader = class {
|
|
|
9459
10283
|
}
|
|
9460
10284
|
/**
|
|
9461
10285
|
* Fetch the soundfile.
|
|
9462
|
-
*
|
|
10286
|
+
*
|
|
9463
10287
|
* @param url : the url of the soundfile
|
|
9464
10288
|
* @param audioCtx : the audio context
|
|
9465
10289
|
* @returns : the audio data
|
|
@@ -9467,14 +10291,17 @@ var SoundfileReader = class {
|
|
|
9467
10291
|
static async fetchSoundfile(url, audioCtx) {
|
|
9468
10292
|
console.log(`Loading sound file from ${url}`);
|
|
9469
10293
|
const response = await fetch(url);
|
|
9470
|
-
if (!response.ok)
|
|
10294
|
+
if (!response.ok)
|
|
10295
|
+
throw new Error(
|
|
10296
|
+
`Failed to load sound file from ${url}: ${response.statusText}`
|
|
10297
|
+
);
|
|
9471
10298
|
const arrayBuffer = await response.arrayBuffer();
|
|
9472
10299
|
const audioBuffer = await audioCtx.decodeAudioData(arrayBuffer);
|
|
9473
10300
|
return this.toAudioData(audioBuffer);
|
|
9474
10301
|
}
|
|
9475
10302
|
/**
|
|
9476
10303
|
* Load the soundfile.
|
|
9477
|
-
*
|
|
10304
|
+
*
|
|
9478
10305
|
* @param filename : the filename
|
|
9479
10306
|
* @param metaUrls : the metadata URLs
|
|
9480
10307
|
* @param soundfiles : the soundfiles
|
|
@@ -9482,15 +10309,28 @@ var SoundfileReader = class {
|
|
|
9482
10309
|
*/
|
|
9483
10310
|
static async loadSoundfile(filename, metaUrls, soundfiles, audioCtx) {
|
|
9484
10311
|
if (soundfiles == null ? void 0 : soundfiles[filename]) return;
|
|
9485
|
-
const urlsToCheck = [
|
|
9486
|
-
|
|
10312
|
+
const urlsToCheck = [
|
|
10313
|
+
filename,
|
|
10314
|
+
...[...metaUrls, ...this.fallbackPaths].map(
|
|
10315
|
+
(path) => new URL(filename, path.endsWith("/") ? path : `${path}/`).href
|
|
10316
|
+
)
|
|
10317
|
+
];
|
|
10318
|
+
const checkResults = await Promise.all(
|
|
10319
|
+
urlsToCheck.map((url) => this.checkFileExists(url))
|
|
10320
|
+
);
|
|
9487
10321
|
const successIndex = checkResults.findIndex((r) => !!r);
|
|
9488
|
-
if (successIndex === -1)
|
|
9489
|
-
|
|
10322
|
+
if (successIndex === -1)
|
|
10323
|
+
throw new Error(
|
|
10324
|
+
`Failed to load sound file ${filename}, all check failed.`
|
|
10325
|
+
);
|
|
10326
|
+
soundfiles[filename] = await this.fetchSoundfile(
|
|
10327
|
+
urlsToCheck[successIndex],
|
|
10328
|
+
audioCtx
|
|
10329
|
+
);
|
|
9490
10330
|
}
|
|
9491
10331
|
/**
|
|
9492
10332
|
* Load the soundfiles, public API.
|
|
9493
|
-
*
|
|
10333
|
+
*
|
|
9494
10334
|
* @param dspMeta : the metadata
|
|
9495
10335
|
* @param soundfilesIn : the soundfiles
|
|
9496
10336
|
* @param audioCtx : the audio context
|
|
@@ -9531,7 +10371,6 @@ var FaustAudioWorkletCommunicator = class {
|
|
|
9531
10371
|
this.uin8NewGyrData = new Uint8ClampedArray(ab, ptr, 1);
|
|
9532
10372
|
ptr += Uint8ClampedArray.BYTES_PER_ELEMENT;
|
|
9533
10373
|
ptr += Uint8ClampedArray.BYTES_PER_ELEMENT;
|
|
9534
|
-
;
|
|
9535
10374
|
this.f32Acc = new Float32Array(ab, ptr, 3);
|
|
9536
10375
|
ptr += 3 * Float32Array.BYTES_PER_ELEMENT;
|
|
9537
10376
|
this.f32Gyr = new Float32Array(ab, ptr, 3);
|
|
@@ -9571,7 +10410,11 @@ var FaustAudioWorkletCommunicator = class {
|
|
|
9571
10410
|
const [x, y, z] = this.f32Acc;
|
|
9572
10411
|
return { x, y, z, invert };
|
|
9573
10412
|
}
|
|
9574
|
-
setGyr({
|
|
10413
|
+
setGyr({
|
|
10414
|
+
alpha,
|
|
10415
|
+
beta,
|
|
10416
|
+
gamma
|
|
10417
|
+
}) {
|
|
9575
10418
|
if (!this.supportSharedArrayBuffer) {
|
|
9576
10419
|
const e = { type: "gyr", data: { alpha, beta, gamma } };
|
|
9577
10420
|
this.port.postMessage(e);
|
|
@@ -9659,13 +10502,19 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9659
10502
|
}
|
|
9660
10503
|
};
|
|
9661
10504
|
// Accelerometer and gyroscope handlers
|
|
9662
|
-
this.handleDeviceMotion = ({
|
|
10505
|
+
this.handleDeviceMotion = ({
|
|
10506
|
+
accelerationIncludingGravity
|
|
10507
|
+
}) => {
|
|
9663
10508
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9664
10509
|
if (!accelerationIncludingGravity) return;
|
|
9665
10510
|
const { x, y, z } = accelerationIncludingGravity;
|
|
9666
10511
|
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9667
10512
|
};
|
|
9668
|
-
this.handleDeviceOrientation = ({
|
|
10513
|
+
this.handleDeviceOrientation = ({
|
|
10514
|
+
alpha,
|
|
10515
|
+
beta,
|
|
10516
|
+
gamma
|
|
10517
|
+
}) => {
|
|
9669
10518
|
this.propagateGyr({ alpha, beta, gamma });
|
|
9670
10519
|
};
|
|
9671
10520
|
this.fJSONDsp = JSONObj;
|
|
@@ -9697,14 +10546,22 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9697
10546
|
async startSensors() {
|
|
9698
10547
|
if (this.hasAccInput) {
|
|
9699
10548
|
if (window.DeviceMotionEvent) {
|
|
9700
|
-
window.addEventListener(
|
|
10549
|
+
window.addEventListener(
|
|
10550
|
+
"devicemotion",
|
|
10551
|
+
this.handleDeviceMotion,
|
|
10552
|
+
true
|
|
10553
|
+
);
|
|
9701
10554
|
} else {
|
|
9702
10555
|
console.log("Cannot set the accelerometer handler.");
|
|
9703
10556
|
}
|
|
9704
10557
|
}
|
|
9705
10558
|
if (this.hasGyrInput) {
|
|
9706
10559
|
if (window.DeviceMotionEvent) {
|
|
9707
|
-
window.addEventListener(
|
|
10560
|
+
window.addEventListener(
|
|
10561
|
+
"deviceorientation",
|
|
10562
|
+
this.handleDeviceOrientation,
|
|
10563
|
+
true
|
|
10564
|
+
);
|
|
9708
10565
|
} else {
|
|
9709
10566
|
console.log("Cannot set the gyroscope handler.");
|
|
9710
10567
|
}
|
|
@@ -9712,10 +10569,18 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9712
10569
|
}
|
|
9713
10570
|
stopSensors() {
|
|
9714
10571
|
if (this.hasAccInput) {
|
|
9715
|
-
window.removeEventListener(
|
|
10572
|
+
window.removeEventListener(
|
|
10573
|
+
"devicemotion",
|
|
10574
|
+
this.handleDeviceMotion,
|
|
10575
|
+
true
|
|
10576
|
+
);
|
|
9716
10577
|
}
|
|
9717
10578
|
if (this.hasGyrInput) {
|
|
9718
|
-
window.removeEventListener(
|
|
10579
|
+
window.removeEventListener(
|
|
10580
|
+
"deviceorientation",
|
|
10581
|
+
this.handleDeviceOrientation,
|
|
10582
|
+
true
|
|
10583
|
+
);
|
|
9719
10584
|
}
|
|
9720
10585
|
}
|
|
9721
10586
|
setOutputParamHandler(handler) {
|
|
@@ -9763,7 +10628,9 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9763
10628
|
}
|
|
9764
10629
|
metadata(handler) {
|
|
9765
10630
|
if (this.fJSONDsp.meta) {
|
|
9766
|
-
this.fJSONDsp.meta.forEach(
|
|
10631
|
+
this.fJSONDsp.meta.forEach(
|
|
10632
|
+
(meta) => handler(Object.keys(meta)[0], meta[Object.keys(meta)[0]])
|
|
10633
|
+
);
|
|
9767
10634
|
}
|
|
9768
10635
|
}
|
|
9769
10636
|
midiMessage(data) {
|
|
@@ -9773,7 +10640,8 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9773
10640
|
const data2 = data[2];
|
|
9774
10641
|
if (cmd === 11) this.ctrlChange(channel, data1, data2);
|
|
9775
10642
|
else if (cmd === 14) this.pitchWheel(channel, data2 * 128 + data1);
|
|
9776
|
-
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
10643
|
+
if (cmd === 8 || cmd === 9 && data2 === 0)
|
|
10644
|
+
this.keyOff(channel, data1, data2);
|
|
9777
10645
|
else if (cmd === 9) this.keyOn(channel, data1, data2);
|
|
9778
10646
|
else this.port.postMessage({ type: "midi", data });
|
|
9779
10647
|
}
|
|
@@ -9807,7 +10675,11 @@ var FaustAudioWorkletNode = class extends (globalThis.AudioWorkletNode || null)
|
|
|
9807
10675
|
propagateGyr(event) {
|
|
9808
10676
|
if (!event) return;
|
|
9809
10677
|
const { alpha, beta, gamma } = event;
|
|
9810
|
-
this.fCommunicator.setGyr({
|
|
10678
|
+
this.fCommunicator.setGyr({
|
|
10679
|
+
alpha,
|
|
10680
|
+
beta,
|
|
10681
|
+
gamma
|
|
10682
|
+
});
|
|
9811
10683
|
}
|
|
9812
10684
|
setParamValue(path, value) {
|
|
9813
10685
|
const e = { type: "param", data: { path, value } };
|
|
@@ -9849,7 +10721,12 @@ _hasAccInput = new WeakMap();
|
|
|
9849
10721
|
_hasGyrInput = new WeakMap();
|
|
9850
10722
|
var FaustMonoAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
9851
10723
|
constructor(context, options) {
|
|
9852
|
-
super(
|
|
10724
|
+
super(
|
|
10725
|
+
context,
|
|
10726
|
+
options.processorOptions.name,
|
|
10727
|
+
options.processorOptions.factory,
|
|
10728
|
+
options
|
|
10729
|
+
);
|
|
9853
10730
|
this.onprocessorerror = (e) => {
|
|
9854
10731
|
throw e;
|
|
9855
10732
|
};
|
|
@@ -9889,22 +10766,24 @@ var FaustPolyAudioWorkletNode = class extends FaustAudioWorkletNode {
|
|
|
9889
10766
|
const e = this.fJSONEffect;
|
|
9890
10767
|
const r = { ...o };
|
|
9891
10768
|
if (e) {
|
|
9892
|
-
r.ui = [
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
10769
|
+
r.ui = [
|
|
10770
|
+
{
|
|
10771
|
+
type: "tgroup",
|
|
10772
|
+
label: "Sequencer",
|
|
10773
|
+
items: [
|
|
10774
|
+
{ type: "vgroup", label: "Instrument", items: o.ui },
|
|
10775
|
+
{ type: "vgroup", label: "Effect", items: e.ui }
|
|
10776
|
+
]
|
|
10777
|
+
}
|
|
10778
|
+
];
|
|
9900
10779
|
} else {
|
|
9901
|
-
r.ui = [
|
|
9902
|
-
|
|
9903
|
-
|
|
9904
|
-
|
|
9905
|
-
{ type: "vgroup", label: "Voices", items: o.ui }
|
|
9906
|
-
|
|
9907
|
-
|
|
10780
|
+
r.ui = [
|
|
10781
|
+
{
|
|
10782
|
+
type: "tgroup",
|
|
10783
|
+
label: "Polyphonic",
|
|
10784
|
+
items: [{ type: "vgroup", label: "Voices", items: o.ui }]
|
|
10785
|
+
}
|
|
10786
|
+
];
|
|
9908
10787
|
}
|
|
9909
10788
|
return r;
|
|
9910
10789
|
}
|
|
@@ -9927,13 +10806,19 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
9927
10806
|
this.fDSPCode = instance;
|
|
9928
10807
|
this.fInputs = new Array(this.fDSPCode.getNumInputs());
|
|
9929
10808
|
this.fOutputs = new Array(this.fDSPCode.getNumOutputs());
|
|
9930
|
-
this.handleDeviceMotion = ({
|
|
10809
|
+
this.handleDeviceMotion = ({
|
|
10810
|
+
accelerationIncludingGravity
|
|
10811
|
+
}) => {
|
|
9931
10812
|
const isAndroid = /Android/i.test(navigator.userAgent);
|
|
9932
10813
|
if (!accelerationIncludingGravity) return;
|
|
9933
10814
|
const { x, y, z } = accelerationIncludingGravity;
|
|
9934
10815
|
this.propagateAcc({ x, y, z }, isAndroid);
|
|
9935
10816
|
};
|
|
9936
|
-
this.handleDeviceOrientation = ({
|
|
10817
|
+
this.handleDeviceOrientation = ({
|
|
10818
|
+
alpha,
|
|
10819
|
+
beta,
|
|
10820
|
+
gamma
|
|
10821
|
+
}) => {
|
|
9937
10822
|
this.propagateGyr({ alpha, beta, gamma });
|
|
9938
10823
|
};
|
|
9939
10824
|
this.onaudioprocess = (e) => {
|
|
@@ -9952,14 +10837,22 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
9952
10837
|
async startSensors() {
|
|
9953
10838
|
if (this.hasAccInput) {
|
|
9954
10839
|
if (window.DeviceMotionEvent) {
|
|
9955
|
-
window.addEventListener(
|
|
10840
|
+
window.addEventListener(
|
|
10841
|
+
"devicemotion",
|
|
10842
|
+
this.handleDeviceMotion,
|
|
10843
|
+
true
|
|
10844
|
+
);
|
|
9956
10845
|
} else {
|
|
9957
10846
|
console.log("Cannot set the accelerometer handler.");
|
|
9958
10847
|
}
|
|
9959
10848
|
}
|
|
9960
10849
|
if (this.hasGyrInput) {
|
|
9961
10850
|
if (window.DeviceMotionEvent) {
|
|
9962
|
-
window.addEventListener(
|
|
10851
|
+
window.addEventListener(
|
|
10852
|
+
"deviceorientation",
|
|
10853
|
+
this.handleDeviceOrientation,
|
|
10854
|
+
true
|
|
10855
|
+
);
|
|
9963
10856
|
} else {
|
|
9964
10857
|
console.log("Cannot set the gyroscope handler.");
|
|
9965
10858
|
}
|
|
@@ -9968,10 +10861,18 @@ var FaustScriptProcessorNode = class extends (globalThis.ScriptProcessorNode ||
|
|
|
9968
10861
|
/** Stop accelerometer and gyroscope handlers */
|
|
9969
10862
|
stopSensors() {
|
|
9970
10863
|
if (this.hasAccInput) {
|
|
9971
|
-
window.removeEventListener(
|
|
10864
|
+
window.removeEventListener(
|
|
10865
|
+
"devicemotion",
|
|
10866
|
+
this.handleDeviceMotion,
|
|
10867
|
+
true
|
|
10868
|
+
);
|
|
9972
10869
|
}
|
|
9973
10870
|
if (this.hasGyrInput) {
|
|
9974
|
-
window.removeEventListener(
|
|
10871
|
+
window.removeEventListener(
|
|
10872
|
+
"deviceorientation",
|
|
10873
|
+
this.handleDeviceOrientation,
|
|
10874
|
+
true
|
|
10875
|
+
);
|
|
9975
10876
|
}
|
|
9976
10877
|
}
|
|
9977
10878
|
compute(input, output) {
|
|
@@ -10093,13 +10994,19 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
|
10093
10994
|
}
|
|
10094
10995
|
}
|
|
10095
10996
|
addSoundfiles(soundfileMap) {
|
|
10096
|
-
if (!this.factory)
|
|
10997
|
+
if (!this.factory)
|
|
10998
|
+
throw new Error(
|
|
10999
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11000
|
+
);
|
|
10097
11001
|
for (const id in soundfileMap) {
|
|
10098
11002
|
this.factory.soundfiles[id] = soundfileMap[id];
|
|
10099
11003
|
}
|
|
10100
11004
|
}
|
|
10101
11005
|
getSoundfileList() {
|
|
10102
|
-
if (!this.factory)
|
|
11006
|
+
if (!this.factory)
|
|
11007
|
+
throw new Error(
|
|
11008
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11009
|
+
);
|
|
10103
11010
|
const meta = JSON.parse(this.factory.json);
|
|
10104
11011
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
10105
11012
|
if (!map) return [];
|
|
@@ -10107,19 +11014,40 @@ var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
|
|
|
10107
11014
|
}
|
|
10108
11015
|
async createNode(context, name = this.name, factory = this.factory, sp = false, bufferSize = 1024, processorName = (factory == null ? void 0 : factory.shaKey) || name, processorOptions = {}) {
|
|
10109
11016
|
var _a, _b;
|
|
10110
|
-
if (!factory)
|
|
11017
|
+
if (!factory)
|
|
11018
|
+
throw new Error(
|
|
11019
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11020
|
+
);
|
|
10111
11021
|
const meta = JSON.parse(factory.json);
|
|
10112
11022
|
const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
10113
|
-
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11023
|
+
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11024
|
+
meta,
|
|
11025
|
+
factory.soundfiles || {},
|
|
11026
|
+
context
|
|
11027
|
+
);
|
|
10114
11028
|
if (sp) {
|
|
10115
11029
|
const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
|
|
10116
|
-
const monoDsp = new FaustMonoWebAudioDsp(
|
|
10117
|
-
|
|
11030
|
+
const monoDsp = new FaustMonoWebAudioDsp(
|
|
11031
|
+
instance,
|
|
11032
|
+
context.sampleRate,
|
|
11033
|
+
sampleSize,
|
|
11034
|
+
bufferSize,
|
|
11035
|
+
factory.soundfiles
|
|
11036
|
+
);
|
|
11037
|
+
const sp2 = context.createScriptProcessor(
|
|
11038
|
+
bufferSize,
|
|
11039
|
+
monoDsp.getNumInputs(),
|
|
11040
|
+
monoDsp.getNumOutputs()
|
|
11041
|
+
);
|
|
10118
11042
|
Object.setPrototypeOf(sp2, FaustMonoScriptProcessorNode.prototype);
|
|
10119
11043
|
sp2.init(monoDsp);
|
|
10120
11044
|
return sp2;
|
|
10121
11045
|
} else {
|
|
10122
|
-
if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
|
|
11046
|
+
if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
|
|
11047
|
+
_FaustMonoDspGenerator.gWorkletProcessors.set(
|
|
11048
|
+
context,
|
|
11049
|
+
/* @__PURE__ */ new Set()
|
|
11050
|
+
);
|
|
10123
11051
|
if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
|
|
10124
11052
|
try {
|
|
10125
11053
|
const processorCode = `
|
|
@@ -10159,24 +11087,41 @@ const dependencies = {
|
|
|
10159
11087
|
// Generate the actual AudioWorkletProcessor code
|
|
10160
11088
|
(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
10161
11089
|
`;
|
|
10162
|
-
const url = URL.createObjectURL(
|
|
11090
|
+
const url = URL.createObjectURL(
|
|
11091
|
+
new Blob([processorCode], { type: "text/javascript" })
|
|
11092
|
+
);
|
|
10163
11093
|
await context.audioWorklet.addModule(url);
|
|
10164
11094
|
(_b = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _b.add(processorName);
|
|
10165
11095
|
} catch (e) {
|
|
10166
11096
|
throw e;
|
|
10167
11097
|
}
|
|
10168
11098
|
}
|
|
10169
|
-
const node = new FaustMonoAudioWorkletNode(context, {
|
|
11099
|
+
const node = new FaustMonoAudioWorkletNode(context, {
|
|
11100
|
+
processorOptions: {
|
|
11101
|
+
name: processorName,
|
|
11102
|
+
factory,
|
|
11103
|
+
sampleSize,
|
|
11104
|
+
...processorOptions
|
|
11105
|
+
}
|
|
11106
|
+
});
|
|
10170
11107
|
return node;
|
|
10171
11108
|
}
|
|
10172
11109
|
}
|
|
10173
11110
|
async createFFTNode(context, fftUtils, name = this.name, factory = this.factory, fftOptions = {}, processorName = (factory == null ? void 0 : factory.shaKey) ? `${factory.shaKey}_fft` : name, processorOptions = {}) {
|
|
10174
11111
|
var _a, _b;
|
|
10175
|
-
if (!factory)
|
|
11112
|
+
if (!factory)
|
|
11113
|
+
throw new Error(
|
|
11114
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11115
|
+
);
|
|
10176
11116
|
const meta = JSON.parse(factory.json);
|
|
10177
11117
|
const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
10178
|
-
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
10179
|
-
|
|
11118
|
+
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11119
|
+
meta,
|
|
11120
|
+
factory.soundfiles || {},
|
|
11121
|
+
context
|
|
11122
|
+
);
|
|
11123
|
+
if (!_FaustMonoDspGenerator.gWorkletProcessors.has(context))
|
|
11124
|
+
_FaustMonoDspGenerator.gWorkletProcessors.set(context, /* @__PURE__ */ new Set());
|
|
10180
11125
|
if (!((_a = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
|
|
10181
11126
|
try {
|
|
10182
11127
|
const processorCode = `
|
|
@@ -10218,14 +11163,25 @@ const dependencies = {
|
|
|
10218
11163
|
// Generate the actual AudioWorkletProcessor code
|
|
10219
11164
|
(${FaustFFTAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
10220
11165
|
`;
|
|
10221
|
-
const url = URL.createObjectURL(
|
|
11166
|
+
const url = URL.createObjectURL(
|
|
11167
|
+
new Blob([processorCode], { type: "text/javascript" })
|
|
11168
|
+
);
|
|
10222
11169
|
await context.audioWorklet.addModule(url);
|
|
10223
11170
|
(_b = _FaustMonoDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _b.add(processorName);
|
|
10224
11171
|
} catch (e) {
|
|
10225
11172
|
throw e;
|
|
10226
11173
|
}
|
|
10227
11174
|
}
|
|
10228
|
-
const node = new FaustMonoAudioWorkletNode(context, {
|
|
11175
|
+
const node = new FaustMonoAudioWorkletNode(context, {
|
|
11176
|
+
channelCount: Math.max(1, Math.ceil(meta.inputs / 3)),
|
|
11177
|
+
outputChannelCount: [Math.ceil(meta.outputs / 2)],
|
|
11178
|
+
processorOptions: {
|
|
11179
|
+
name: processorName,
|
|
11180
|
+
factory,
|
|
11181
|
+
sampleSize,
|
|
11182
|
+
...processorOptions
|
|
11183
|
+
}
|
|
11184
|
+
});
|
|
10229
11185
|
if (fftOptions.fftSize) {
|
|
10230
11186
|
const param = node.parameters.get("fftSize");
|
|
10231
11187
|
if (param) param.value = fftOptions.fftSize;
|
|
@@ -10245,7 +11201,10 @@ const dependencies = {
|
|
|
10245
11201
|
return node;
|
|
10246
11202
|
}
|
|
10247
11203
|
async createAudioWorkletProcessor(name = this.name, factory = this.factory, processorName = (factory == null ? void 0 : factory.shaKey) || name) {
|
|
10248
|
-
if (!factory)
|
|
11204
|
+
if (!factory)
|
|
11205
|
+
throw new Error(
|
|
11206
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11207
|
+
);
|
|
10249
11208
|
const meta = JSON.parse(factory.json);
|
|
10250
11209
|
const dependencies = {
|
|
10251
11210
|
FaustBaseWebAudioDsp,
|
|
@@ -10262,19 +11221,36 @@ const dependencies = {
|
|
|
10262
11221
|
dspMeta: meta,
|
|
10263
11222
|
poly: false
|
|
10264
11223
|
};
|
|
10265
|
-
const Processor = FaustAudioWorkletProcessor_default(
|
|
11224
|
+
const Processor = FaustAudioWorkletProcessor_default(
|
|
11225
|
+
dependencies,
|
|
11226
|
+
faustData
|
|
11227
|
+
);
|
|
10266
11228
|
return Processor;
|
|
10267
11229
|
} catch (e) {
|
|
10268
11230
|
throw e;
|
|
10269
11231
|
}
|
|
10270
11232
|
}
|
|
10271
11233
|
async createOfflineProcessor(sampleRate, bufferSize, factory = this.factory, context) {
|
|
10272
|
-
if (!factory)
|
|
11234
|
+
if (!factory)
|
|
11235
|
+
throw new Error(
|
|
11236
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11237
|
+
);
|
|
10273
11238
|
const meta = JSON.parse(factory.json);
|
|
10274
11239
|
const instance = await FaustWasmInstantiator_default.createAsyncMonoDSPInstance(factory);
|
|
10275
11240
|
const sampleSize = meta.compile_options.match("-double") ? 8 : 4;
|
|
10276
|
-
if (context)
|
|
10277
|
-
|
|
11241
|
+
if (context)
|
|
11242
|
+
factory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11243
|
+
meta,
|
|
11244
|
+
factory.soundfiles || {},
|
|
11245
|
+
context
|
|
11246
|
+
);
|
|
11247
|
+
const monoDsp = new FaustMonoWebAudioDsp(
|
|
11248
|
+
instance,
|
|
11249
|
+
sampleRate,
|
|
11250
|
+
sampleSize,
|
|
11251
|
+
bufferSize,
|
|
11252
|
+
factory.soundfiles
|
|
11253
|
+
);
|
|
10278
11254
|
return new FaustMonoOfflineProcessor(monoDsp, bufferSize);
|
|
10279
11255
|
}
|
|
10280
11256
|
getMeta() {
|
|
@@ -10300,7 +11276,11 @@ var _FaustPolyDspGenerator = class _FaustPolyDspGenerator {
|
|
|
10300
11276
|
};
|
|
10301
11277
|
process = dsp_code.effect;`) {
|
|
10302
11278
|
try {
|
|
10303
|
-
this.effectFactory = await compiler.createPolyDSPFactory(
|
|
11279
|
+
this.effectFactory = await compiler.createPolyDSPFactory(
|
|
11280
|
+
name,
|
|
11281
|
+
effectCodeAux,
|
|
11282
|
+
args
|
|
11283
|
+
);
|
|
10304
11284
|
if (this.effectFactory) {
|
|
10305
11285
|
const effectJSON = JSON.parse(this.effectFactory.json);
|
|
10306
11286
|
const dspCode = `// Voice output is forced to 2, when DSP is stereo or effect has 2 ins or 2 outs,
|
|
@@ -10340,16 +11320,28 @@ dsp_code = environment{
|
|
|
10340
11320
|
};
|
|
10341
11321
|
process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
10342
11322
|
`;
|
|
10343
|
-
this.voiceFactory = await compiler.createPolyDSPFactory(
|
|
11323
|
+
this.voiceFactory = await compiler.createPolyDSPFactory(
|
|
11324
|
+
name,
|
|
11325
|
+
dspCode,
|
|
11326
|
+
args
|
|
11327
|
+
);
|
|
10344
11328
|
try {
|
|
10345
|
-
this.effectFactory = await compiler.createPolyDSPFactory(
|
|
11329
|
+
this.effectFactory = await compiler.createPolyDSPFactory(
|
|
11330
|
+
name,
|
|
11331
|
+
effectCode,
|
|
11332
|
+
args + " -inpl"
|
|
11333
|
+
);
|
|
10346
11334
|
} catch (e) {
|
|
10347
11335
|
console.warn(e);
|
|
10348
11336
|
}
|
|
10349
11337
|
}
|
|
10350
11338
|
} catch (e) {
|
|
10351
11339
|
console.warn(e);
|
|
10352
|
-
this.voiceFactory = await compiler.createPolyDSPFactory(
|
|
11340
|
+
this.voiceFactory = await compiler.createPolyDSPFactory(
|
|
11341
|
+
name,
|
|
11342
|
+
dspCodeAux,
|
|
11343
|
+
args
|
|
11344
|
+
);
|
|
10353
11345
|
}
|
|
10354
11346
|
if (this.voiceFactory) {
|
|
10355
11347
|
this.name = name;
|
|
@@ -10364,13 +11356,19 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
10364
11356
|
}
|
|
10365
11357
|
}
|
|
10366
11358
|
addSoundfiles(soundfileMap) {
|
|
10367
|
-
if (!this.voiceFactory)
|
|
11359
|
+
if (!this.voiceFactory)
|
|
11360
|
+
throw new Error(
|
|
11361
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11362
|
+
);
|
|
10368
11363
|
for (const id in soundfileMap) {
|
|
10369
11364
|
this.voiceFactory.soundfiles[id] = soundfileMap[id];
|
|
10370
11365
|
}
|
|
10371
11366
|
}
|
|
10372
11367
|
getSoundfileList() {
|
|
10373
|
-
if (!this.voiceFactory)
|
|
11368
|
+
if (!this.voiceFactory)
|
|
11369
|
+
throw new Error(
|
|
11370
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11371
|
+
);
|
|
10374
11372
|
const meta = JSON.parse(this.voiceFactory.json);
|
|
10375
11373
|
const map = SoundfileReader_default.findSoundfilesFromMeta(meta);
|
|
10376
11374
|
if (!map) return [];
|
|
@@ -10381,22 +11379,56 @@ process = adaptorIns(dsp_code.process) : dsp_code.effect : adaptorOuts;
|
|
|
10381
11379
|
}
|
|
10382
11380
|
async createNode(context, voices, name = this.name, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, sp = false, bufferSize = 1024, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`, processorOptions = {}) {
|
|
10383
11381
|
var _a, _b;
|
|
10384
|
-
if (!voiceFactory)
|
|
11382
|
+
if (!voiceFactory)
|
|
11383
|
+
throw new Error(
|
|
11384
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11385
|
+
);
|
|
10385
11386
|
const voiceMeta = JSON.parse(voiceFactory.json);
|
|
10386
11387
|
const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
|
|
10387
11388
|
const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
|
|
10388
|
-
voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
10389
|
-
|
|
11389
|
+
voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11390
|
+
voiceMeta,
|
|
11391
|
+
voiceFactory.soundfiles || {},
|
|
11392
|
+
context
|
|
11393
|
+
);
|
|
11394
|
+
if (effectFactory)
|
|
11395
|
+
effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11396
|
+
effectMeta,
|
|
11397
|
+
effectFactory.soundfiles || {},
|
|
11398
|
+
context
|
|
11399
|
+
);
|
|
10390
11400
|
if (sp) {
|
|
10391
|
-
const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
11401
|
+
const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(
|
|
11402
|
+
voiceFactory,
|
|
11403
|
+
mixerModule,
|
|
11404
|
+
voices,
|
|
11405
|
+
effectFactory || void 0
|
|
11406
|
+
);
|
|
11407
|
+
const soundfiles = {
|
|
11408
|
+
...effectFactory == null ? void 0 : effectFactory.soundfiles,
|
|
11409
|
+
...voiceFactory.soundfiles
|
|
11410
|
+
};
|
|
11411
|
+
const polyDsp = new FaustPolyWebAudioDsp(
|
|
11412
|
+
instance,
|
|
11413
|
+
context.sampleRate,
|
|
11414
|
+
sampleSize,
|
|
11415
|
+
bufferSize,
|
|
11416
|
+
soundfiles
|
|
11417
|
+
);
|
|
11418
|
+
const sp2 = context.createScriptProcessor(
|
|
11419
|
+
bufferSize,
|
|
11420
|
+
polyDsp.getNumInputs(),
|
|
11421
|
+
polyDsp.getNumOutputs()
|
|
11422
|
+
);
|
|
10395
11423
|
Object.setPrototypeOf(sp2, FaustPolyScriptProcessorNode.prototype);
|
|
10396
11424
|
sp2.init(polyDsp);
|
|
10397
11425
|
return sp2;
|
|
10398
11426
|
} else {
|
|
10399
|
-
if (!_FaustPolyDspGenerator.gWorkletProcessors.has(context))
|
|
11427
|
+
if (!_FaustPolyDspGenerator.gWorkletProcessors.has(context))
|
|
11428
|
+
_FaustPolyDspGenerator.gWorkletProcessors.set(
|
|
11429
|
+
context,
|
|
11430
|
+
/* @__PURE__ */ new Set()
|
|
11431
|
+
);
|
|
10400
11432
|
if (!((_a = _FaustPolyDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _a.has(processorName))) {
|
|
10401
11433
|
try {
|
|
10402
11434
|
const processorCode = `
|
|
@@ -10439,19 +11471,34 @@ const dependencies = {
|
|
|
10439
11471
|
// Generate the actual AudioWorkletProcessor code
|
|
10440
11472
|
(${FaustAudioWorkletProcessor_default.toString()})(dependencies, faustData);
|
|
10441
11473
|
`;
|
|
10442
|
-
const url = URL.createObjectURL(
|
|
11474
|
+
const url = URL.createObjectURL(
|
|
11475
|
+
new Blob([processorCode], { type: "text/javascript" })
|
|
11476
|
+
);
|
|
10443
11477
|
await context.audioWorklet.addModule(url);
|
|
10444
11478
|
(_b = _FaustPolyDspGenerator.gWorkletProcessors.get(context)) == null ? void 0 : _b.add(processorName);
|
|
10445
11479
|
} catch (e) {
|
|
10446
11480
|
throw e;
|
|
10447
11481
|
}
|
|
10448
11482
|
}
|
|
10449
|
-
const node = new FaustPolyAudioWorkletNode(context, {
|
|
11483
|
+
const node = new FaustPolyAudioWorkletNode(context, {
|
|
11484
|
+
processorOptions: {
|
|
11485
|
+
name: processorName,
|
|
11486
|
+
voiceFactory,
|
|
11487
|
+
mixerModule,
|
|
11488
|
+
voices,
|
|
11489
|
+
sampleSize,
|
|
11490
|
+
effectFactory: effectFactory || void 0,
|
|
11491
|
+
...processorOptions
|
|
11492
|
+
}
|
|
11493
|
+
});
|
|
10450
11494
|
return node;
|
|
10451
11495
|
}
|
|
10452
11496
|
}
|
|
10453
11497
|
async createAudioWorkletProcessor(name = this.name, voiceFactory = this.voiceFactory, effectFactory = this.effectFactory, processorName = ((voiceFactory == null ? void 0 : voiceFactory.shaKey) || "") + ((effectFactory == null ? void 0 : effectFactory.shaKey) || "") || `${name}_poly`) {
|
|
10454
|
-
if (!voiceFactory)
|
|
11498
|
+
if (!voiceFactory)
|
|
11499
|
+
throw new Error(
|
|
11500
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11501
|
+
);
|
|
10455
11502
|
const voiceMeta = JSON.parse(voiceFactory.json);
|
|
10456
11503
|
const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
|
|
10457
11504
|
const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
|
|
@@ -10471,24 +11518,53 @@ const dependencies = {
|
|
|
10471
11518
|
poly: true,
|
|
10472
11519
|
effectMeta
|
|
10473
11520
|
};
|
|
10474
|
-
const Processor = FaustAudioWorkletProcessor_default(
|
|
11521
|
+
const Processor = FaustAudioWorkletProcessor_default(
|
|
11522
|
+
dependencies,
|
|
11523
|
+
faustData
|
|
11524
|
+
);
|
|
10475
11525
|
return Processor;
|
|
10476
11526
|
} catch (e) {
|
|
10477
11527
|
throw e;
|
|
10478
11528
|
}
|
|
10479
11529
|
}
|
|
10480
11530
|
async createOfflineProcessor(sampleRate, bufferSize, voices, voiceFactory = this.voiceFactory, mixerModule = this.mixerModule, effectFactory = this.effectFactory, context) {
|
|
10481
|
-
if (!voiceFactory)
|
|
11531
|
+
if (!voiceFactory)
|
|
11532
|
+
throw new Error(
|
|
11533
|
+
"Code is not compiled, please define the factory or call `await this.compile()` first."
|
|
11534
|
+
);
|
|
10482
11535
|
const voiceMeta = JSON.parse(voiceFactory.json);
|
|
10483
11536
|
const effectMeta = effectFactory ? JSON.parse(effectFactory.json) : void 0;
|
|
10484
|
-
const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(
|
|
11537
|
+
const instance = await FaustWasmInstantiator_default.createAsyncPolyDSPInstance(
|
|
11538
|
+
voiceFactory,
|
|
11539
|
+
mixerModule,
|
|
11540
|
+
voices,
|
|
11541
|
+
effectFactory || void 0
|
|
11542
|
+
);
|
|
10485
11543
|
const sampleSize = voiceMeta.compile_options.match("-double") ? 8 : 4;
|
|
10486
11544
|
if (context) {
|
|
10487
|
-
voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
10488
|
-
|
|
10489
|
-
|
|
10490
|
-
|
|
10491
|
-
|
|
11545
|
+
voiceFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11546
|
+
voiceMeta,
|
|
11547
|
+
voiceFactory.soundfiles || {},
|
|
11548
|
+
context
|
|
11549
|
+
);
|
|
11550
|
+
if (effectFactory)
|
|
11551
|
+
effectFactory.soundfiles = await SoundfileReader_default.loadSoundfiles(
|
|
11552
|
+
effectMeta,
|
|
11553
|
+
effectFactory.soundfiles || {},
|
|
11554
|
+
context
|
|
11555
|
+
);
|
|
11556
|
+
}
|
|
11557
|
+
const soundfiles = {
|
|
11558
|
+
...effectFactory == null ? void 0 : effectFactory.soundfiles,
|
|
11559
|
+
...voiceFactory.soundfiles
|
|
11560
|
+
};
|
|
11561
|
+
const polyDsp = new FaustPolyWebAudioDsp(
|
|
11562
|
+
instance,
|
|
11563
|
+
sampleRate,
|
|
11564
|
+
sampleSize,
|
|
11565
|
+
bufferSize,
|
|
11566
|
+
soundfiles
|
|
11567
|
+
);
|
|
10492
11568
|
return new FaustPolyOfflineProcessor(polyDsp, bufferSize);
|
|
10493
11569
|
}
|
|
10494
11570
|
getMeta() {
|
|
@@ -10496,22 +11572,24 @@ const dependencies = {
|
|
|
10496
11572
|
const e = this.effectFactory ? JSON.parse(this.effectFactory.json) : null;
|
|
10497
11573
|
const r = { ...o };
|
|
10498
11574
|
if (e) {
|
|
10499
|
-
r.ui = [
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
11575
|
+
r.ui = [
|
|
11576
|
+
{
|
|
11577
|
+
type: "tgroup",
|
|
11578
|
+
label: "Sequencer",
|
|
11579
|
+
items: [
|
|
11580
|
+
{ type: "vgroup", label: "Instrument", items: o.ui },
|
|
11581
|
+
{ type: "vgroup", label: "Effect", items: e.ui }
|
|
11582
|
+
]
|
|
11583
|
+
}
|
|
11584
|
+
];
|
|
10507
11585
|
} else {
|
|
10508
|
-
r.ui = [
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
{ type: "vgroup", label: "Voices", items: o.ui }
|
|
10513
|
-
|
|
10514
|
-
|
|
11586
|
+
r.ui = [
|
|
11587
|
+
{
|
|
11588
|
+
type: "tgroup",
|
|
11589
|
+
label: "Polyphonic",
|
|
11590
|
+
items: [{ type: "vgroup", label: "Voices", items: o.ui }]
|
|
11591
|
+
}
|
|
11592
|
+
];
|
|
10515
11593
|
}
|
|
10516
11594
|
return r;
|
|
10517
11595
|
}
|
|
@@ -10525,11 +11603,103 @@ const dependencies = {
|
|
|
10525
11603
|
// Set of all created WorkletProcessors, each of them has to be unique
|
|
10526
11604
|
_FaustPolyDspGenerator.gWorkletProcessors = /* @__PURE__ */ new Map();
|
|
10527
11605
|
var FaustPolyDspGenerator = _FaustPolyDspGenerator;
|
|
11606
|
+
var _FaustDspGenerator = class _FaustDspGenerator {
|
|
11607
|
+
// Analyze the metadata of a Faust JSON file and extract the [midi:on] and [nvoices:n] options
|
|
11608
|
+
extractMidiAndNvoices(jsonData) {
|
|
11609
|
+
const optionsMetadata = jsonData.meta.find((meta) => meta.options);
|
|
11610
|
+
if (optionsMetadata && optionsMetadata.options) {
|
|
11611
|
+
const options = optionsMetadata.options;
|
|
11612
|
+
const midiRegex = /\[midi:(on|off)\]/;
|
|
11613
|
+
const nvoicesRegex = /\[nvoices:(\d+)\]/;
|
|
11614
|
+
const midiMatch = options.match(midiRegex);
|
|
11615
|
+
const nvoicesMatch = options.match(nvoicesRegex);
|
|
11616
|
+
const midi = midiMatch ? midiMatch[1] === "on" : false;
|
|
11617
|
+
const nvoices = nvoicesMatch ? parseInt(nvoicesMatch[1], 10) : -1;
|
|
11618
|
+
return { midi, nvoices };
|
|
11619
|
+
} else {
|
|
11620
|
+
return { midi: false, nvoices: -1 };
|
|
11621
|
+
}
|
|
11622
|
+
}
|
|
11623
|
+
/**
|
|
11624
|
+
* Compile DSP code, inspect metadata for [nvoices:] (and optionally [midi:on]), and build either a mono
|
|
11625
|
+
* or poly WebAudio node (ScriptProcessor or AudioWorklet depending on `sp`). Compilation uses a shared,
|
|
11626
|
+
* lazily-created libfaust instance to avoid repeatedly instantiating the WASM compiler.
|
|
11627
|
+
*/
|
|
11628
|
+
async createFaustNode(context, name, code, sp, bufferSize) {
|
|
11629
|
+
const getCompiler = async () => {
|
|
11630
|
+
if (!_FaustDspGenerator.compilerPromise) {
|
|
11631
|
+
const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
|
|
11632
|
+
if (!baseURL)
|
|
11633
|
+
throw new Error("Cannot resolve libfaust-wasm location.");
|
|
11634
|
+
const jsURL = new URL(
|
|
11635
|
+
"../libfaust-wasm/libfaust-wasm.js",
|
|
11636
|
+
baseURL
|
|
11637
|
+
).href;
|
|
11638
|
+
const dataURL = jsURL.replace(/c?js$/, "data");
|
|
11639
|
+
const wasmURL = jsURL.replace(/c?js$/, "wasm");
|
|
11640
|
+
_FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
|
|
11641
|
+
jsURL,
|
|
11642
|
+
dataURL,
|
|
11643
|
+
wasmURL
|
|
11644
|
+
).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
|
|
11645
|
+
}
|
|
11646
|
+
return _FaustDspGenerator.compilerPromise;
|
|
11647
|
+
};
|
|
11648
|
+
const args = "-ftz 2";
|
|
11649
|
+
try {
|
|
11650
|
+
const compiler = await getCompiler();
|
|
11651
|
+
const monoGenerator = new FaustMonoDspGenerator();
|
|
11652
|
+
const compiledMono = await monoGenerator.compile(
|
|
11653
|
+
compiler,
|
|
11654
|
+
name,
|
|
11655
|
+
code,
|
|
11656
|
+
args
|
|
11657
|
+
);
|
|
11658
|
+
if (!compiledMono) return null;
|
|
11659
|
+
const { nvoices } = this.extractMidiAndNvoices(
|
|
11660
|
+
monoGenerator.getMeta()
|
|
11661
|
+
);
|
|
11662
|
+
if (nvoices > 0) {
|
|
11663
|
+
const polyGenerator = new FaustPolyDspGenerator();
|
|
11664
|
+
const compiledPoly = await polyGenerator.compile(
|
|
11665
|
+
compiler,
|
|
11666
|
+
name,
|
|
11667
|
+
code,
|
|
11668
|
+
args
|
|
11669
|
+
);
|
|
11670
|
+
if (!compiledPoly) return null;
|
|
11671
|
+
return await polyGenerator.createNode(
|
|
11672
|
+
context,
|
|
11673
|
+
nvoices,
|
|
11674
|
+
name,
|
|
11675
|
+
void 0,
|
|
11676
|
+
void 0,
|
|
11677
|
+
void 0,
|
|
11678
|
+
sp,
|
|
11679
|
+
bufferSize
|
|
11680
|
+
);
|
|
11681
|
+
}
|
|
11682
|
+
return await monoGenerator.createNode(
|
|
11683
|
+
context,
|
|
11684
|
+
name,
|
|
11685
|
+
void 0,
|
|
11686
|
+
sp,
|
|
11687
|
+
bufferSize
|
|
11688
|
+
);
|
|
11689
|
+
} catch (e) {
|
|
11690
|
+
console.error(e);
|
|
11691
|
+
return null;
|
|
11692
|
+
}
|
|
11693
|
+
}
|
|
11694
|
+
};
|
|
11695
|
+
_FaustDspGenerator.compilerPromise = null;
|
|
11696
|
+
var FaustDspGenerator = _FaustDspGenerator;
|
|
10528
11697
|
export {
|
|
10529
11698
|
FaustAudioWorkletNode,
|
|
10530
11699
|
FaustBaseWebAudioDsp,
|
|
10531
11700
|
FaustCmajor_default as FaustCmajor,
|
|
10532
11701
|
FaustCompiler_default as FaustCompiler,
|
|
11702
|
+
FaustDspGenerator,
|
|
10533
11703
|
FaustDspInstance,
|
|
10534
11704
|
FaustModuleFactoryData,
|
|
10535
11705
|
FaustModuleFactoryFn,
|