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

@ra2web/wavefile

v1.0.2

Published

WAV file processing library from ra2web project

Downloads

45

Readme

@ra2web/wavefile

一个从ra2web项目中提取的WAV文件处理库。该库提供了读取、写入和操作WAV音频文件的全面功能。

特性

  • 读写WAV文件
  • 支持多种位深(8、16、24、32、64位)
  • 支持浮点音频格式(32f、64)
  • 音频压缩格式(IMA-ADPCM、A-Law、μ-Law)
  • 采样率转换
  • 位深转换
  • 音频格式转换
  • Base64编码/解码
  • 数据URI支持

安装

npm install @ra2web/wavefile

使用

基础用法

import { WaveFile } from '@ra2web/wavefile';

// 创建新的WaveFile实例
const wav = new WaveFile();

// 从缓冲区加载
const buffer = /* 你的音频缓冲区 */;
wav.fromBuffer(buffer);

// 访问音频属性
console.log('采样率:', wav.fmt.sampleRate);
console.log('声道数:', wav.fmt.numChannels);
console.log('位深:', wav.bitDepth);

// 获取采样值
const samples = wav.getSamples();

// 转换为不同格式
wav.toBitDepth('16');
wav.toSampleRate(44100);

// 导出为缓冲区
const outputBuffer = wav.toBuffer();

格式转换

// 转换为不同压缩格式
wav.toALaw();        // 转换为A-Law
wav.toMuLaw();       // 转换为μ-Law
wav.toIMAADPCM();    // 转换为IMA-ADPCM

// 从压缩格式转换
wav.fromALaw();
wav.fromMuLaw();
wav.fromIMAADPCM();

Base64和数据URI支持

// 转换为Base64
const base64String = wav.toBase64();

// 从Base64加载
wav.fromBase64(base64String);

// 转换为数据URI
const dataUri = wav.toDataURI();

// 从数据URI加载
wav.fromDataURI(dataUri);

API参考

WaveFile类

构造函数

  • new WaveFile(buffer?) - 创建新的WaveFile实例(可选从缓冲区初始化)

方法

文件I/O
  • fromBuffer(buffer) - 从缓冲区加载WAV数据
  • toBuffer() - 导出WAV数据为缓冲区
  • fromBase64(base64String) - 从Base64字符串加载WAV数据
  • toBase64() - 导出WAV数据为Base64字符串
  • fromDataURI(dataUri) - 从数据URI加载WAV数据
  • toDataURI() - 导出WAV数据为数据URI
格式转换
  • toBitDepth(bitDepth, dithered?) - 转换位深
  • toSampleRate(sampleRate, options?) - 转换采样率
  • toRIFF() - 转换为RIFF格式
  • toRIFX() - 转换为RIFX格式
压缩
  • toALaw() - 转换为A-Law压缩
  • fromALaw(bitDepth?) - 从A-Law压缩转换
  • toMuLaw() - 转换为μ-Law压缩
  • fromMuLaw(bitDepth?) - 从μ-Law压缩转换
  • toIMAADPCM() - 转换为IMA-ADPCM压缩
  • fromIMAADPCM(bitDepth?) - 从IMA-ADPCM压缩转换
音频数据
  • getSamples(interleaved?) - 获取音频采样值

属性

  • fmt - 格式块数据
  • data - 音频数据块
  • bitDepth - 当前位深
  • container - 容器格式(RIFF/RIFX/RF64)

许可证

MIT

贡献

本库从ra2web项目中提取。有关问题和贡献,请参考原始项目仓库。