web-audio-apispidermonkey

Web Audio API with SpiderMonkey?


Is it possible to use the Web Audio API with SpiderMonkey or other standalone JavaScript engines? - V8 doesn't seem to support it.

Asking because I'm currently rendering audio artifacts in the browser with the Web Audio API, using OfflineAudioContext, but would like to perform that task in other contexts, outside the browser environment.

(A related question is: Can the WebGL canvas be accessed from a standalone JavaScript engine such as SpiderMonkey?)


Solution

  • The Web Audio API is a browser API and not a JavaScript feature. Therefore it's missing in SpiderMonkey or V8.

    However there are some projects like audiojs/web-audio-api which allow you to use the same API (or parts of it) with Node.js.

    There is also a fork of Chromium's Web Audio API implementation called LabSound.

    And last but not least there is also a Rust implementation called web-audio-api-rs.

    If all of that doesn't work for your use case you could also run Firefox or Chrome in headless mode controlled by Playwright or Puppeteer.