Snap audio region to the playhead location

Is there a way to snap an audio clip to the playhead location?
this is my use case: I’m using ardour for audio design using JACK to synchronize timecode with another application. I need to align sounds to locations in the timeline which have nothing to snap to in ardour, but do in another application which has its timecode synchronized. I can locate the right spot in the other application which synchronizes the location of the playhead to just the right spot in Ardour, but I can’t find a way to then use the mouse to drag an audio clip and have it snap perfectly to that location. Is there any snap setting that will do this? or a command I can bind a keyboard shortcut to which will move the selected audio clip (or clips) to the location of the playhead?

Edit: I’m on Ardour 6.9, Ubuntu 20.04LTS


You can snap to timecode which is may work in your case, but what I would do is drop a marker real quick and snap to the marker. Also worth noting is that even though you may not snap, when you are aligned with the playhead it shifts colors (At least in Mixbus which I have in front of me right now, so I suspect in Ardour as well).


Also this is a use case where I suspect a simple Lua script could solve the issue, by finding the current playhead position, and moving the start of the selected region to that position. No time to look into it myself right now, but maybe someone else can jump in here.


not a bad idea. would that script be able to be triggered by a keyboard shortcut? I know how to code but I don’t know anything about lua unfortunately.
I should try the marker idea to see how well that would work. I tried and did find that I can probably snap to the right place with snap to time code. the other program cannot position anything between frames in timecode so whatever I want to line it up with will always be on an even frame. workable, but I found I have to zoom way in in order to get it to snap to a particular frame location. if I zoom out even a little it will show me the frame number but will only snap to a second, not a frame. doable, but if there were a way to make it snap to the playhead or have a keyboard shortcut that would be ideal.

thanks for the quick reply!

Lua itself is a really simple language with a limited syntax, it should be easy to pick up.

Anyway to get you going… paste the following into Ardour’s Menu > Window > Scripting and “save” the script (or alternatively directly save it into ardour’s config dir. On Linux that would be ~/.config/ardour6/scripts/move_regions_to_playhead.lua)

ardour {
  ["type"]    = "EditorAction",
  name        = "Move Regions to Playhead",
  license     = "MIT",
  author      = "Ardour Team",
  description = "Move selected regions to playhead position"

function factory () return function ()

  local sel = Editor:get_selection () -- get current selection
  local sel_regions = sel.regions:regionlist() -- get selected regions

  local playhead = Session:transport_sample () -- get playhead position

  -- prepare undo operation
  Session:begin_reversible_command ("Move Regions to Playhead")

  -- iterate over selected regions
  for region in sel.regions:regionlist ():iter () do
      -- prepare for undo operation
      region:to_stateful ():clear_changes ()

      -- move region to playhead position
      region:set_position (playhead, 0)

      -- collect undo/redo diff
      Session:add_stateful_diff_command (region:to_statefuldestructible ())

  -- all done, commit the combined Undo Operation (if any)
  if not Session:abort_empty_reversible_command () then
    Session:commit_reversible_command (nil)

end end

Yes, one can bind Lua Action scripts to keyboard shortcuts.

First load the script: easiest via right-click on one of the script-buttons top-right in the GUI e.g. “3” here:


You can then already run it by pressing the given action-script button.

Then in Window > Keyboard Shortcuts search for “Move regions” and assign a shortcut:

PS. This script works in Ardour 6 (not Ardour7/git).

1 Like

Amazing! Thank you so much. That code did exactly what I was looking for without any modifications at all. I was able to bind it to the #3 button just like you showed and set a keyboard shortcut to Shift+S so the same shortcut performs exactly the same action as in Blender (VSE), which is the other program I’m using next to Ardour.
I can’t thank you enough!

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