@grame/faustwasm 0.0.27 → 0.0.29
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/README.md +10 -8
- package/assets/standalone/faustwasm/index.d.ts +17 -17
- package/assets/standalone/faustwasm/index.js +47 -31
- package/assets/standalone/faustwasm/index.js.map +3 -3
- package/dist/cjs/index.d.ts +17 -17
- package/dist/cjs/index.js +46 -30
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs-bundle/index.d.ts +17 -17
- package/dist/cjs-bundle/index.js +1449 -3153
- package/dist/cjs-bundle/index.js.map +3 -3
- package/dist/esm/index.d.ts +17 -17
- package/dist/esm/index.js +47 -31
- package/dist/esm/index.js.map +3 -3
- package/dist/esm-bundle/index.d.ts +17 -17
- package/dist/esm-bundle/index.js +1452 -3152
- package/dist/esm-bundle/index.js.map +3 -3
- package/libfaust-wasm/libfaust-wasm.data +0 -0
- package/libfaust-wasm/libfaust-wasm.js +3 -4
- package/libfaust-wasm/libfaust-wasm.wasm +0 -0
- package/package.json +1 -1
- package/src/FaustDspGenerator.ts +13 -13
- package/src/FaustDspInstance.ts +1 -3
- package/src/FaustWasmInstantiator.ts +1 -1
- package/src/exports.ts +24 -24
- package/test/faustlive-wasm/faustwasm/index.d.ts +17 -17
- package/test/faustlive-wasm/faustwasm/index.js +47 -31
- package/test/faustlive-wasm/faustwasm/index.js.map +3 -3
- package/test/t1.cjs +46 -0
- package/test/t1.js +46 -0
package/test/t1.cjs
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const FaustWasm = require("@grame/faustwasm");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
instantiateFaustModuleFromFile,
|
|
7
|
+
LibFaust,
|
|
8
|
+
WavEncoder,
|
|
9
|
+
FaustMonoDspGenerator,
|
|
10
|
+
FaustCompiler,
|
|
11
|
+
FaustSvgDiagrams
|
|
12
|
+
} = FaustWasm;
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
15
|
+
const faustModulePath = path.join(__dirname, "../node_modules/@grame/faustwasm/libfaust-wasm/libfaust-wasm.js");
|
|
16
|
+
|
|
17
|
+
// initialize the libfaust wasm
|
|
18
|
+
const faustModule = await instantiateFaustModuleFromFile(faustModulePath);
|
|
19
|
+
|
|
20
|
+
// Get the Faust compiler
|
|
21
|
+
const libFaust = new LibFaust(faustModule);
|
|
22
|
+
console.log(libFaust.version());
|
|
23
|
+
const compiler = new FaustCompiler(libFaust);
|
|
24
|
+
const generator = new FaustMonoDspGenerator();
|
|
25
|
+
const sampleRate = 48000;
|
|
26
|
+
const name = "Djembe"
|
|
27
|
+
const argv = ["-I", "libraries/"];
|
|
28
|
+
const code = `
|
|
29
|
+
import("stdfaust.lib");
|
|
30
|
+
process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
|
|
31
|
+
`;
|
|
32
|
+
// Compile the DSP
|
|
33
|
+
await generator.compile(compiler, name, code, argv.join(" "));
|
|
34
|
+
const processor = await generator.createOfflineProcessor(sampleRate, 1024);
|
|
35
|
+
|
|
36
|
+
// Generate SVG diagrams.
|
|
37
|
+
const svgDiagrams = new FaustSvgDiagrams(compiler);
|
|
38
|
+
const svgs = svgDiagrams.from(name, code, argv.join(" "));
|
|
39
|
+
console.log(Object.keys(svgs));
|
|
40
|
+
|
|
41
|
+
const out = processor.render(null, 192000);
|
|
42
|
+
const wav = WavEncoder.encode(out, { sampleRate, bitDepth: 24 });
|
|
43
|
+
|
|
44
|
+
// The wav file is generated
|
|
45
|
+
fs.writeFileSync(`${__dirname}/out.wav`, new Uint8Array(wav));
|
|
46
|
+
})();
|
package/test/t1.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const FaustWasm = require("@grame/faustwasm");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
instantiateFaustModuleFromFile,
|
|
7
|
+
LibFaust,
|
|
8
|
+
WavEncoder,
|
|
9
|
+
FaustMonoDspGenerator,
|
|
10
|
+
FaustCompiler,
|
|
11
|
+
FaustSvgDiagrams
|
|
12
|
+
} = FaustWasm;
|
|
13
|
+
|
|
14
|
+
(async () => {
|
|
15
|
+
const faustModulePath = path.join(__dirname, "../node_modules/@grame/faustwasm/libfaust-wasm/libfaust-wasm.js");
|
|
16
|
+
|
|
17
|
+
// initialize the libfaust wasm
|
|
18
|
+
const faustModule = await instantiateFaustModuleFromFile(faustModulePath);
|
|
19
|
+
|
|
20
|
+
// Get the Faust compiler
|
|
21
|
+
const libFaust = new LibFaust(faustModule);
|
|
22
|
+
console.log(libFaust.version());
|
|
23
|
+
const compiler = new FaustCompiler(libFaust);
|
|
24
|
+
const generator = new FaustMonoDspGenerator();
|
|
25
|
+
const sampleRate = 48000;
|
|
26
|
+
const name = "Djembe"
|
|
27
|
+
const argv = ["-I", "libraries/"];
|
|
28
|
+
const code = `
|
|
29
|
+
import("stdfaust.lib");
|
|
30
|
+
process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1);
|
|
31
|
+
`;
|
|
32
|
+
// Compile the DSP
|
|
33
|
+
await generator.compile(compiler, name, code, argv.join(" "));
|
|
34
|
+
const processor = await generator.createOfflineProcessor(sampleRate, 1024);
|
|
35
|
+
|
|
36
|
+
// Generate SVG diagrams.
|
|
37
|
+
const svgDiagrams = new FaustSvgDiagrams(compiler);
|
|
38
|
+
const svgs = svgDiagrams.from(name, code, argv.join(" "));
|
|
39
|
+
console.log(Object.keys(svgs));
|
|
40
|
+
|
|
41
|
+
const out = processor.render(null, 192000);
|
|
42
|
+
const wav = WavEncoder.encode(out, { sampleRate, bitDepth: 24 });
|
|
43
|
+
|
|
44
|
+
// The wav file is generated
|
|
45
|
+
fs.writeFileSync(`${__dirname}/out.wav`, new Uint8Array(wav));
|
|
46
|
+
})();
|