#audio-devices #sound #pcm #miniaudio

om-fork-miniaudio

Bindings to the miniaudio C library. Fork until upstream is updated!

4 releases

0.12.2 Feb 7, 2025
0.12.1 Mar 16, 2024
0.12.0 Dec 6, 2022
0.11.0 Apr 16, 2022

#202 in Audio

Download history 3/week @ 2024-10-23 3/week @ 2024-10-30 5/week @ 2024-11-06 1/week @ 2024-11-13 4/week @ 2024-11-20 9/week @ 2024-11-27 11/week @ 2024-12-04 21/week @ 2024-12-11 5/week @ 2024-12-18 22/week @ 2025-01-15 4/week @ 2025-01-22 14/week @ 2025-01-29 139/week @ 2025-02-05

179 downloads per month

MIT license

5.5MB
141K SLoC

Rust 87K SLoC // 0.0% comments C 54K SLoC // 0.1% comments

Mini Audio Rust Bindings

Note: The upstream version is is archived. I currently don't use this anymore, but will do an update now and then. Most of it is untested.

Build Status crates.io docs.rs

Bindings to https://github.com/dr-soft/miniaudio

** The crate currently lacks documentation, but for the most part the API is very close the the API of the miniaudio C library. That can be found in the C library's main header file. **

Building

LLVM and clang must be installed in order to generate the bindings. Installation instructions can be found here: https://rust-lang.github.io/rust-bindgen/requirements.html

Example Usage

For more examples, check out the examples directory.

//! Enumerating Devices

use miniaudio::Context;

pub fn main() {
    let context = Context::new(&[], None).expect("failed to create context");

    context
        .with_devices(|playback_devices, capture_devices| {
            println!("Playback Devices:");
            for (idx, device) in playback_devices.iter().enumerate() {
                println!("\t{}: {}", idx, device.name());
            }

            println!("Capture Devices:");
            for (idx, device) in capture_devices.iter().enumerate() {
                println!("\t{}: {}", idx, device.name());
            }
        })
        .expect("failed to get devices");
}

Dependencies