WASAPI audio output plugin
This plugin is what gets OxiGuitar’s sound out of your speakers or headphones on Windows. It hands the finished sound to WASAPI (the Windows Audio Session API), the sound system of Windows since Vista.
It uploads nothing and downloads nothing. It only plays sound on your computer.
On Windows you need an output plugin: without one OxiGuitar can’t play. This is the one to take.
What an audio output does
OxiGuitar works out the sound of a song as a stream of numbers, about 48,000 of them a second for each speaker. Something has to hand those numbers to the sound card, in small batches, always on time: if a batch is late, you hear a click or a gap. That is the job of the operating system’s sound system, and of this plugin, which connects OxiGuitar to it.
Two words come up when people talk about this:
- Latency is the delay between OxiGuitar sending sound and you hearing it. For playing back a song it hardly matters, because the cursor is moved to match what you hear; it matters for anything you play along live.
- The buffer is how much sound is handed over at a time. A bigger buffer is safer against clicks on a busy computer, at the cost of more latency.
Every operating system has its own sound system, and each needs its own code. OxiGuitar keeps each in a plugin of its own, so you install only the one your system uses.
How to use it shows where to pick the device.
How to use it
There is nothing to set up: install it, and OxiGuitar plays through it. The Output list in the player, at the top of the window, picks the device when you have more than one; System default follows whatever your system is set to:
Tools → Plugins… shows whether the plugin was found and loaded.
What you can do with it
- Hear a score. OxiGuitar makes the sound, and this plugin hands it to the system.
- Pick the output device, if you have more than one. The player’s Output list shows the devices this plugin offers.
A score plays through the sound plugin you have installed. See the OxiGuitar manual if you have no such plugin yet. Without an audio output plugin the player buttons stay greyed out, and OxiGuitar says so when it starts.
Architecture and strategy
The plugin gives OxiGuitar a list of devices and an audio stream. It is built on the cpal audio library, through a small layer that the other output plugins share, and it uses the WASAPI host of that library.
The strategy is one output plugin for each system’s own sound API, so each can be installed, updated and left out on its own. OxiGuitar picks among the installed outputs.
Current limitations
- Shared mode only. OxiGuitar shares the device with other programs, through Windows’ mixer. Exclusive mode, which takes the device over for the lowest delay, isn’t offered.
- No ASIO. The low-latency driver interface of many audio interfaces isn’t supported.
- Tested by machine only. Nobody has clicked through it on a real Windows computer yet: reports welcome.
- Your system’s sound must already work. The plugin doesn’t repair or configure WASAPI.
Left out on purpose
- A sound library of our own. cpal, the Rust audio library, already speaks every system’s sound API. All four output plugins share a thin layer over it, oxiguitar-audio-cpal.
- One plugin for every system. Each system’s output is a plugin of its own, so each is built, tested, updated and left out on its own, and a Linux install carries no Windows code.
- Recording. The output plugins only play. OxiGuitar has no audio input.
Where you can help
- Testing on real hardware, especially unusual sound cards, USB interfaces and Bluetooth headphones. Tell us what worked and what clicked.
- Lower latency settings, if you know WASAPI well.
Every change needs its tests and a row on the Features page; the Testing page says how to run them.
Requirements and assumptions
Requirements
- OxiGuitar 0.25 or later (the plugin asks for interface 3.0). See the OxiGuitar manual.
- Windows, on x86_64 or ARM64.
Assumptions
- Your system’s sound is working already. This plugin doesn’t repair it.
Installing
You need OxiGuitar first: its manual says how to get it. This page is about the WASAPI audio output plugin.
From a release
Each release on the releases page has a zip for each Windows processor (x86_64 and ARM64), a setup program for each that installs for you alone (no administrator password), and a SHA256SUMS file to check the downloads against. Take the file that matches your system.
Copying the file yourself
A plugin is a single file ending in .oxp. Unzip the release for your system and put audio-wasapi.oxp in your plugins folder:
| System | Your plugins folder |
|---|---|
| Windows | %APPDATA%\OxiGuitar\plugins\ |
Start OxiGuitar again. Tools → Plugins… lists what it found. The same menu switches a plugin off, and deleting the file removes it.
Features and their tests
Everything this plugin does, and the tests that check it. The test names are the ones cargo test prints; a name after windows: is a test that only runs on WASAPI’s system. scripts/test-all.py fails when a feature here names no test, or names a test that doesn’t exist, so a new feature gets its row and its tests in the same pull request (the Testing page says how to run them).
The plugin is a thin layer: opening, feeding and closing the output stream is OxiGuitar’s own oxiguitar-audio-cpal code (through cpal), which this plugin uses as released. Hearing the sound needs a sound card, so the tests check everything up to it.
| Feature | What it does | Tests |
|---|---|---|
| The WASAPI output | Offers the audio-device service wasapi, and nothing else, so the player can send its sound to WASAPI. | tests::it_offers_only_the_wasapi_audio_device, windows:contract::the_plugin_file_keeps_the_contract |
| Says when it can’t play | Probing tells the player whether there’s an output, and why not when there isn’t (shown in the footer and Tools > Plugins). | windows:tests::probing_says_whether_there_is_an_output |
| Picks the output device | Lists the system’s output devices by name for the footer’s output chooser. | windows:tests::listing_the_outputs_answers_with_or_without_a_device |
| Refuses wrong requests | A damaged request to open an output, or a method it doesn’t have, gets an error, never a crash. | windows:tests::wrong_requests_are_refused |
| Only on WASAPI’s system | Its manifest limits it to windows; anywhere else it is never available and says why. | oxiguitar_plugin_checks::the_manifest_matches_the_plugin, linux,macos:tests::elsewhere_it_says_it_runs_only_on_windows |
| A working plugin file | The .oxp file keeps the plugin contract, with this repository’s SDK version and with the newest release of OxiGuitar. | windows:contract::the_plugin_file_keeps_the_contract, stage:contract (latest core) |
Testing
Every test of this repository runs with one command, on your own machine, and anyone can run it. When something fails, it tells you how to report it.
Run everything
python3 scripts/test-all.py
On Windows, type python instead of python3 if that’s what you have.
You need:
- Rust, from rustup (the version in
Cargo.toml’srust-versionor newer); - git, and Python 3.8 or newer (nothing to install with pip);
- on Linux, the libraries a build needs:
libasound2-dev,libpipewire-0.3-devandlibclang-devon Debian and Ubuntu (alsa-lib-devel,pipewire-develandclang-develon Fedora);
It runs:
- every Rust test of the repository (
cargo testover the whole workspace), with a progress bar; - the plugin against the newest release of OxiGuitar: it fetches that release’s source with git (once per release, kept in a cache folder every OxiGuitar repository on your machine shares:
~/.cache/oxiguitar-test-all,~/Library/Caches/oxiguitar-test-allon macOS,%LOCALAPPDATA%\oxiguitar-test-allon Windows, orOXIGUITAR_TEST_CACHE), builds itsoxiguitar-cliandoxiguitar-plugin-test, builds this repository’s plugin file for your system and runs the plugin contract on it; - a check of the Features page: every feature names a test, and every test it names exists.
It tests the system and processor it runs on, and only those (as Rust sees them: rustc -vV’s host). Tests for other systems are left out and the summary says so; they are not failures.
This repository is for windows only: elsewhere the script says there’s nothing to test and stops.
What you get
A line per stage while it runs, then the result. In target/test-all/<date>-<time>/:
summary.md: the result, your system, what failed and why, short enough to paste into a GitHub issue;test-all.log: everything that happened, every command and its output;
The script exits with 0 when everything passed, 1 when something failed, and 2 when it couldn’t start.
When something fails
- Update to the newest
develop(git checkout develop && git pull) and run it again: it may be fixed already. - Look for an issue about the same test at github.com/mateusrdp/oxiguitar-wasapi/issues.
- Otherwise open one: call it
test-all: <the first failing test>, paste the wholesummary.md, and attachtest-all.log(drag it onto the text box; zip it first if it’s over 25 MB). Read the log first: it has your folder names, so change anything you’d rather keep private. - You can also give
summary.mdandtest-all.logto a language model along with this repository and ask it to find the cause.
Options
--release: an optimised test build: slower to build, faster corpus tests.--ignore-rust-version: for a Rust older thanrust-version(unsupported, but handy).--core DIR: test against a checkout of OxiGuitar you already have, instead of its newest release;--core-version v0.21.5picks a release.--out DIR: where the results go.
Adding a feature
A new feature comes with its tests and a row on the Features page, in the same pull request; a new corpus test uses tests/support/corpus.rs. The script fails until the row names tests that exist.
Credits
Thank you to the people whose work this plugin is built on.
Code we use
| Project | Authors | What it does here | Licence |
|---|---|---|---|
OxiGuitar’s plugin SDK (oxiguitar-plugin, and oxiguitar-plugin-test for the tests) | Mateus Rocha de Paula and the OxiGuitar contributors | The plugin interface | MIT OR Apache-2.0 |
| oxiguitar-audio-cpal | Mateus Rocha de Paula and the OxiGuitar contributors | The layer all four output plugins share | GPL-3.0-or-later |
| cpal | The RustAudio contributors | Devices and the audio stream, on every system | Apache-2.0 |
| windows-rs | Microsoft and contributors | Talks to WASAPI | MIT OR Apache-2.0 |
| Rust and its standard library | The Rust Project | Everything else | MIT OR Apache-2.0 |
The system
WASAPI, by Microsoft: the sound system itself, part of Windows. The plugin only calls it.
Tools
| Tool | Use |
|---|---|
| mdBook | Builds this manual |
| cargo-deny | Checks the licences of everything we build with |
Thanks
To the RustAudio community for cpal, which turns four very different sound systems into one, and to the people behind WASAPI.