Closed barnabycollins closed 2 years ago
The main problems I'm currently having are:
libfaust-wasm.js
upon attempting to compile Faust code (currently Aborted(Assertion failed: allocate no longer takes a type argument)
and a message saying XMLHttpRequest on the main thread is deprecated)I'm trying to import and use Faust in a similar way to the file in README.md (but adjusted based on index.ts in the Faust IDE repo):
import {Faust, FaustAudioWorkletNode, FaustScriptProcessorNode} from "faust2webaudio";
const audioCtx = new window.AudioContext();
const code = `
import("stdfaust.lib");
process = ba.pulsen(1, 10000) : pm.djembe(60, 0.3, 0.4, 1) <: dm.freeverb_demo;`;
const faust = new Faust({
debug: true,
wasmLocation: "src/libfaust/libfaust-wasm.wasm",
dataLocation: "src/libfaust/libfaust-wasm.data"
});
await faust.ready;
let node: FaustScriptProcessorNode | FaustAudioWorkletNode;
node = await faust.getNode(code, { audioCtx, useWorklet: window.AudioWorklet ? true : false, args: { "-I": "https://raw.githubusercontent.com/grame-cncm/faustlibraries/4cd48b91f1170498c1cf5d8ee5b87cda6cd797df/" } })
.then(node => node.connect(audioCtx.destination));
I've downloaded libfaust-wasm.data
and libfaust-wasm.wasm
from the Faust IDE in case the hardcoded URLs or included WASM files were wrong (after trying both of these first), and also pointed the compiler to the up-to-date faustlibraries
repo rather than the faust website as you can see, because https://faust.grame.fr/tools/editor/libraries/stdfaust.lib
seemed to be 404ing. I'm also using the same, latest version (1f9a20e8ec21139ab002c2f3e37574764a510903) of faust2wasm as the IDE.
Is there anything else I should be doing / anything else I should know about? I've tried to replicate the (obviously working) state of the Faust IDE as far as I can with no success so far.
TIA!
Hi @barnabycollins, If I understood correctly, you wan't to use faust2webaudio in another project.
libfaust-wasm.data
and libfaust-wasm.wasm
match the version of faust2webaudio
. You can simply use the files under ./dist
folder in this project. (Those from the Faust IDE may not be the latest.)faustlibraries
is just inside libfaust-wasm.data
, so no need to have another copy or point elsewhere. They are built-in, just neet to use the argument -I libraries/
as in the test/mono.html
Hi there @Fr0stbyteR; thanks for the super-quick response and clear instructions! Yes; I am hoping to use it in my own web tool as part of my undergraduate final Master's project.
I've switched to the bundled libfaust-wasm.*
files and changed the -I
argument back.
I was then getting the following error:
which seems to be similar to the error in issue #13. I saw you just mentioned CRLF might cause issues on that thread and I am running Windows, and you were right - converting libfaust-wasm.data
to LF instead of CRLF in my IDE appears to have fixed it, and I was instantly blessed with some beautiful djembe noises!
Thanks for your help! 😁
To summarise, I think my problem was that I saw the error appearing when I used the copy from dist
, so looked at #13 and decided to try another copy from the IDE, which was the wrong version and therefore also didn't work. Switching back to the copy bundled with the module and making sure it was using LF fixed all my problems.
Wow glad to know that it works! ;)
Renaming to reflect discussion and closing 😁
I'm looking to use this module for an academic project, since I need a framework to generate synthesisers in the browser and Faust seems ideal for this. I see that it's used in the Faust IDE, but I am having problems getting it to work and am wondering if I'm missing some documentation somewhere.