@audio/decode-wavpack

中文文档
2.0.0发布于 2026/09/29BSD-3-ClauseTypeScriptES Module零依赖近 30 天下载 54.7万

Decode WavPack (.wv) audio with libwavpack WASM

原始使用文档

@audio/decode-wavpack npm BSD-3-Clause

Decode WavPack (.wv) to PCM float samples

npm install @audio/decode-wavpack
import decode, { decoder } from '@audio/decode-wavpack'

libwavpack (the reference WavPack 5 implementation, David Bryant) compiled to a single-file WASM ES module — no side files, loads from any CDN, Node, workers and AudioWorklets. Handles everything the format defines: lossless and hybrid/lossy, 8/16/24/32-bit integer and 32-bit float, mono through multichannel, and DSD-as-PCM (OPEN_DSD_AS_PCM, decimated to 24-bit PCM by the library). Streaming decode drives libwavpack's own block reader through a memory-backed WavpackStreamReader64, so multichannel block groups and adaptive decorrelation state are handled exactly as the reference library handles them — this package only tracks byte-level block boundaries.

let { channelData, sampleRate } = await decode(wvBytes)

let dec = await decoder()
let head = dec.decode(chunk1)   // synchronous; partial blocks carry over
let tail = dec.flush()          // drops an incomplete trailing block, if any
dec.free()
Export
decode(src)Promise<AudioData>Whole-stream decode
decoder()Promise<{decode, flush, free}>Streaming decoder; decode(chunk) is synchronous

AudioData is { channelData: Float32Array[], sampleRate: number }, samples in [-1, 1]. Integer PCM is scaled by 2^(bits-1) (asymmetric, matching WAV convention: max positive sample maps to <1, max negative to exactly -1); float PCM is a direct bit reinterpretation (WavPack stores float samples pre-normalized when opened with OPEN_NORMALIZE, which this package always sets). Channels come out in the order libwavpack reports them, which for standard Microsoft-ordered sources (anything ffmpeg or the WavPack CLI produces) is WAV order: FL, FR, FC, LFE, BL, BR, ...

decode() drains every sample libwavpack can produce from the blocks fed so far, every call — there's no encoder lookahead or block-spanning delay to hold back, so flush() only ever discards an incomplete trailing block (a stream cut off mid-block) and returns nothing new.

Hybrid/lossy WavPack (-b<n>) decodes at whatever quality it was encoded at; the .wvc correction file (lossless-hybrid two-file mode) is not read — only the standalone .wv bitstream. A garbage or non-WavPack input throws instead of returning empty/wrong data.

Use when: you need a from-scratch, spec-accurate WavPack decoder in the browser or Node — audio tools reading .wv files, WavPack-in-container demuxers, or any pipeline that already speaks @audio's {channelData, sampleRate} shape.


Part of @audio/decode — the decode family umbrella.

ॐ · BSD-3-Clause, inherited from the bundled libwavpack.

版本与发布记录

@audio/decode-wavpack 共发布 2 个版本,首次发布于 2026/08/29;过去 12 个月发布了 2 个版本。

版本发布日期距今
2.0.0latest2026/09/291 个月前
1.0.02026/08/292 个月前

关于 @audio/decode-wavpack 的常见问题

@audio/decode-wavpack 是什么?

Decode WavPack (.wv) audio with libwavpack WASM

如何安装 @audio/decode-wavpack?

在项目目录运行 npm install @audio/decode-wavpack,或使用 pnpm add / yarn add / bun add。

@audio/decode-wavpack 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@audio/decode-wavpack 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@audio/decode-wavpack 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@audio/decode-wavpack 可以商用吗?

@audio/decode-wavpack 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@audio/decode-wavpack 的下载量有多少?

根据 npm 官方下载统计,@audio/decode-wavpack 在 2026/10/07 – 2026/11/05 这 30 天内被下载 546,514 次,日均约 18,217 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@audio/decode-wavpack 还在维护吗?

最新版本 2.0.0 发布于 2026/09/29(1 个月前);至今共发布 2 个版本,其中过去 12 个月发布了 2 个;首次发布于 2026/08/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。