@audio/weighting-k

中文文档
1.2.1发布于 2026/10/13MITTypeScriptES Module近 30 天下载 1.2万

ITU-R BS.1770-4 K-weighting: high-shelf + RLB highpass

原始使用文档

@audio/weighting-k npm MIT

ITU-R BS.1770-4 K-weighting — the loudness pre-filter behind LUFS

npm install @audio/weighting-k
import kWeighting from '@audio/weighting-k'

Time-domain K-weighting: two cascaded stages redesigned per sample rate from the canonical ITU-R BS.1770-4 Annex 1 analog prototype constants (De Man 2014, "Evaluation of Implementations of the ITU-R BS.1770 Loudness Algorithm" — the same design pyloudnorm uses). Stage 1 is a spherical-head high shelf (G=3.999843853973347 dB, Q=0.7071752369554196, fc=1681.974450955533 Hz); stage 2 is the RLB weighting highpass (Q=0.5003270373238773, fc=38.13547087602444 Hz, unnormalized {1,-2,1} numerator at any fs). At fs=48000 this reproduces the spec's published coefficient table to ~1e-11.

kWeighting(data)                          // in place, fs=48000
kWeighting(data, { fs: 44100 })
let sos = kWeighting.coefs(44100)         // 2 SOS sections (shelf, then RLB highpass)
kWeighting.response(2000, 48000)          // |H(2000)| — shelf boost
ParamDefault
fs48000sample rate — SOS recomputed when it changes mid-stream
StaticReturns
.coefs(fs)SOS2-section cascade (high shelf + RLB highpass) at rate fs, for analysis/plotting
.response(f, fs)number|H(f)| — exact magnitude of this atom's own .coefs(fs) cascade, not an independent approximation
.ms(channels, params)Float64Arraymean square of each channel's K-weighted block (input untouched; state per channel on params, same params every block): the BS.1770 measurement loop, fused, float64

Use when: implementing integrated/momentary/short-term loudness (LUFS) per ITU-R BS.1770 / EBU R128 — this is the mandated pre-filter, applied before mean-square gating and channel summing.


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

MIT © audiojs

版本与发布记录

@audio/weighting-k 共发布 6 个版本,首次发布于 2026/07/09;过去 12 个月发布了 6 个版本。

版本发布日期距今
1.2.1latest2026/10/1326 天前
1.2.02026/09/271 个月前
1.1.22026/07/113 个月前
1.1.12026/07/113 个月前
1.1.02026/07/093 个月前
1.0.02026/07/094 个月前

关于 @audio/weighting-k 的常见问题

@audio/weighting-k 是什么?

ITU-R BS.1770-4 K-weighting: high-shelf + RLB highpass

如何安装 @audio/weighting-k?

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

@audio/weighting-k 支持 TypeScript 吗?

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

@audio/weighting-k 支持 ESM 还是 CommonJS?

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

@audio/weighting-k 需要什么版本的 Node.js?

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

@audio/weighting-k 可以商用吗?

@audio/weighting-k 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@audio/weighting-k 的下载量有多少?

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

@audio/weighting-k 还在维护吗?

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