Sorry I did’nt realize you can only have 9 scripts in Edit > Lua Scripts because you only have 8 buttons unless you run it from the scripting window (unless I have missed something ?) . It’s all looking a bit difficult to implement things, tho the potential is there. In REAPER I can have 1000+ scripts and call on any of them from within other scripts.
Maybe I’m missing something, will have another look tomorrow.
If you have a tempo map you get the samples in the TempoMap section in the project xml.
Depending on what sample rate you are using you can calculate the samples/frames at a bar or beat, in the map you have the current sample > 441000 and target > 420646 will change 120bpm to 130bpm
In Ardour/git (upcoming Ardour 6) you can get this information with
The harder part is to map the beat-position of the file to ardour’s map. It’s mostly rule of three with incremental offsets to the previous sync point (except Ardour also supports temp-ramps so this can get complicated).