Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Provide ability to run faust compiler WASM version in Nodejs #598

Open
Smona opened this issue Jun 18, 2021 · 1 comment
Open

Comments

@Smona
Copy link

Smona commented Jun 18, 2021

Hello all! I'm very excited about the possibilities Faust creates when it comes to running custom DSP on the web for non-c++ programmers.

I'm trying to build a webpack loader for Faust DSP files. I've gotten it most of the way there, but unfortunately the version of libfaust provided by many package managers has some bugs in the AudioWorklet processor template.

I've been trying to figure out how to use libfaust-wasm in Node.js so I can package the compiler with the loader and make sure the version is correct. Unfortunately, when I try to run libfaust-wasm.js in a node environment, I get an error about preloaded memory only being supported in the browser and web workers. I got a bit stuck at that point because libfaust-wasm.js is quite opaque, and admittedly c++ and its compilation aren't my strong suit.

I was hoping that someone involved with the project would be interested in helping to create a version of libfaust-wasm that can be run in node. Ideally, it would support something like the following:

import { FaustCompiler } from "@grame/libfaust";
import { promises as fs } from "fs";

async function compileDSP(dspCode: string) {
  await FaustCompiler.initialize();
  const result = await FaustCompiler.compileAudioWorklet(dspCode, options);
  await fs.writeFile("MyDSP.wasm", result.wasm);
  await fs.writeFile("MyDSP-processor.js", result.processsor);
}

I really think supporting compilation from Nodejs would be a boon to Faust adoption, as it would enable integrating Faust compilation into all the various build tools used by application developers. I'd also be happy to provide help with any necessary planning or implementation! The part I need help with is just compiling and instantiating a version of libfaust that doesn't use preloaded memory.

@sletz
Copy link
Member

sletz commented Jun 19, 2021

Which libfaust-wasm.js version are you using?
Note that we have completely rewritten the Faust/WeAudio layer in the wasm2 branch, see https://github.com/grame-cncm/faust/tree/wasm2/javascript.
This new code (still in test) is already packaged as an npm package. Thus it will be better to start from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants