https://github.com/amjad50/dynwave
Audio player library for real-time streaming audio with auto resampling
https://github.com/amjad50/dynwave
audio audioplayerapi hacktoberfest resampling
Last synced: 10 months ago
JSON representation
Audio player library for real-time streaming audio with auto resampling
- Host: GitHub
- URL: https://github.com/amjad50/dynwave
- Owner: Amjad50
- License: mit
- Created: 2024-01-29T09:06:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T07:31:59.000Z (over 1 year ago)
- Last Synced: 2024-11-28T16:52:24.480Z (over 1 year ago)
- Topics: audio, audioplayerapi, hacktoberfest, resampling
- Language: Rust
- Homepage:
- Size: 36.1 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# dynwave
[](https://actions-badge.atrox.dev/Amjad50/dynwave/goto)
[](https://deps.rs/repo/github/Amjad50/dynwave)
[](./LICENSE)
[](https://crates.io/crates/dynwave)
[](https://docs.rs/dynwave/latest/dynwave/)
dynwave is a dynamic audio player based on fixed samples stream, written in Rust.
The purpose of this is to implement a cross platform audio player that plays audio samples stream generated and plays it real-time.
This works as a fusion between [rubato](https://crates.io/crates/rubato) and [cpal](https://crates.io/crates/cpal).
This is useful for emulators for example, where an emulation loop will be like this:
1) Run emulation for a frame.
2) Extract the collected audio samples for that frame.
3) Queue the samples for playing (using `dynwave`).
4) Take video frame and display it.
5) Repeat.
## Getting Started
You can use `dynwave` to play audio streams for your Rust projects.
### Cargo
Add it as a dependency in your `Cargo.toml` file:
```sh
cargo add dynwave
```
### Example usage
```rust
use dynwave::{AudioPlayer, BufferSize};
let mut player = AudioPlayer::::new(44100, BufferSize::OneSecond).unwrap();
// Start playing the audio
player.play().unwrap();
// generate audio samples (can be done in a emulation loop for example)
let samples = generate_samples();
player.queue(&samples);
// pause the audio
player.pause().unwrap();
```
## Minimum Supported Rust Version (MSRV)
The minimum supported Rust version for this crate is `1.70.0`.
## Contributing
Contributions are welcome, please open an issue or a PR if you have any suggestions or ideas.
Make sure to:
- Run `cargo fmt`.
- Run `cargo clippy`.
- Run `cargo test`.
## Projects using `dynwave`
> If you are using `dynwave` in your project, please open a PR to add it here.
| Project | Description |
| ------- | ----------- |
| [mizu](https://github.com/Amjad50/mizu) | A GameBoy emulator written in Rust (this is actually were this library originiated https://github.com/Amjad50/mizu/issues/11)|
| [trapezoid](https://github.com/Amjad50/trapezoid) | PSX emulator powered with Vulkan and Rust |
| [plastic](https://github.com/Amjad50/plastic) | NES emulator with TUI and GUI |
## License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details