@grame/faustwasm 0.0.45 → 0.0.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grame/faustwasm",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "description": "WebAssembly version of Faust Compiler",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -2,7 +2,7 @@
2
2
  //@ts-check
3
3
  import * as process from "process";
4
4
  import faust2wasmFiles from "../src/faust2wasmFiles.js";
5
- import copyWebStandaloneAssets from "../src/copyWebStandaloneAssets.js";
5
+ import { copyWebStandaloneAssets, copyTemplate } from "../src/copyWebStandaloneAssets.js";
6
6
 
7
7
  const argv = process.argv.slice(2);
8
8
 
@@ -26,5 +26,9 @@ const [inputFile, outputDir, ...argvFaust] = argv;
26
26
 
27
27
  (async () => {
28
28
  await faust2wasmFiles(inputFile, outputDir, argvFaust, poly);
29
- if (standalone) copyWebStandaloneAssets(outputDir);
29
+ if (standalone) {
30
+ copyWebStandaloneAssets(outputDir);
31
+ } else {
32
+ copyTemplate(outputDir, poly);
33
+ }
30
34
  })();
@@ -103,7 +103,7 @@ export interface IFaustPolyDspGenerator {
103
103
  *
104
104
  * @param compiler - the Faust compiler
105
105
  * @param name - the DSP name
106
- * @param dspCode - the DSP code ('dsp_code' can possibly contain an integrated effect)
106
+ * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)
107
107
  * @param args - the compilation parameters
108
108
  * @param effectCode - optional effect DSP code
109
109
  * @returns the compiled factory or 'null' if failure
@@ -119,7 +119,7 @@ export interface IFaustPolyDspGenerator {
119
119
  * @param voices - the number of voices
120
120
  * @param name - AudioWorklet Processor name
121
121
  * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
122
- * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
122
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)
123
123
  * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
124
124
  * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
125
125
  * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames
@@ -1,3 +1,4 @@
1
1
  declare const copyWebStandaloneAssets: (outputDir: string) => void;
2
+ declare const copyTemplate: (outputDir: string, poly: boolean) => void;
2
3
 
3
- export default copyWebStandaloneAssets;
4
+ export { copyWebStandaloneAssets, copyTemplate };
@@ -17,4 +17,19 @@ const copyWebStandaloneAssets = (outputDir) => {
17
17
  cpSync(assetsPath, outputDir);
18
18
  };
19
19
 
20
- export default copyWebStandaloneAssets;
20
+ /**
21
+ * @param {string} outputDir
22
+ */
23
+ const copyTemplate = (outputDir, poly = false) => {
24
+ console.log(`Writing index file.`)
25
+ if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
26
+ const templateJSPath = path.join(__dirname, "../assets/standalone/template.js");
27
+ const templateHTMLPath = (poly) ? path.join(__dirname, "../assets/standalone/template-poly.html") : path.join(__dirname, "../assets/standalone/template.html");
28
+ const faustwasmPath = path.join(__dirname, "../assets/standalone/faustwasm");
29
+ cpSync(templateJSPath, outputDir + "/template.js");
30
+ cpSync(templateHTMLPath, outputDir + "/template.html");
31
+ cpSync(faustwasmPath, outputDir + "/faustwasm");
32
+ };
33
+
34
+ export { copyWebStandaloneAssets, copyTemplate };
35
+
@@ -1199,7 +1199,7 @@ export interface IFaustPolyDspGenerator {
1199
1199
  *
1200
1200
  * @param compiler - the Faust compiler
1201
1201
  * @param name - the DSP name
1202
- * @param dspCode - the DSP code ('dsp_code' can possibly contain an integrated effect)
1202
+ * @param dspCode - the DSP code ('dspCode' can possibly contain an integrated effect)
1203
1203
  * @param args - the compilation parameters
1204
1204
  * @param effectCode - optional effect DSP code
1205
1205
  * @returns the compiled factory or 'null' if failure
@@ -1215,7 +1215,7 @@ export interface IFaustPolyDspGenerator {
1215
1215
  * @param voices - the number of voices
1216
1216
  * @param name - AudioWorklet Processor name
1217
1217
  * @param voiceFactory - the Faust factory for voices, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1218
- * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files)
1218
+ * @param mixerModule - the wasm Mixer module (loaded from 'mixer32.wasm' or 'mixer64.wasm' files located in the 'faustwasm' package)
1219
1219
  * @param effectFactory - the Faust factory for the effect, either obtained with a compiler (createDSPFactory) or loaded from files (loadDSPFactory)
1220
1220
  * @param sp - whether to compile a ScriptProcessorNode or an AudioWorkletNode
1221
1221
  * @param bufferSize - the buffer size in frames to be used in ScriptProcessorNode only, since AudioWorkletNode always uses 128 frames