diff options
| author | spv <spv@spv.sh> | 2026-11-22 15:28:49 -0500 |
|---|---|---|
| committer | spv <spv@spv.sh> | 2026-11-22 15:28:49 -0500 |
| commit | 5b140bb5b30fc0c4ff9c4cb05880abfcd8c6fe91 (patch) | |
| tree | b90bb593a56977cbed53635414faba35062eeaba /tempo_based_region_remap.lua | |
Diffstat (limited to 'tempo_based_region_remap.lua')
| -rw-r--r-- | tempo_based_region_remap.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tempo_based_region_remap.lua b/tempo_based_region_remap.lua new file mode 100644 index 0000000..b338590 --- /dev/null +++ b/tempo_based_region_remap.lua @@ -0,0 +1,33 @@ +ardour { ["type"] = "EditorAction", name = "Tempo-based Region Remap" } + +function factory () return function () + -- get Editor selection + -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Editor + -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:Selection + local sel = Editor:get_selection () + -- query the session's currane sample-rate + local sr = Session:nominal_sample_rate () + + -- XXX EDIT THESE ACCORDINGLY! + local original_tempo = 120.0 + local new_tempo = 90.0 + + -- iterate over Regions that part of the selection + -- http://manual.ardour.org/lua-scripting/class_reference/#ArdourUI:RegionSelection + for r in sel.regions:regionlist ():iter () do + -- each of the items 'r' is-a + -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Region + + -- test if it is an audio region + local ar = r:to_audioregion () + if ar:isnil () then goto next end + + local nt = Temporal.timepos_t(math.floor(r:position():samples() * original_tempo / new_tempo)) + + r:set_position(nt) + + ::next:: + end + + -- XXX handle automation curves +end end |
