{"id":19276500,"url":"https://github.com/orottier/web-audio-api-rs","last_synced_at":"2025-04-12T22:25:09.387Z","repository":{"id":38007846,"uuid":"332851350","full_name":"orottier/web-audio-api-rs","owner":"orottier","description":"A Rust implementation of the Web Audio API, for use in non-browser contexts","archived":false,"fork":false,"pushed_at":"2024-04-14T09:55:57.000Z","size":11448,"stargazers_count":244,"open_issues_count":41,"forks_count":14,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-04-14T15:19:41.523Z","etag":null,"topics":["audio","dsp","rust","web-audio-api","webaudio"],"latest_commit_sha":null,"homepage":"https://docs.rs/web-audio-api/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/orottier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-01-25T18:56:50.000Z","updated_at":"2024-04-15T19:45:20.257Z","dependencies_parsed_at":"2024-03-11T17:02:14.720Z","dependency_job_id":"2b3956db-94eb-4b64-af90-5c18cc4d40c2","html_url":"https://github.com/orottier/web-audio-api-rs","commit_stats":{"total_commits":1142,"total_committers":8,"mean_commits":142.75,"dds":0.6042031523642732,"last_synced_commit":"3b26ae63e7bce1a0dadba991766ee1e3e565559f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orottier%2Fweb-audio-api-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orottier%2Fweb-audio-api-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orottier%2Fweb-audio-api-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/orottier%2Fweb-audio-api-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/orottier","download_url":"https://codeload.github.com/orottier/web-audio-api-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248638811,"owners_count":21137713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","dsp","rust","web-audio-api","webaudio"],"created_at":"2024-11-09T20:54:44.081Z","updated_at":"2025-04-12T22:25:09.349Z","avatar_url":"https://github.com/orottier.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Rust Web Audio API\n\n[![crates.io](https://img.shields.io/crates/v/web-audio-api.svg)](https://crates.io/crates/web-audio-api)\n[![docs.rs](https://img.shields.io/docsrs/web-audio-api)](https://docs.rs/web-audio-api)\n\nA pure Rust implementation of the Web Audio API, for use in non-browser contexts\n\n## About the Web Audio API\n\nThe [Web Audio API](https://www.w3.org/TR/webaudio/)\n([MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API))\nprovides a powerful and versatile system for controlling audio on the Web,\nallowing developers to choose audio sources, add effects to audio, create audio\nvisualizations, apply spatial effects (such as panning) and much more.\n\nOur Rust implementation decouples the Web Audio API from the Web. You can now\nuse it in desktop apps, command line utilities, headless execution, etc.\n\n## Example usage\n\n```rust,no_run\nuse web_audio_api::context::{AudioContext, BaseAudioContext};\nuse web_audio_api::node::{AudioNode, AudioScheduledSourceNode};\n\n// set up the audio context with optimized settings for your hardware\nlet context = AudioContext::default();\n\n// for background music, read from local file\nlet file = std::fs::File::open(\"samples/major-scale.ogg\").unwrap();\nlet buffer = context.decode_audio_data_sync(file).unwrap();\n\n// setup an AudioBufferSourceNode\nlet mut src = context.create_buffer_source();\nsrc.set_buffer(buffer);\nsrc.set_loop(true);\n\n// create a biquad filter\nlet biquad = context.create_biquad_filter();\nbiquad.frequency().set_value(125.);\n\n// connect the audio nodes\nsrc.connect(\u0026biquad);\nbiquad.connect(\u0026context.destination());\n\n// play the buffer\nsrc.start();\n\n// enjoy listening\nstd::thread::sleep(std::time::Duration::from_secs(4));\n```\n\nCheck out the [docs](https://docs.rs/web-audio-api) for more info.\n\n## Spec compliance\n\nWe have tried to stick to the official W3C spec as close as possible, but some\ndeviations could not be avoided:\n\n- naming: snake_case instead of CamelCase\n- getters/setters methods instead of exposed attributes\n- introduced some namespacing\n- inheritance is modelled with traits\n\n## Bindings\n\nWe provide NodeJS bindings to this library over at\n\u003chttps://github.com/ircam-ismm/node-web-audio-api\u003e so you can use this library\nby simply writing native NodeJS code.\n\nThis enables us to run the official [WebAudioAPI test\nharness](https://github.com/web-platform-tests/wpt/tree/master/webaudio) and\n[track our spec compliance\nscore](https://github.com/ircam-ismm/node-web-audio-api/issues/57).\n\n## Audio backends\n\nBy default, the [`cpal`](https://github.com/rustaudio/cpal) library is used for\ncross platform audio I/O.\n\nWe offer [experimental support](https://github.com/orottier/web-audio-api-rs/issues/187) for the\n[`cubeb`](https://github.com/mozilla/cubeb-rs) backend via the `cubeb` feature\nflag. Please note that `cmake` must be installed locally in order to run\n`cubeb`.\n\n| Feature flag   | Backends                                                       |\n| -------------- | -------------------------------------------------------------- |\n| cpal (default) | ALSA, WASAPI, CoreAudio, Oboe (Android)                        |\n| cpal-jack      | JACK                                                           |\n| cpal-asio      | ASIO see \u003chttps://github.com/rustaudio/cpal#asio-on-windows\u003e   |\n| cubeb          | PulseAudio, AudioUnit, WASAPI, OpenSL, AAudio, sndio, Sun, OSS |\n\n### Notes for Linux users\n\nUsing the library on Linux with the ALSA backend might lead to unexpected\ncranky sound with the default render size (i.e. 128 frames). In such cases, a\nsimple workaround is to pass the `AudioContextLatencyCategory::Playback`\nlatency hint when creating the audio context, which will increase the render\nsize to 1024 frames:\n\n```rs\nlet audio_context = AudioContext::new(AudioContextOptions {\n    latency_hint: AudioContextLatencyCategory::Playback,\n    ..AudioContextOptions::default()\n});\n```\n\nFor real-time and interactive applications where low latency is crucial, you\nshould instead rely on the JACK backend provided by `cpal`. To that end you\nwill need a running JACK server and build your application with the `cpal-jack`\nfeature, e.g. `cargo run --release --features \"cpal-jack\" --example\nmicrophone`.\n\n### Targeting the browser\n\nWe can go full circle and pipe the Rust WebAudio output back into the browser\nvia `cpal`'s `wasm-bindgen` backend. Check out [an example WASM\nproject](https://github.com/orottier/wasm-web-audio-rs).\nWarning: experimental!\n\n## Contributing\n\nweb-audio-api-rs welcomes contribution from everyone in the form of\nsuggestions, bug reports, pull requests, and feedback. 💛\n\nIf you need ideas for contribution, there are several ways to get started:\n\n- Try out some of our examples (located in the `examples/` directory) and start\n  building your own audio graphs\n- Found a bug or have a feature request?\n  [Submit an issue](https://github.com/orottier/web-audio-api-rs/issues/new)!\n- Issues labeled with\n  [good first issue](https://github.com/orottier/web-audio-api-rs/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22good+first+issue%22)\n  are relatively easy starter issues.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in web-audio-api-rs by you, shall be licensed as MIT, without any\nadditional terms or conditions.\n\n## License\n\nThis project is licensed under the [MIT license].\n\n[mit license]: https://github.com/orottier/web-audio-api-rs/blob/main/LICENSE\n\n## Acknowledgements\n\nThe IR files used for HRTF spatialization are part of the LISTEN database\ncreated by the EAC team from Ircam.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forottier%2Fweb-audio-api-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forottier%2Fweb-audio-api-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forottier%2Fweb-audio-api-rs/lists"}