cdp-wasm

The Composers Desktop Project (CDP) compiled to WebAssembly and wrapped in a small typed API
for Node.js and the browser.
npm i cdp-wasm # the library
npm i -g cdp-wasm # the `cdp` command line tool
Quick start · Effect catalog ·
Command line · Agent skills ·
Install details · FAQ
The published package ships the
prebuilt .wasm; you do not need the submodule or a toolchain. The
submodule below is only for building from source.
Architecture
CDP programs are individual command-line tools: each reads and writes audio
files and takes its parameters as command-line arguments. This package adds a
few layers on top so you can drive them with in-memory audio buffers and named
parameters, in Node and the browser.
- WebAssembly modules — each CDP program compiled to a
.wasm, sharing one
cdp-core (libc + the CDP core libraries). This is the full suite: the same
programs, arguments and file formats as native CDP.
- The
CDP runtime (cdp.run / cdp.process) — stages your audio into an
in-memory filesystem, runs the program, and returns the result as byte arrays
/ AudioBuffers. You work with Uint8Arrays rather than files on disk, and
$IN/$OUT tokens stand in for paths. Every bundled program is reachable here.
- Data helpers (
decodeWav, extractEnvelope, getPitch, findPeaks, …) —
convert CDP's audio and text formats to and from plain JS values: float
channel data, [[time, value], …] breakpoint arrays, pitch contours, peak times.
- The typed catalog (
EFFECTS / applyEffect, GENERATORS /
applyGenerator) — describes each effect and generator as data (named
parameters with ranges and defaults) and runs it for you, taking care of
spectral (pvoc) analysis/resynthesis wrapping, per-channel splitting and
recombining, two-input effects, breakpoint automation, and multi-step pipelines.
applyEffect(cdp, effect, values, wav) typed catalog — named params, pvoc + channels
└─ cdp.process(program, args, bytes) byte interface — $IN/$OUT, one in / one out
└─ cdp.run(program, argv) in-memory FS staging + callMain(argv)
└─ blur.wasm on cdp-core a CDP program (same arguments/formats as native)
Each layer is usable on its own: reach for the catalog when you want ready-made
effects with named parameters, or drop down to cdp.run for any bundled program
the catalog doesn't cover.
Building from source
The CDP C sources are a pinned git submodule (CDP8/) tracking the
cdp-wasm-suite/CDP8 fork of upstream
ComposersDesktop/CDP8 — upstream
plus a small set of bug fixes and portability changes (Emscripten support
among them), each maintained as a reviewable topic branch on the fork and
proposed upstream. The sources build unmodified; nothing is patched at build
time.
git clone --recurse-submodules https://github.com/cdp-wasm-suite/cdp-wasm
cd cdp-wasm
source /path/to/emsdk/emsdk_env.sh # activate Emscripten
npm run build:wasm # builds wasm/
npm test # catalog (mono+stereo), helpers, CLI, externals, docs
(If you cloned without --recurse-submodules, run git submodule update --init.)
Build knobs (env vars): CDP_SPECTRAL_O3=0 reverts the core + FFT/spectral
programs to -Oz instead of the default -O3 (smaller, ~15% slower
spectral; time-domain programs are always -Oz); CDP_WASM_OUT=<dir> writes
to an alternate output dir; CDP_SIMD_FFT=0 disables the hand-written SIMD128 FFT that
replaces the Singleton FFT in the phase-vocoder path (pvoc/synth) and
fastconv — it is on by default and gated by a build-time scalar-vs-SIMD
self-test. Engines without SIMD128 are handled at runtime, not build
time: each SIMD-bearing program also ships a <program>.scalar.* variant
(~250 KB total), and the loader auto-detects the engine's SIMD support and
picks the right one — old webviews and pre-16.4 Safari/Node just work, a few
percent slower. new CDP({ simd: false }) forces the scalar variants
explicitly. npm run bench measures performance against a baseline build.