Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Audio clips plugin

This plugin lets a score play recorded audio along with its notes. Put a clip on a rest, and from that beat the audio file plays for as long as it lasts, in time with the song. Use it for a spoken intro, a sample, a backing part you have as a recording, or a stand-in for a part you haven’t written yet.

It is not a multitrack recorder: you can’t record into OxiGuitar or edit the audio. You add a clip with the Clip tool, in the palette’s Plugins section (How to use it).

Notes and audio, side by side

Everything else in OxiGuitar is notation: the score says which notes to play, and an instrument plugin turns them into sound when you press Play. Change the tempo and the notes simply come faster. A clip is different: it is already sound, a recording with its own length. The plugin’s job is to fit the two together:

  • Where it starts is a beat in the score, so the clip moves with the music if you change the tempo or add bars before it.
  • How long it lasts is the recording’s own length. The page draws a line from the rest to the beat where the clip ends, working out the beats from the score’s tempo, tempo changes included.
  • Practice speed. Slow the song to 70 % and the notes just play slower. Audio slowed down the naive way also drops in pitch, like a record played at the wrong speed. The plugin uses time-stretching, which changes the speed but keeps the pitch, so the clip stays in tune with the notes.
  • Sample rate. A recording might be made at 44.1 kHz and your sound card run at 48 kHz. The plugin converts it, resampling, so it plays at the right speed and pitch.

A clip plays through its track: the track’s volume, pan, mute and solo apply, and it goes into audio exports too.

How to use it

Add a clip

  1. Put the caret on a rest, in the track the clip should play through. A clip plays through its track’s volume, pan, mute and solo.
  2. Click Clip in the palette’s Plugins section:

  1. Choose a WAV, FLAC, MP3 or Opus file in the system’s file dialog, and whether to keep its path relative to the score or absolute. Relative: move or share the score’s folder with the score and its .oxg file, and the clip comes along. Absolute: the score can move, and the file stays where it is.
  2. The page shows a speaker and the file’s name at the rest, and a line to the beat where the clip ends:

Click the clip on the page to change or remove it.

Line it up

If the recording doesn’t start right on the beat, give the clip an Offset in its dialog instead of editing the file. Type how much later than the rest it should start, like 0.25 or 250 ms, or how much earlier with a minus, like -1.5, and press Enter. The line on the page then ends where the sound does. A clip that starts before the song does is cut there.

What you can do with it

  • Put a clip on a rest. Choose a WAV, FLAC, MP3 or Opus file in the system’s file dialog. Click a clip on the page to change or remove it.
  • See it. The page shows a speaker and the file’s name at the rest, then a line to the beat where the clip ends, across bars and systems.
  • Hear it with the track. A clip plays through its track’s volume, pan, mute and solo, from wherever playing starts, and through loops. It also goes into audio exports. At a practice speed other than 100 %, it keeps its pitch.
  • Line it up. Start a clip a little after its rest, or before it, with its Offset, in seconds or milliseconds.
  • Keep a clip with the score. Choose a path relative to the score to move or share a folder with the score, its .oxg file and the clips together. Choose absolute to keep clips where you work on them.

A clip that runs into the next clip of its track, or past a repeat or a D.C., is drawn in red. It still plays.

A missing file is named in the footer when the song is played or exported, and the track plays without it.

Architecture and strategy

How it fits into OxiGuitar

The plugin does two jobs through OxiGuitar’s plugin interface:

  1. It draws on the page: the speaker, the file’s name and the line to where the clip ends. The line follows the score’s tempo changes and stops at a jump in the playing order (a repeat, a D.C.).
  2. It plays as an effect that follows the score: OxiGuitar tells it which beats the track plays, from wherever playing starts and through loops, and the plugin mixes in each clip from its beat.

The clip is kept on its rest in the song’s .oxg file beside it, since no score format has a place for it. Its path is stored relative to the score or absolute, as you choose.

Audio files are decoded with Symphonia (WAV, FLAC and MP3) and opus-pure (Opus), resampled with Rubato, and stretched at practice speeds with timestretch. All are used as published. The files are decoded and the stretcher set up before the song starts; a real-time check confirms nothing is allocated on the audio thread while clips play.

Current limitations

  • Clips start on rests only. A clip can’t start on a note.
  • No trimming, fades or gain. The whole file plays, at its own level, through the track’s volume.
  • Overlaps are flagged, not managed. A clip that runs into the next clip of its track, or past a repeat or a D.C., is drawn in red. It still plays on, even where the score goes elsewhere.
  • No waveform on the page, only the line.
  • Files must stay put. If you move the audio files, pick the path again. A missing file is named in the footer and the track plays without it.

Left out on purpose

  • Recording. OxiGuitar plays scores; it has no audio input. A multitrack recorder is a different program, and there are excellent free ones.
  • Audio editing. Cutting, fading and processing audio belong in an audio editor. Prepare the clip there, then lay it on the score.
  • Embedding audio in the score. The clip stays a separate file, so the score stays small and nothing gets copied behind your back.

Where you can help

  • Clip gain and fades, saved with the clip on its rest.
  • A waveform drawn along the line on the page.
  • Starting on notes, which needs a way to pick the clip’s beat that doesn’t fight with editing the note.

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). See the OxiGuitar manual.
  • A track with an instrument, since the clip is heard through its track. The MIDI plugin plays every track. See its manual.
  • Windows, macOS or Linux.

Assumptions

  • The audio files stay where the score expects them. If you move them, pick the path again.
  • A clip is a short piece of audio laid on a rest, not a recording of the whole song.

Installing

You need OxiGuitar first: its manual says how to get it. This page is about the Audio clips 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 clips.oxp in your plugins folder:

SystemYour 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-clips. 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-clips

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-clips

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.clips

flatpak update keeps it current and flatpak remove takes it away.

Features and their tests

Everything the clips 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).

FeatureWhat it doesTests
A clip on a restThe dialog puts a clip on the caret’s beat, or takes it off, leaving the beat’s other data alone.dialog::tests::a_clip_goes_on_a_beat_and_comes_off_leaving_the_rest, dialog::tests::the_caret_names_its_beat
The clip windowA Slint window (ui/clips.slint) shows the file, its length, the path and offset, says why a typed offset isn’t one, and changes them; OK keeps the changes and Cancel forgets them. The file compiles as OxiGuitar compiles it, with every property and callback the window uses.dialog::tests::the_window_shows_and_changes_the_clip, dialog::tests::the_slint_file_has_what_the_window_sets_and_hears
WAV, FLAC, MP3 and Opus filesRead whole, at their own rate, as stereo; Opus gapless. A file that isn’t sound says so.decode::tests::a_wav_file_is_read_as_stereo_at_its_rate, decode::tests::a_flac_file_is_read_sample_for_sample, decode::tests::an_mp3_file_is_read, decode::tests::an_opus_file_is_read_whole_and_gapless, decode::tests::what_isnt_a_sound_file_says_so
An offsetA clip starts a set time after its rest, or before it; typed in seconds or milliseconds, kept with the clip; a clip moved before the song’s start is cut there. The line ends where the sound does, and the red warning goes by where it sounds.clip::tests::an_offset_is_kept_either_way_and_a_wild_one_isnt, dialog::tests::an_offset_is_typed_in_seconds_or_milliseconds, missing_files::an_offset_plays_the_clip_later_or_earlier, draw::tests::an_offset_moves_where_the_line_ends_and_what_is_red
Drawn on the pageA speaker and the file’s name at the rest, then a line as long as the clip lasts; a long name is cut.draw::tests::a_clip_is_its_name_and_a_run_as_long_as_it_lasts, draw::tests::a_long_name_is_cut_and_the_box_keeps_the_limits
Warned in redA clip that runs into the next one, or past a repeat or a D.C., is drawn in red; it still plays.draw::tests::a_clip_into_the_next_or_past_a_repeat_is_laid_in_red
Plays with its trackFrom its beat, sample for sample at 100 %; clips that overlap both sound. Through the track’s chain, so its mixer settings and exports include it.sound::tests::at_100_percent_a_clip_plays_its_samples_from_its_beat, sound::tests::clips_that_overlap_both_sound
From wherever playing startsA jump into a clip (a start mid-song, a loop) plays from there, faded in; a stop fades out.sound::tests::a_jump_into_a_clip_plays_from_there_faded_in_and_a_stop_fades_out
Practice speedsAt another speed a clip keeps its pitch and follows the score.sound::tests::at_another_speed_a_clip_keeps_its_pitch_and_follows_the_score, sound::tests::at_half_speed_a_clip_starts_when_its_beat_is_heard
Kept with the scoreSaved in the beat’s plugin data; a path relative to the score follows it, an absolute one doesn’t.clip::tests::a_clip_is_kept_as_text_and_read_back, clip::tests::a_relative_path_follows_the_score_and_an_absolute_one_doesnt
A missing fileNamed once in the footer when the song plays or exports, and the track plays without it.missing_files::a_missing_file_is_named_and_the_track_plays_without_it
Real timeNothing allocated and no system calls on the audio thread, within its time budget.contract::the_clips_run_in_real_time, realtime::playing_clips_allocates_nothing
A working plugin fileThe .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’s rust-version or 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-dev and libclang-dev on Debian and Ubuntu (alsa-lib-devel, pipewire-devel and clang-devel on Fedora);

It runs:

  1. every Rust test of the repository (cargo test over the whole workspace), with a progress bar;
  2. 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-all on macOS, %LOCALAPPDATA%\oxiguitar-test-all on Windows, or OXIGUITAR_TEST_CACHE), builds its oxiguitar-cli and oxiguitar-plugin-test, builds this repository’s plugin file for your system and runs the plugin contract on it;
  3. 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

  1. Update to the newest develop (git checkout develop && git pull) and run it again: it may be fixed already.
  2. Look for an issue about the same test at github.com/mateusrdp/oxiguitar-clips/issues.
  3. Otherwise open one: call it test-all: <the first failing test>, paste the whole summary.md, and attach test-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.
  4. You can also give summary.md and test-all.log to 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 than rust-version (unsupported, but handy).
  • --core DIR: test against a checkout of OxiGuitar you already have, instead of its newest release; --core-version v0.21.5 picks 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

ProjectAuthorsWhat it does hereLicence
OxiGuitar’s plugin SDK (oxiguitar-plugin, and oxiguitar-host and oxiguitar-plugin-test for the tests)Mateus Rocha de Paula and the OxiGuitar contributorsThe plugin interface, and OxiGuitar’s own host to test againstMIT OR Apache-2.0
SymphoniaPhilip Deljanov and contributorsDecoding WAV, FLAC and MP3MPL-2.0
opus-pureStephen Berry and restsend.com; a port of libopus (Xiph.Org, Skype Limited, Octasic and others)Decoding OpusBSD-3-Clause
RubatoHenrik EnquistResampling to the sound card’s rateMIT OR Apache-2.0
timestretchRob Morgan and contributorsPractice speeds with the pitch keptMIT
rfdBartłomiej Maryńczak and contributorsThe system’s file dialogMIT
pathdiffManish GoregaokarPaths relative to the scoreMIT OR Apache-2.0
rusty_flac and rusty_mp3Mata NetworkMaking test files (tests only)Apache-2.0
Rust and its standard libraryThe Rust ProjectEverything elseMIT OR Apache-2.0

Tools

ToolUse
mdBookBuilds this manual
cargo-denyChecks the licences of everything we build with

Thanks

To the Rust audio community, whose decoders, resamplers and stretchers made this plugin a matter of putting good pieces together, and to everyone who lays a clip on a score and tells us how it went.