A simple tone generator. Written in C++, compiled to WASM with Emscripten, running in the browser, on top of a WebGPU rendering back-end.
This primarily demonstrates the Emscripten Audio system - a C++ helper class to assist in managing Emscripten WASM Audio Worklets with a simple interface.
This is a very low-latency approach, as the sound generation runs away from the main thread, in a dedicated realtime-priority audio worklet.
For other demos, see:
- https://github.com/Armchair-Software/webgpu-demo
- https://github.com/Armchair-Software/webgpu-demo2
- https://github.com/Armchair-Software/boids-webgpu-demo
- https://github.com/Armchair-Software/webgpu-shader-demo
- https://github.com/Armchair-Software/chatgpt-emscripten-demo
Live demo: https://armchair-software.github.io/emscripten-sound-demo/
This requires Firefox Nightly, or a recent version of Chrome or Chromium, with webgpu and Vulkan support explicitly enabled.
- Emscripten Audio (included)
- Emscripten
- CMake
- VectorStorm (included)
- LogStorm (included)
- Emscripten Browser Clipboard (included)
- magic_enum (included)
- dear imgui with the proposed
imgui_impl_emscripten
backend (included)
The easiest way to assemble everything (including in-tree shader resource assembly) is to use the included build script:
./build.sh
To launch a local server and bring up a browser:
./run.sh
For manual builds with CMake, and to adjust how the example is run locally, inspect the build.sh
and run.sh
scripts.