View Issue Details

IDProjectCategoryView StatusLast Update
0009132ardourbugspublic2022-12-01 13:29
Reporterdomingo Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformArchOSLinuxOS Version(any)
Product Version7.1 
Summary0009132: Jack Transport: LUA script for snapping region to playhead behaves bizarre
DescriptionOS: Linux Manjaro Gnome 43
Ardour 7.1

A LUA script for Ardour 7.1 moves a region to the playhead (included on 'Additional Information'). It works fine when timecode is set to INT, but using JACK as timecode master produces a strange effect. After running the script the selected region will move a few frames after the playhead, instead of the playhead itself. ie., If the playhead is at 00:10:00:00, the region will fall on 00:10:00:02.

Jack Transport is interfaced by QJackCtl 0.9.8, JACK version 1.9.21.
I noticed the failure in sync with Blender, but it also occurs when Ardour is the only Jack client.

A related discussion of the issue here: https://discourse.ardour.org/t/snap-audio-region-to-playhead-ardour-7/107972/6


Additional Information=====================
LUA Script
=====================

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 (Temporal.timepos_t (playhead))

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

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

end end
Tagsjack, Lua, playhead, script, sync, timecode, transport

Activities

domingo

2022-11-30 22:45

reporter  

x42

2022-11-30 23:22

administrator   ~0026967

can you add a

  print (Session:transport_sample ())

and run the script in Window > Scripting (so that the output is visible)
Assuming a sample-rate of 48kHz, the result at 00:10:00:00 should be 48000 * 10 * 60 = 2880000

domingo

2022-12-01 13:29

reporter   ~0026968

Running the script with JACK timecode prints: 28804096
With INT timecode: 28800000

Playhead at 00:10:00:00

Issue History

Date Modified Username Field Change
2022-11-30 22:45 domingo New Issue
2022-11-30 22:45 domingo Tag Attached: jack
2022-11-30 22:45 domingo Tag Attached: Lua
2022-11-30 22:45 domingo Tag Attached: playhead
2022-11-30 22:45 domingo Tag Attached: script
2022-11-30 22:45 domingo Tag Attached: sync
2022-11-30 22:45 domingo Tag Attached: timecode
2022-11-30 22:45 domingo Tag Attached: transport
2022-11-30 22:45 domingo File Added: Screenshot from 2022-11-30 19-20-58.png
2022-11-30 23:22 x42 Note Added: 0026967
2022-12-01 13:29 domingo Note Added: 0026968