@happysoftware/nam-web
v0.2.0
Published
Headless WebAssembly engine for Neural Amp Modeler — run neural guitar amp models in any web page, in real time.
Maintainers
Readme
@happysoftware/nam-web
Neural Amp Modeler as a drop-in
AudioWorkletNode— no React, no COOP/COEP headers.
Run the real NAM — neural guitar amp models — anywhere in a Web Audio graph. It's
just an audio node: connect() it, swap models at runtime, done. No UI framework
to adopt, and — because inference runs inside the worklet, with no
SharedArrayBuffer — no cross-origin-isolation headers to add to your site.
Embed it on any page as-is.
npm install @happysoftware/nam-webimport { createNamNode } from '@happysoftware/nam-web';
const ctx = new AudioContext();
const nam = await createNamNode(ctx, { modelUrl: '/models/my-amp.nam' });
const guitar = ctx.createMediaStreamSource(stream);
guitar.connect(nam.node).connect(ctx.destination);
nam.setInputGainDb(6); // drive
await nam.loadModel('/models/other-amp.nam'); // hot-swap, glitch-freeThree lines to put a neural amp model in the signal path. No React, no UI, no
SharedArrayBuffer headers — just an AudioWorkletNode.
The worklet and the WASM binary ship inside the package (
dist/worklet.js,dist/nam-wasm.wasm). Serve them as static assets; the bytes are handed to the worklet at runtime — no special headers required.
Why
NAM in the browser already exists — TONE3000 ships it as a React component (neural-amp-modeler-wasm). But there is no headless, typed, framework-agnostic building block: an AudioWorklet node you can drop into a Vue/Svelte/vanilla-JS site, a web DAW, a model marketplace preview button, or a "hear this amp" product page.
nam-web is that missing layer: the engine only, three lines to wire up.
API
createNamNode(ctx, opts) returns a NamNode:
| Member | Purpose |
|---|---|
| node | the AudioWorkletNode — connect()/disconnect() as usual |
| loadModel(url \| ArrayBuffer) | load/swap a model; resolves with its sample rate |
| setInputGainDb(db) / setOutputGainDb(db) | drive (pre-model) and output level |
| setBypass(on) | dry passthrough without tearing down the node |
| on(fn) | subscribe to ready / loaded / error events |
| dispose() | disconnect and release |
Lower-level pieces (NamModel, NamProcessorCore, RingBuffer,
LinearResampler) are exported too, for offline rendering or custom graphs.
How it works
.nam model file ─► WASM (NeuralAmpModelerCore + Eigen, Emscripten)
▲ lock-free ring buffer
AudioContext ──► AudioWorkletProcessor ──► output
▲
TypeScript API (createNamNode, loadModel, events)- DSP core: upstream sdatkinson/NeuralAmpModelerCore, unmodified.
- WASM glue: this project's own Emscripten bindings (clean-room).
- TS layer: AudioWorklet wrapper, model loading, resampling, gain staging.
- No UI: the package ships zero components.
Source, demo, and build instructions: github.com/HappySoftwareLabs/nam-web.
Credits & licensing
- The neural inference core is NeuralAmpModelerCore by Steven Atkinson, MIT licensed. This project would not exist without it.
- The browser-WASM approach was pioneered by TONE3000 in
their fork.
nam-webis an independent, complementary implementation (headless engine vs. full player component). - MIT licensed.
