ALSA audio output plugin
This plugin is what gets OxiGuitar’s sound out of your speakers or headphones on Linux. It hands the finished sound to ALSA (the Advanced Linux Sound Architecture), the sound layer built into the Linux kernel.
It uploads nothing and downloads nothing. It only plays sound on your computer.
It is the fallback for Linux systems where PipeWire isn’t running. PipeWire desktops pass ALSA’s sound on to PipeWire anyway, so it also works there, with a little more delay than the PipeWire plugin. It is the output the AppImage uses.
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 ALSA 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
- Exclusive access on some systems. Without a sound server, ALSA gives a device to one program at a time; another program playing sound may block OxiGuitar, or the other way round.
- More delay than PipeWire on PipeWire desktops, where ALSA’s sound takes a detour.
- Your system’s sound must already work. The plugin doesn’t repair or configure ALSA.
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 ALSA 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.
- Linux, on x86_64 or ARM64.
Assumptions
- Your system’s sound is working already. This plugin doesn’t repair it.
- ALSA is the common denominator. On a PipeWire desktop you get the same sound through the PipeWire plugin, with lower latency.
Installing
You need OxiGuitar first: its manual says how to get it. This page is about the ALSA audio output plugin.
From a release
Each release on the releases page has a zip for each Linux processor (x86_64 and ARM64), a .deb, an .rpm and a Flatpak for each, 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-alsa.oxp in your plugins folder:
| System | Your plugins folder |
|---|---|
| Linux | ~/.local/share/oxiguitar/plugins/ |
Start OxiGuitar again. Tools → Plugins… lists what it found. The same menu switches a plugin off, and deleting the file removes it.
Linux package managers
The package is called oxiguitar-alsa. It lives in a signed package repository on GitHub Pages that you add once.
Debian, Ubuntu and relatives:
sudo install -d -m 0755 /etc/apt/keyrings
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.gpg -o /etc/apt/keyrings/oxiguitar.gpg
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.sources -o /etc/apt/sources.list.d/oxiguitar.sources
sudo apt update
sudo apt install oxiguitar-alsa
Fedora and relatives:
sudo curl -fsSL https://mateusrdp.github.io/oxiguitar-packages/oxiguitar.repo -o /etc/yum.repos.d/oxiguitar.repo
sudo dnf install oxiguitar-alsa
Normal system updates keep the plugin current from then on.
OxiGuitar’s Flatpak is a sandbox that cannot see the system’s plugin folders, so it needs the plugin as a Flatpak extension. Flathub comes first because Flatpak takes its runtime from there:
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak remote-add --if-not-exists oxiguitar https://mateusrdp.github.io/oxiguitar-packages/flatpak/oxiguitar.flatpakrepo
flatpak install oxiguitar io.github.mateusrdp.OxiGuitar.Plugin.alsa
flatpak update keeps it current and flatpak remove takes it away.
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 linux: is a test that only runs on ALSA’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 ALSA output | Offers the audio-device service alsa, and nothing else, so the player can send its sound to ALSA. | tests::it_offers_only_the_alsa_audio_device, linux: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). | linux: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. | linux: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. | linux:tests::wrong_requests_are_refused |
| Only on ALSA’s system | Its manifest limits it to linux; anywhere else it is never available and says why. | oxiguitar_plugin_checks::the_manifest_matches_the_plugin, windows,macos:tests::elsewhere_it_says_it_runs_only_on_linux |
| A working plugin file | The .oxp file keeps the plugin contract, with this repository’s SDK version and with the newest release of OxiGuitar. | linux: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 linux 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-alsa/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 |
| alsa | David Henningsson and contributors | Talks to ALSA | Apache-2.0 OR MIT |
| Rust and its standard library | The Rust Project | Everything else | MIT OR Apache-2.0 |
The system
ALSA, by The ALSA project: the sound system itself, on your computer. 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 ALSA.