13 breaking releases

0.15.0 Jun 17, 2024
0.14.0 Oct 25, 2023
0.13.0 Jul 19, 2023
0.12.0 Mar 28, 2022
0.3.0 Jul 8, 2021

#260 in Windows APIs

Download history 53/week @ 2024-08-18 163/week @ 2024-08-25 168/week @ 2024-09-01 212/week @ 2024-09-08 136/week @ 2024-09-15 125/week @ 2024-09-22 31/week @ 2024-09-29 18/week @ 2024-10-06 20/week @ 2024-10-13 19/week @ 2024-10-20 17/week @ 2024-10-27 39/week @ 2024-11-03 31/week @ 2024-11-10 24/week @ 2024-11-17 210/week @ 2024-11-24 41/week @ 2024-12-01

317 downloads per month
Used in win-audio-devices-cli

MIT license

82KB
1.5K SLoC

Wasapi bindings for Rust

The aim of this crate is to provide easy and safe access to the Wasapi API for audio playback and capture.

The presented API is all safe Rust, but structs and functions closely follow the original Windows API.

For details on how to use Wasapi, please see the Windows documentation.

Bindings are generated automatically using the windows crate.

Supported functionality

These things have been implemented so far:

  • Audio playback and capture
  • Shared and exclusive modes
  • Event-driven buffering
  • Loopback capture
  • Notifications for volume change, device disconnect etc

Included examples

Example Description
playsine Plays a sine wave in shared mode on the default output device.
playsine_events Similar to playsine but also listens to notifications.
playnoise_exclusive Plays white noise in exclusive mode on the default output device. Shows how to handle HRESULT errors.
loopback Shows how to simultaneously capture and render sound, with separate threads for capture and render.
record Records audio from the default device, and saves the raw samples to a file.
devices Lists all available audio devices and displays the default devices.
record_application Records audio from a single application, and saves the raw samples to a file.

Dependencies

~128MB
~2M SLoC