Proof-of-concept demonstrating the usage of Web Audio API on server using Playwright.
The core audio rendering logic put in src/renderAudio.ts script, which uses OfflineAudioContext to generate audio buffer. Then it's being taken by some wrapping code to put it into an HTML page wrapper to be opened by Playwright browser to download the resulting audio file.
The key benefit of Playwright is that it allows to run this logic on any platform, preserving all of the features of Web Audio API. So there's no need of some custom Web Audio API re-implementation solution for server, which is a very difficult task to complete.
Prerequisites:
To install dependencies:
bun install
To run:
bun run build
bun run render
This project was created using bun init
in bun v1.0.29. Bun is a fast all-in-one JavaScript runtime.