Why Web Audio API isn't supported in nodejs? Why Web Audio API isn't supported in nodejs? node.js node.js

Why Web Audio API isn't supported in nodejs?


Node.js doesn't support Web Audio because it isn't part of the JavaScript language itself - it's a separate web platform JavaScript API.

You can think of it like Web Workers, requestAnimationFrame or XMLHttpRequest - they are part of the browser's JavaScript environment, but they don't necessarily make sense for other runtimes.

V8 is a generic JavaScript engine; it doesn't include web platform features. That's one of the reasons that Node.js is able to use it. Chrome's implementation of Web Audio is part of Blink, the rendering engine.

The web-audio-api npm module aims to implement Web Audio for Node.js.


The reason why the Web Audio API (WAA) is not implemented in NodeJS is fundamentally a design decision. And the fact that AudioContext is part of window has nothing to do with it. For example, console is part of window interface but is in "node-core".

The fact that the WAA is not part of ECMAScript specs is also not sufficient to explain why WAA is not in node-core. For example HTTP2, web crypto API, setInterval(),... are not in ECMAScript spec but are in node-core.

There is no clear cut between what should be in node-core, and what should be in userland (meaning not be in node-core). But in general, NodeJS prefers to keep its standard lib small, expirements new API in userland. You can read this article which talks about that in more depth (see).

Should we see WAA in node-core in near future? Probably not (see issue #64546), but it doesn't mean that 's impossible.

I should add that portability in Audio programming is not an easy task, and this certainly explain in part why NodeJS maintainers are not eager to implement WAA in core.