Robin Gareus
39b85bd2d4
Tempo Map updates can change a region's position/length, in which case region-automation may follow the region, and DiskReader:: playlist_ranges_moved will save additional undo information. These MementoCommand(s) need to be included in the undo operation.
31 lines
1.1 KiB
Lua
31 lines
1.1 KiB
Lua
ardour { ["type"] = "Snippet", name = "tempo map examples" }
|
|
|
|
function factory () return function ()
|
|
|
|
-- query BPM at 00:00:10:00
|
|
local tp = Temporal.timepos_t (Session:nominal_sample_rate () * 10)
|
|
local tm = Temporal.TempoMap.read ()
|
|
print (tm:quarters_per_minute_at (tp))
|
|
tm = nil
|
|
|
|
-- set initial tempo to 140, ramp to 120 over the first 4/4 bar, then continue at BPM 80
|
|
local tm = Temporal.TempoMap.fetch_writable ()
|
|
tm:set_tempo (Temporal.Tempo (140, 120, 4), Temporal.timepos_t (0))
|
|
tm:set_tempo (Temporal.Tempo (120, 80, 4), Temporal.timepos_t.from_ticks (Temporal.ticks_per_beat * 4))
|
|
tm:set_tempo (Temporal.Tempo (80, 80, 4), Temporal.timepos_t.from_ticks (Temporal.ticks_per_beat * 4))
|
|
Session:begin_reversible_command ("Change Tempo Map")
|
|
Temporal.TempoMap.update (tm)
|
|
if not Session:abort_empty_reversible_command () then
|
|
Session:commit_reversible_command (nil)
|
|
end
|
|
tm = nil
|
|
|
|
-- Abort Edit example
|
|
-- after every call to Temporal.TempoMap.fetch_writable ()
|
|
-- there must be a matching call to
|
|
-- Temporal.TempoMap.update() or Temporal.TempoMap.abort_update()
|
|
Temporal.TempoMap.fetch_writable()
|
|
Temporal.TempoMap.abort_update()
|
|
|
|
end end
|