diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index fb75fec380..a5e1e206bf 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -794,6 +794,24 @@ LuaBindings::common (lua_State* L) .addCast ("to_point") .endClass () + .beginClass ("TempoMetric") + .addFunction ("tempo", &Temporal::TempoMetric::tempo) + .addFunction ("meter", &Temporal::TempoMetric::meter) + .addFunction ("sample_at", &Temporal::TempoMetric::sample_at) + .addFunction ("quarters_at", &Temporal::TempoMetric::quarters_at) + .addFunction ("note_type", &Temporal::TempoMetric::note_type) + .addFunction ("note_value", &Temporal::TempoMetric::note_value) + .addFunction ("divisions_per_bar", &Temporal::TempoMetric::divisions_per_bar) + .endClass () + + .deriveClass ("TempoMapPoint") + .addCast ("to_tempometric") + .addFunction ("time", &Temporal::TempoMapPoint::time) + .endClass () + + .beginStdList ("TempoMapPoints") + .endClass () + .beginWSPtrClass ("TempoMap") /* we cannot use ::fetch or ::use because LuaBridge cannot overload * shared_ptr and shared_ptr in the same class. @@ -841,6 +859,9 @@ LuaBindings::common (lua_State* L) .addFunction ("convert_duration", &Temporal::TempoMap::convert_duration) .addFunction ("bbt_walk", &Temporal::TempoMap::bbt_walk) .addFunction ("count_bars", &Temporal::TempoMap::count_bars) +#ifdef WITH_SUPERCLOCK_BINDINGS + .addRefFunction ("get_grid", &Temporal::TempoMap::get_grid) +#endif .addFunction ("quarters_per_minute_at", &Temporal::TempoMap::quarters_per_minute_at) .addFunction ("round_to_bar", &Temporal::TempoMap::round_to_bar) diff --git a/share/scripts/s_tempo_map.lua b/share/scripts/s_tempo_map.lua index a8c7db3a64..5d46136dcd 100644 --- a/share/scripts/s_tempo_map.lua +++ b/share/scripts/s_tempo_map.lua @@ -27,4 +27,17 @@ function factory () return function () Temporal.TempoMap.write_copy() Temporal.TempoMap.abort_update() + -- get grid -- currently only available in debug-builds + -- Temporal.superclock_ticks_per_second = 282240000 + tm = Temporal.TempoMap.read () + local grid = tm:get_grid (Temporal.TempoMapPoints(), 0, Temporal.superclock_ticks_per_second (), 0, 1) + for t in grid[1]:iter () do + -- each t is-a TempoMapPoint + local metric = t:to_tempometric () + local tempo_point = metric:tempo () + local meter_point = metric:meter() + print (t:time(), tempo_point:to_tempo():quarter_notes_per_minute(), meter_point:note_value()) + end + tm = nil + end end