faust-loader v1.3.0
faust-loader
Import Faust .dsp files, and get back an AudioWorklet or ScriptProcessor node.
This loader is confirmed working with Faust v2.30.5, but may break on lower versions. Help is wanted on getting the WASM version of libfaust working in NodeJS.
Installation
Install the Faust compiler version >=2.30.5. You can download it or build it from source. It's also available from the AUR.
Install faust-loader:
npm install --save-dev faust-loader
# OR
yarn add -D faust-loader
- Add faust-loader to your webpack config:
module: {
rules: [
// ...
{
test: /\.dsp$/,
use: [
{
loader: "faust-loader",
options: {
outputPath: "processors", // Where the generated files will be placed relative to the output directory
publicPath: "/build/processors" // Where the generated files will be served from
}
},
],
},
],
},
Usage
import { AudioContext } from "standardized-audio-context";
import createCompressor from "./Compressor.dsp";
const context = new AudioContext();
createCompressor(context).then((node) => {
node.connect(context.destination);
node.getParams();
node.setParam("attack", 0.3);
});
faust-loader makes use of standardized-audio-context for instantiating AudioWorkletNodes. This allows it to automatically fallback to a ScriptProcessorNode on Safari and other browsers that don't support AudioWorklets, as well as interoperate seamlessly with Tone.js, a popular web audio framework.
Because of this, you have to use an AudioContext from standardized-audio-context
when creating Faust nodes. If you want
to use this loader with a vanilla AudioContext, please submit an issue or PR!
With Tone.js
import { getContext, connect } from "tone";
import createSynth from "./Synthesizer.dsp";
async function connectSynth() {
const context = getContext();
// `context` is the Tone Context, we need to get the raw standardized-audio-context.
const node = await createSynth(context.rawContext);
// We also need to use the global `connect` function since the node isn't a Tone AudioNode.
connect(node, context.destination);
}
With Next.js
// next.config.js
module.exports = {
webpack: (config, { isServer }) => {
config.module.rules.push({
test: [/\.dsp$/],
loader: "faust-loader",
options: {
outputPath: `${isServer ? "../" : ""}static/processors/`,
publicPath: "/_next/static/processors",
},
});
return config;
},
};
6 months ago
6 months ago
10 months ago
10 months ago
10 months ago
1 year ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago