Audio export plugin
This plugin turns a song into an audio file you can share, practise with or load into another program. File → Export Audio… plays the whole song, or the selected bars, through every instrument, amp and mixer setting you have, a lot faster than real time, and this plugin writes the result as a WAV, FLAC, MP3 or Opus file. How to use it shows the dialog.
It took the place of the older WAV plugin (up to version 0.1.2), which OxiGuitar no longer loads; you can remove the old package, oxiguitar-wav.
This plugin needs the MIDI plugin, which makes the sound that gets written. See its manual.
A little about digital audio
Sound in a computer is a long list of numbers, samples, each one the position of the speaker cone at one instant. Two settings decide how fine that list is:
- Sample rate: how many samples a second. CDs use 44,100 (44.1 kHz); video and most audio software use 48,000 (48 kHz). Both capture everything people can hear, so pick the one the place you are sending the file to expects.
- Bit depth: how precisely each sample is stored. 16 bits is CD quality. 24 bits leaves more room for later editing. 32-bit float is what audio programs use inside and can’t clip.
Going down to 16 bits rounds every sample a little, which on quiet passages can leave a faint, gritty distortion. Dither adds a whisper of random noise before the rounding so the error becomes a smooth, inaudible hiss instead. The plugin does this by itself whenever it writes 16 bits.
Lossless and lossy
- WAV stores the samples as they are. Every program reads it, and files are big: about 10 MB a minute at 16 bits and 44.1 kHz in stereo.
- FLAC is lossless: it packs the same samples into about half the space, like a ZIP file for sound, and gives back exactly the same numbers when played.
- MP3 and Opus are lossy: they throw away what the ear is least likely to notice, and files come out around a tenth the size of WAV or smaller. MP3 plays everywhere. Opus, the newer one, sounds better at the same size; it is also the codec web browsers use for voice and video calls. How much they keep is the bitrate, in kilobits per second (kbps); variable bitrate (VBR, MP3’s V0 to V4) spends more on busy passages and less on quiet ones.
A lossy file is fine for listening and sharing. To edit the sound later, or to keep a master copy, use WAV or FLAC.
Gapless
MP3 and Opus encoders normally add a little silence at the start and end of a file. The plugin records how much in the file, so a player that understands it (most do) starts and ends exactly where the song does, and a loop plays without a gap.
How to use it
Export a song
- Open the song, and set it up the way you want to hear it: each track’s sound, amp, equalizer, volume, pan, mute and solo all go into the file as they are.
- Choose File → Export Audio…:
- Pick a Format:
- Set the format’s own choices, which appear under the Format list (the table below lists them), and then:
- What: the whole song, or only the bars you selected before opening the dialog.
- Tempo: as written, or at the practice speed you set in the player. The pitch stays the same either way.
- The metronome’s clicks in the sound, if you want to play along with a click.
- Click Export…, and choose where to save the file. A three-minute song takes a few seconds.
The choices are kept for next time when you click Export…, and forgotten when you click Cancel.
Which format?
| Format | Choices | Default | Use it for |
|---|---|---|---|
| WAV | 16-bit (with dither), 24-bit or 32-bit float; 44.1 or 48 kHz | 24-bit, 48 kHz | Loading into another audio program; anything that needs plain, uncompressed audio |
| FLAC, lossless | 16-bit (with dither) or 24-bit; 44.1 or 48 kHz | 24-bit, 48 kHz | Keeping a master copy at half the size of WAV |
| MP3 | variable bitrate V0, V2 or V4, or constant 128 to 320 kbps; 44.1 or 48 kHz | V2, about 190 kbps, 44.1 kHz | Sharing: every phone, car and player plays it |
Opus (.opus) | 96 to 256 kbps; always 48 kHz | 160 kbps | Sharing, smaller than MP3 for the same quality |
The overview explains bit depth, sample rate, dither and lossy formats if any of that is new.
Practise with it
- Loop a hard passage: select those bars, export only them, and loop the file in any player. MP3 and Opus exports are gapless, so the loop doesn’t stutter.
- Slow it down: set the player’s speed to 70 %, then export with Tempo at the practice speed.
- Make a backing track: mute the part you want to play yourself, then export.
From the command line
oxiguitar-cli export SONG.gp5 SONG.flac
The format comes from the file’s extension, with the choices you last kept in the dialog.
Good to know
- Nothing needs a sound card: the song is rendered as fast as the computer can.
- The file is written under a temporary name and renamed only when it is complete, so a cancelled or failed export leaves nothing behind.
Architecture and strategy
How it fits into OxiGuitar
The plugin is an exporter. OxiGuitar does all the playing: it renders the score into a stream of sound through the instrument, effect and output plugins, exactly as it would play it, only as fast as the processor allows. The plugin receives that stream and does two things: it encodes it in the chosen format and writes the file.
- WAV is our own code. 16-bit samples get triangular dither, one step wide, from a fixed generator, so the same song always exports to the same file.
- FLAC goes through rusty_flac, MP3 through rusty_mp3, and Opus through opus-pure. All three are pure Rust, so the plugin has no C libraries to install, and all are used as published.
- MP3 files carry a LAME Info/Xing tag, and Opus files the pre-skip in their header, so players can cut the encoder’s padding and play gaplessly.
- A file is written under a temporary name and takes its real name only when it is whole. A cancelled or failed export leaves nothing behind.
Each format’s own choices (bit depth, rate, bitrate) are shown in the export dialog only while that format is picked. Export… keeps them for next time; Cancel forgets them. oxiguitar-cli export SONG.gp5 SONG.flac uses the last kept choices.
Current limitations
- Two sample rates. 44.1 and 48 kHz, nothing higher. Opus is always 48 kHz, by design of the format.
- No tags. The title, artist and so on aren’t written into the file yet.
- No stems. One file for the whole mix; exporting each track to its own file means muting the others by hand.
- No normalising. The file is as loud as the mix. Turn the tracks up or down in the mixer first.
- WAV files stop at 4 GB, over three hours of sound. That is the format’s own limit.
Left out on purpose
- C libraries such as LAME, libFLAC or libopus. They are excellent, but bundling them on every system, or asking you to install them, is exactly the kind of setup OxiGuitar avoids. Pure Rust encoders build everywhere the plugin does.
- More formats (AAC, Ogg Vorbis, AIFF). WAV, FLAC, MP3 and Opus cover sharing, editing and archiving. Another format is one more encoder to maintain, so it waits until someone needs it.
- Uploading anywhere. OxiGuitar never connects to the internet. The file is yours to send.
Where you can help
- Tags for MP3, FLAC and Opus: title, artist, album from the score’s own information.
- Stems: one file per track, in one go.
- Listening tests of the encoders’ quality settings against other encoders.
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 (plugin interface 3.0). Version 0.2 of the plugin works with OxiGuitar 0.21.2 and later. See the OxiGuitar manual.
- The MIDI plugin, for the sound. See its manual.
- Windows, macOS or Linux.
Assumptions
- You export something that is already open. Opening a score takes a plugin for its format.
- A WAV file holds at most 4 GB, which is over three hours of sound.
Installing
You need OxiGuitar first: its manual says how to get it. This page is about the Audio export plugin.
From a release
Each release on the releases page has a zip for each system (Linux, Windows and macOS; Linux and Windows for x86_64 and ARM64), a .deb, an .rpm and a Flatpak for Linux, a setup program for Windows that installs for you alone (no administrator password), a .pkg for macOS that does the same, 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 export.oxp in your plugins folder:
| System | Your plugins folder |
|---|---|
| Linux | ~/.local/share/oxiguitar/plugins/ |
| macOS | ~/Library/Application Support/OxiGuitar/plugins/ |
| 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.
On macOS, a plugin file you downloaded yourself may be refused as coming from an unverified developer. Clear the download mark and start OxiGuitar again:
xattr -d com.apple.quarantine ~/Library/Application\ Support/OxiGuitar/plugins/*.oxp
A plugin installed with the .pkg is not marked this way.
Linux package managers
The package is called oxiguitar-export. 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-export
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-export
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.export
flatpak update keeps it current and flatpak remove takes it away.
Features and their tests
Everything the audio export plugin does, and the tests that check it. The test names are the ones cargo test prints. 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).
OxiGuitar itself renders the song (the selected bars, the practice speed, the metronome, every track with its sound, amp and mixer), faster than real time and without a sound card, and writes the file under a temporary name until it is whole. That part is tested in OxiGuitar’s own repository. This plugin turns the sound into each format’s bytes.
| Feature | What it does | Tests |
|---|---|---|
| Four formats | WAV, FLAC, MP3 and Opus, each an exporter of its own with its options. | tests::every_format_has_its_exporter_and_options, tests::each_format_starts_at_its_rate_and_finishes |
| WAV | 16-bit with dither, 24-bit or 32-bit float, at 44.1 or 48 kHz; the header names the format and the length; past four gigabytes the export stops. | wav::tests::samples_become_bytes_at_each_depth, wav::tests::headers_name_the_format_and_the_length, wav::tests::past_four_gigabytes_the_export_stops, pcm::tests::full_scale_and_dither |
| FLAC | Lossless, 16-bit with dither or 24-bit, streamed in pieces. | flac::tests::a_stream_in_pieces, pcm::tests::full_scale_and_dither |
| MP3 | Variable bitrate V0, V2 or V4, or constant 128 to 320 kbps; gapless; streamed in pieces. | mp3::tests::a_stream_in_pieces, mp3::tests::qualities |
| Opus | 96 to 256 kbps, always 48 kHz, streamed in pieces. | opus::tests::a_stream_in_pieces |
| Each format’s choices | Every choice has options and a default among them; picks come from the settings or the defaults; the dialog’s changes are a draft, kept with Export and forgotten with Cancel. Drawn by ui/export.slint, one component for the four formats, which compiles with what the plugin sets and hears. | choices::tests::every_choice_has_options_and_a_default_among_them, choices::tests::picks_come_from_the_settings_or_the_defaults, tests::the_options_change_a_draft_until_they_close, tests::the_slint_file_has_what_the_options_set_and_hear |
| A working plugin file | The .oxp file keeps the plugin contract, with this repository’s SDK version and with the newest release of OxiGuitar. | contract::the_plugin_file_keeps_the_contract, oxiguitar_plugin_checks::the_manifest_matches_the_plugin, 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.
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-export/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-host and oxiguitar-plugin-test for the tests) | Mateus Rocha de Paula and the OxiGuitar contributors | The plugin interface, and OxiGuitar’s own host to test against | MIT OR Apache-2.0 |
| rusty_flac | Mata Network | FLAC encoding | Apache-2.0 |
| rusty_mp3 | Mata Network | MP3 encoding | Apache-2.0 |
| opus-pure | Stephen Berry and restsend.com; a port of libopus (Xiph.Org, Skype Limited, Octasic and others) | Opus encoding | BSD-3-Clause |
| Rust and its standard library | The Rust Project | Everything else | MIT OR Apache-2.0 |
The WAV writer and the dither are our own code.
Standards
The formats themselves are the work of many people: FLAC and the Ogg container from Xiph.Org, Opus from the IETF and Xiph.Org, MP3 from the Fraunhofer Institute and MPEG, and the gapless Info tag from the LAME project.
Tools
| Tool | Use |
|---|---|
| mdBook | Builds this manual |
| cargo-deny | Checks the licences of everything we build with |
Thanks
To the authors of the pure Rust encoders, who made it possible to export to every format with no C library at all, and to everyone who exports a song and tells us how it came out.