AudioClipboard (v1.0) | A standalone Lua script for copying & pasting audio regions between projects/snapshots

Hello fellow Ardour people :wave:


Since April I’ve been working on a bit of a pet project: a standalone Lua script for Ardour (8.12+) that would allow me to copy and paste audio regions between project sessions/snapshots. I greatly desired this functionality because I wanted to merge song fragments (projects) into larger, more-complete song-projects (-and can now do so thanks to getting a much more powerful computer).

As with most of my projects, it started pretty minimally (-and naively :pensive:), but quickly ballooned into a fully-fledged monster as I learned more and more about what I really wanted, and about how Lua works and what Lua is truly capable of doing within Ardour which, as it turns out, is a lot. So I also want to express my thanks to the developers of Ardour for making Ardour so incredibly flexible and truly free. Thank you.

Anyway, after much testing/tweaking, I think it’s decent enough to share:

Now, although the official GitHub repository there :point_up_2: contains everything you’d need to know about “AudioClipboard” in its README section, I thought I’d share a little bit about it here regardless…


AudioClipboard :clipboard:

Basic Description

AudioClipboard (AudioClipboard.lua) is a Lua script designed to be run in the Ardour DAW (v8.12+) that allows one to copy and paste mono and stereo audio regions between projects/sessions/snapshots, whilst maintaining virtually all of the region data in the process.

AudioClipboard_Opening_Window

Features:

  • Works with audio regions, mono and stereo.
  • Easy to use, 3-step process: Copy → Pre-Paste → Paste :white_check_mark:
  • Pasted regions retain all original position, trim, envelope, gain, polarity, fade length/shape data, etc…
  • Avoids most re-embedding or re-importing of files already present in the project during pre-pasting.
  • By default, original relationships to source materials are preserved almost 1:1, but there’s also…
  • An option to manually select different files to use for pasting. (This is super convenient for cleaning-up projects in general, and even fixing broken sources.
  • Handles -L/-R regions that came from a use of “Make Mono Regions”.
  • Handles combined audio regions (-although Ardour currently suffers from many combined region bugs, which can occasionally cause various problems in attempts to copy them, despite my best efforts).
  • Can be used in conjunction with Ardour’s built-in track-template-creator to achieve full track and regions duplication from one session/snapshot into another.
  • There’s a built-in ‘Source Finder Wizard’ that automatically discovers potential source matches (via similar naming) during Pre-Paste, and offers them for approval. (This feature further helps reduce redundant or unecessary imports/embeds.)
  • All contained in a single, standalone Lua script.
  • The Paste action is an undoable command (via ctrl-Z/cmd-Z, etc.).
  • File-collisions and accidental erasures are prevented behind the scenes via simple file-name checks.
  • Legacy Dual-Mono stereo pairs (with -L/-R endings) are automatically modernized during Pre-Paste by renaming them with standard (%L/%R) endings.
  • Legacy fade shapes inherited from older versions of Ardour (like v2, etc.) are automatically detected and replaced during pasting with their closest modern equivalents. (-And the user is informed about this.)
  • Automatically saves your session before any step is executed so that if something goes wrong and Ardour crashes (which is very unlikely), then no previous work is lost.
  • Handles all project/region sample-rates (e.g. 44.1 kHz, 48 kHz, 96 kHz, etc.).
  • Under the GNU General Public License (GPL), thus 100% free to use, copy, alter, distribute, etc.!

Known Limitations/Warnings

  • It doesn’t (yet) work with audio regions/sources with more than 2 channels, sorry.
  • It doesn’t work with anything MIDI, but this is okay because transferring MIDI regions is easy thanks to Ardour’s built-in region export function (-select the MIDI region, then click Region → Export…).
  • It sometimes fails to properly handle combined/compound regions, mostly due to known Ardour bugs.
  • It can’t recreate original transient markers. (-Hopefully this can be implemented soon.)
  • :warning: Due to the way in which AudioClipboard pastes regions, this script has the potential to disturb/destroy automation curves (-plugin/fader/pan/etc.) on a track if the setting “Move relevant automation when audio regions are moved” (-under Preferences → Editor) is NOT disabled during Pasting. This is especially true for pasting combined regions.→ So PLEASE be sure to DISABLE that setting BEFORE using AudioClipboard!


Here’s an example of the level of sample-accurate, copy-paste accuracy I made it achieve, covering and recreating a wide range of data points per region:


And finally, here is a more-technical diagram that I think is worth sharing here, too, that depicts the ‘heart’ of AudioClipboard, → i.e. the “Pre-Paste” process:

Figuring-out how to respectfully handle audio sources based on their unique type and location was a fun challenge, and was eventually narrowed-down to three overall handling routes based on whether the original source was coming from (1) an audiofiles/ directory and was a ‘Dual-Mono’ (%L/%R) pair, (2) was a whole stereo or mono file coming from an audiofiles/ directory, or (3) was coming from a not-in-audiofiles/ location (i.e. anywhere else on the machine pretty much). The basic premise here was to maintain original region-to-source relationships as close to 1:1 as possible, as mentioned earlier…

Oh yeah! -And it would be nice to get a few new bindings if possible(?) (and maybe some other stuff fixed) pretty please. :kissing_heart:


For a long time a few people here and there have expressed a desire for this kind of functionality (…myself included). So hopefully this script can help fill that void somewhat, and help at least a few people out there beyond myself!

~Thanks for reading, and enjoy!

J. K. Lookinland
:ringer_planet:


[ PS: If you encounter any major/minor bugs, please let me know (via GitHub or on here) so I can address them sooner than later. -Thanks! ]


[ [ PS PS: Um, maybe it’s about time to get a ‘Lua Scripts/Scripting’ category on the forum here? :thinking:] ]

8 Likes

Just a note to say “thank you” for this. Really, really great work :slight_smile:

1 Like

Thanks!
I really appreciate it. :grin:


I’ve been working really hard on this ‘little’ script (-aspects like automatic source detection via playlist scanning, manual file selection and proper TSV file mutation, fade-shape determination (via direct XML-parsing), fade-length determination and conversion (also from XML-parsing), an endless slew of popups/warnings/notifications, handling “Make Mono Regions” situations (-where you have to handle more than one region ‘type’ coming from a single source, i.e. the -L, -R, and full-stereo variants), combined-region deconstruction and recreation, etc., etc…) and anyone is welcome to view the code itself to see the integrity of it. (-I.E., it’s not just AI-generated slop.)

Yes there are a few ‘bells and whistles’ on this thing. But even to get a “simple”, user-worthy copy-paste script to work requires waaaaayyy more time, thought, care, and effort than one might expect.

Developing this has really made me appreciate what software developers are up-against all the time. Even the most “basic” features can be a huge challenge to implement, and I 100% get that now. -So thank you to the creators of Ardour, yet again! :small_red_triangle: :+1:

3 Likes

thank you very much, this is very helpful, the first tests are very promising!!

1 Like

Hey @dspasic, I just randomly stumbled-upon your Replace/swap audio media thread from years ago…

Even though it’s been ~4 years, I just thought I’d let you know that you can now basically achieve this using my script here (in Ardour 8.12+).

Just copy your regions using AudioClipboard, then during “Pre-Paste”, simply manually-select which replacement source(s) you would like to use instead. Once ‘pre-pasting’ (i.e. importing/embedding) is finished, you can then paste and the new regions will be virtually identical to the previous ones, other than that the used source(s) will be different, of course. :grin: :+1:

And unlike Ardour, any replacement doesn’t even have to match the original source’s length exactly (…although preferably it should), as Robin suggested in that old thread here:


Anyway, here’s a somewhat-messy diagram depicting in detail how to use this feature (-click to zoom-in!):


And in the README on GitHub, I list several situations where this feature could come in handy:

  • A project’s Source List might be cluttered with duplicate entries, and you’d like to clean it up (→ by redirecting regions to single, shared sources, and then deleting the duplicates).
  • You might be working with lower-quality sources (-like compressed MP3s), but now you wish to ‘swap them out’ for better sources while maintaining all of the original envelope, gain, trimming, etc…
  • You might also just prefer having certain regions link to sources located in a new/different/updated folder (or even a different SSD/HDD).
  • You have already edited (e.g. cut, trimmed, positioned, etc.) a full, combined drum mix recording, but you realize you actually have access to the individual drum stem files, and now you wish to apply all that same editing to every stem recording in the group.
  • You have some broken/missing sources that you just cannot seem to fix, although you do have new sources that would make suitable replacements…

Hope this helps.
:v:
-J

2 Likes

Amazing work. This script has really come a far way and is really useful.
Great stuff.

Thank you

1 Like

Hey, that’s amazing!
looking forward to test it
i’ll let you know when i grab some time to mess with it(haven’t had recently time to fiddle with Ardour in general)
Thanks, that’s awesome news!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.