百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
W

web-audio-api-rs

> 编程语言
开源

一个 Rust 实现的 Web Audio API,可用于非浏览器环境

379 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个 Rust 实现的 Web Audio API,可用于非浏览器环境

Rust Web Audio API

A pure Rust implementation of the Web Audio API, for use in non-browser contexts

About the Web Audio API

The Web Audio API (MDN docs) provides a powerful and versatile system for controlling audio on the Web, allowing developers to choose audio sources, add effects to audio, create audio visualizations, apply spatial effects (such as panning) and much more.

Our Rust implementation decouples the Web Audio API from the Web. You can now use it in desktop apps, command line utilities, headless execution, etc.

Example usage

…

Check out the docs for more info.

Spec compliance

We have tried to stick to the official W3C spec as close as possible, but some deviations could not be avoided:

  • naming: snake_case instead of CamelCase
  • getters/setters methods instead of exposed attributes
  • introduced some namespacing
  • inheritance is modelled with traits

Bindings

We provide NodeJS bindings to this library over at so you can use this library by simply writing native NodeJS code.

This enables us to run the official WebAudioAPI test harness and track our spec compliance score.

Audio backends

By default, the cpal library is used for cross platform audio I/O.

We offer experimental support for the cubeb backend via the cubeb feature flag. Please note that cmake must be installed locally in order to run cubeb.

Feature flag Backends
cpal (default) ALSA, WASAPI, CoreAudio, Oboe (Android)
cpal-jack JACK
cpal-pipewire PipeWire
cpal-asio ASIO see
cubeb PulseAudio, AudioUnit, WASAPI, OpenSL, AAudio, sndio, Sun, OSS

Notes for Linux users

Using the library on Linux with the ALSA backend might lead to unexpected cranky sound with the default render size (i.e. 128 frames). In such cases, a simple workaround is to pass the AudioContextLatencyCategory::Playback latency hint when creating the audio context, which will increase the render size to 1024 frames:

rust
let audio_context = AudioContext::new(AudioContextOptions {
    latency_hint: AudioContextLatencyCategory::Playback,
    ..AudioContextOptions::default()
});

For real-time and interactive applications where low latency is crucial, you should instead rely on the JACK backend provided by cpal. To that end you will need a running JACK server and build your application with the cpal-jack feature, e.g. cargo run --release --features "cpal-jack" --example microphone.

Targeting the browser

We can go full circle and pipe the Rust WebAudio output back into the browser via cpal's wasm-bindgen backend. Check out an example WASM project. Warning: experimental!

Audio decoding support

Audio decoding is powered by Symphonia. The current implementation enables all Symphonia-supported audio formats and codecs, including AIFF, CAF, ISO/MP4, MKV/WebM, Ogg, WAV, AAC, ADPCM, ALAC, FLAC, MP1/MP2/MP3, PCM, and Vorbis.

Contributing

web-audio-api-rs welcomes contribution from everyone in the form of suggestions, bug reports, pull requests, and feedback.

To mirror the CI check locally, run:

bash
cargo fmt
cargo build --all-targets
cargo test --all-targets
cargo clippy --all-targets

The formatting and lint checks remain separate and can be run locally with:

bash
pre-commit run --all-files

If you need ideas for contribution, there are several ways to get started:

  • Try out some of our examples (located in the examples/ directory) and start building your own audio graphs
  • Found a bug or have a feature request? Submit an issue!
  • Issues labeled with good first issue are relatively easy starter issues.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in web-audio-api-rs by you, shall be licensed as MIT, without any additional terms or conditions.

License

This project is licensed under the MIT license.

Acknowledgements

The IR files used for HRTF spatialization are part of the LISTEN database created by the EAC team from Ircam.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rustaudiodsprustweb-audio-api

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言