npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wydev/noise-core

v0.1.0

Published

Core noise monitoring and scoring engine extracted from Immersive Clock Monitor

Readme

@wydev/noise-core

@wydev/noise-core 是从 Immersive Clock Monitor 拆分出的核心噪音监测库,包含:

  • 音频帧数学计算(RMS / dBFS / 分位数 / 线性能量平均)
  • 三维度噪音评分引擎
  • 浏览器端实时噪音流服务(Web Audio API)
  • 噪音控制设置的读取、保存与事件订阅
  • 完整 TypeScript 类型与常量导出

安装

npm i @wydev/noise-core

快速上手

import {
  noiseService,
  computeNoiseSliceScore,
  getNoiseControlSettings,
  type NoiseSliceRawStats,
} from "@wydev/noise-core";

// 1) 启动实时监测
await noiseService.start();

// 2) 订阅实时快照
const unsubscribe = noiseService.subscribe((snapshot) => {
  console.log(snapshot.status, snapshot.currentDisplayDb, snapshot.currentScore);
});

// 3) 离线评分(可用于服务端/批处理)
const raw: NoiseSliceRawStats = {
  avgDbfs: -56,
  maxDbfs: -32,
  p50Dbfs: -54,
  p95Dbfs: -38,
  overRatioDbfs: 0.16,
  segmentCount: 3,
};
const { score } = computeNoiseSliceScore(raw, 30_000);
console.log("slice score:", score);

// 4) 停止并取消订阅
unsubscribe();
noiseService.stop();

导出模块

  • 常量:constants.ts
  • 类型:types.ts
  • 数学函数:services/noiseMath.ts
  • 噪音流服务:services/noiseService.ts
  • 设置管理:utils/noiseControlSettings.ts
  • 评分引擎:utils/noiseScoreEngine.ts

包入口:@wydev/noise-core(统一 re-export)

核心 API

noiseService

单例服务,主要方法:

  • start(): Promise<void> 启动麦克风采集与分析
  • stop(): void 停止采集并释放音频资源
  • subscribe(listener): () => void 订阅实时快照,返回取消订阅函数
  • calibrate(targetDb, callback?): void 进行 3 秒基准校准
  • getHistory(): NoiseSliceSummary[] 读取历史切片
  • clearHistory(): void 清空历史切片

评分相关

  • computeNoiseSliceScore(raw, durationMs)
    • 输入:原始统计 + 切片时长
    • 输出:{ score, scoreDetail }
    • 评分模型:持续噪音 40% + 超阈时长 30% + 打断频次 30%

数学工具

  • computeRmsAndPeak(data)
  • computeDbfsFromRms(rms)
  • computeDisplayDbFromRms({ rms, baselineRms, baselineDb })
  • computeAvgDbfsFromDbfsArray(dbfsArr)
  • computeQuantileFromDbfsArray(dbfsArr, p)
  • clamp01(val)

设置管理

  • getNoiseControlSettings()
  • saveNoiseControlSettings(partial)
  • resetNoiseControlSettings()
  • subscribeSettingsEvent(handler)
  • SETTINGS_UPDATED_EVENT

运行环境

浏览器依赖

以下能力依赖浏览器环境,不可在纯 Node.js 下直接使用:

  • noiseService(依赖 windownavigator.mediaDevicesAudioContext
  • 设置读写函数(依赖 localStoragewindow 事件)

可在 Node.js 运行

纯算法能力可在 Node.js 使用:

  • computeNoiseSliceScore
  • noiseMath 中的大部分函数
  • 类型与常量

存储行为

  • 历史切片默认存储在 localStoragenoise-slices-v2
  • 设置存储在 noise-control-settings
  • 历史自动清理策略:保留最近 14 天,最多 1000 条

本地开发

在 monorepo 根目录执行:

npm run build --workspace @wydev/noise-core

产物输出到:packages/noise-core/dist

发布到 npm

# 1) 确认版本号(先修改 packages/noise-core/package.json)
# 2) 构建
npm run build --workspace @wydev/noise-core

# 3) 发布
npm publish --workspace @wydev/noise-core --access public

License

沿用仓库根目录 License。