Skip to content

Add bounded FLAC Wasm encoding and async streaming decoding - #2

Merged
tamashi095 merged 2 commits into
mainfrom
feat/1-flac-wasm
Sep 13, 2026
Merged

tamashi095 merged 2 commits into
mainfrom
feat/1-flac-wasm

Conversation

@tamashi095

Copy link
Copy Markdown
Contributor

Adds @misofm/codec with incremental FLAC encoding and asynchronous streaming decoding, built with Bun and Effect v4 around pinned libFLAC 1.5.0 Wasm. The decoder emits metadata, bounded packed PCM, and a verified completion event, providing the codec boundary needed for a later engine-web-adapter migration.

Encoding uses level 8 without exhaustive model search and a caller-owned random-access sink. Decoding suspends for asynchronous input within a frame, observes downstream backpressure, and uses fixed 2 MiB Wasm memory. Portable assets and Node/Bun loading Layers ship in the package.

Validation includes native libFLAC oracles, corruption/fragmentation/cancellation and allocator tests, byte-for-byte Wasm rebuilds, and fresh packed consumers on Bun, Node, Chromium, Firefox, and WebKit for both advertised Effect peers. The server benchmark covers all 137 chunks across 30 stems with three serial warm rounds and exact PCM verification; detailed receipts and review evidence are recorded in issue #1's spec.

The final server run produced 425,689,892 FLAC bytes versus native’s 425,690,361 bytes. Median encoding time was 60.580 seconds for Wasm versus 15.554 seconds native (3.895×); all PCM hashes matched. The receipt documents a brief packed-test overlap in warm round 1.

Adapter, CLI, and transcoder integration remain separate changes. This PR does not publish an npm release.

Closes #1

@tamashi095
tamashi095 marked this pull request as ready for review September 13, 2026 05:16
@tamashi095
tamashi095 merged commit 544aaa9 into main Sep 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build bounded FLAC encoding and async streaming decoding with pinned libFLAC Wasm

1 participant