@grame/faustwasm 0.13.0 → 0.13.2

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 CHANGED
@@ -334,8 +334,8 @@ An offline processor to render a DSP in a non real-time context and get the comp
334
334
  #### High-level API <a name="high"></a>
335
335
 
336
336
  The high-level API provides convenient functions to compile a Faust DSP program and create its corresponding audio node, either monophonic or polyphonic.
337
- - `createNode` explicitly builds a mono or polyphonic node.
338
- - `createFaustNode` automatically selects mono or polyphonic mode by inspecting the `[nvoices:] `field in the DSP metadata.
337
+ - using the appropriate `FaustMonoDspGenerator` or `FaustPolyDspGenerator` class, `createNode` explicitly builds a mono or polyphonic node.
338
+ - `createFaustNode` automatically selects mono or polyphonic mode by inspecting the `[nvoices:N] `field in the DSP metadata.
339
339
 
340
340
  For offline rendering, `createOfflineProcessor` is available and supports both mono and polyphonic processing. FFT processing nodes can be created using `createFFTNode`.
341
341
 
@@ -5192,6 +5192,7 @@ var FaustPolyScriptProcessorNode = class extends FaustScriptProcessorNode {
5192
5192
  };
5193
5193
 
5194
5194
  // src/FaustDspGenerator.ts
5195
+ var import_meta = {};
5195
5196
  var _FaustMonoDspGenerator = class _FaustMonoDspGenerator {
5196
5197
  constructor() {
5197
5198
  this.factory = null;
@@ -5840,20 +5841,38 @@ var _FaustDspGenerator = class _FaustDspGenerator {
5840
5841
  async createFaustNode(context, name, code, sp, bufferSize) {
5841
5842
  const getCompiler = async () => {
5842
5843
  if (!_FaustDspGenerator.compilerPromise) {
5843
- const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
5844
- if (!baseURL)
5845
- throw new Error("Cannot resolve libfaust-wasm location.");
5846
- const jsURL = new URL(
5847
- "../libfaust-wasm/libfaust-wasm.js",
5848
- baseURL
5849
- ).href;
5850
- const dataURL = jsURL.replace(/c?js$/, "data");
5851
- const wasmURL = jsURL.replace(/c?js$/, "wasm");
5852
- _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5853
- jsURL,
5854
- dataURL,
5855
- wasmURL
5856
- ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5844
+ const isNode = typeof document === "undefined" && typeof window === "undefined";
5845
+ if (isNode) {
5846
+ const baseURL = (typeof __dirname !== "undefined" ? `file://${__dirname}/` : void 0) || (typeof import_meta !== "undefined" && typeof import_meta.url === "string" ? import_meta.url : void 0);
5847
+ if (!baseURL)
5848
+ throw new Error("Cannot resolve libfaust-wasm location.");
5849
+ const jsURL = new URL(
5850
+ "../libfaust-wasm/libfaust-wasm.js",
5851
+ baseURL
5852
+ ).href;
5853
+ const dataURL = jsURL.replace(/c?js$/, "data");
5854
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
5855
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5856
+ jsURL,
5857
+ dataURL,
5858
+ wasmURL
5859
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5860
+ } else {
5861
+ const baseURL = (typeof document !== "undefined" ? "src" in (document.currentScript || {}) ? document.currentScript.src : document.baseURI : void 0) || (typeof window !== "undefined" ? window.location.href : void 0);
5862
+ if (!baseURL)
5863
+ throw new Error("Cannot resolve libfaust-wasm location.");
5864
+ const jsURL = new URL(
5865
+ "../libfaust-wasm/libfaust-wasm.js",
5866
+ baseURL
5867
+ ).href;
5868
+ const dataURL = jsURL.replace(/c?js$/, "data");
5869
+ const wasmURL = jsURL.replace(/c?js$/, "wasm");
5870
+ _FaustDspGenerator.compilerPromise = instantiateFaustModuleFromFile_default(
5871
+ jsURL,
5872
+ dataURL,
5873
+ wasmURL
5874
+ ).then((module) => new FaustCompiler_default(new LibFaust_default(module)));
5875
+ }
5857
5876
  }
5858
5877
  return _FaustDspGenerator.compilerPromise;
5859
5878
  };