13
0

Add DiskIOProc & Latency related Lua bindings & scripts

This commit is contained in:
Robin Gareus 2017-09-28 04:25:50 +02:00
parent 2b20f30d81
commit 1339d42c78
3 changed files with 106 additions and 15 deletions

View File

@ -40,6 +40,8 @@
#include "ardour/beats_samples_converter.h"
#include "ardour/chan_mapping.h"
#include "ardour/dB.h"
#include "ardour/disk_reader.h"
#include "ardour/disk_writer.h"
#include "ardour/dsp_filter.h"
#include "ardour/file_source.h"
#include "ardour/fluid_synth.h"
@ -64,7 +66,9 @@
#include "ardour/runtime_functions.h"
#include "ardour/region.h"
#include "ardour/region_factory.h"
#include "ardour/return.h"
#include "ardour/route_group.h"
#include "ardour/send.h"
#include "ardour/session.h"
#include "ardour/session_object.h"
#include "ardour/sidechain.h"
@ -872,6 +876,10 @@ LuaBindings::common (lua_State* L)
.addFunction ("connected_to", (bool (Port::*)(std::string const &)const)&Port::connected_to)
.addFunction ("connect", (int (Port::*)(std::string const &))&Port::connect)
.addFunction ("disconnect", (int (Port::*)(std::string const &))&Port::disconnect)
.addFunction ("physically_connected", &Port::physically_connected)
.addFunction ("private_latency_range", &Port::private_latency_range)
.addFunction ("public_latency_range", &Port::public_latency_range)
.addRefFunction ("get_connected_latency_range", &Port::get_connected_latency_range)
//.addStaticFunction ("port_offset", &Port::port_offset) // static
.endClass ()
@ -909,6 +917,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("port_by_name", &IO::nth)
.addFunction ("n_ports", &IO::n_ports)
.addFunction ("latency", &IO::latency)
.addFunction ("public_latency", &IO::latency)
.endClass ()
.deriveWSPtrClass <PannerShell, SessionObject> ("PannerShell")
@ -1063,6 +1072,7 @@ LuaBindings::common (lua_State* L)
.addFunction ("peak_meter", (boost::shared_ptr<PeakMeter> (Route::*)())&Route::peak_meter)
.addFunction ("set_meter_point", &Route::set_meter_point)
.addFunction ("signal_latency", &Route::signal_latency)
.addFunction ("playback_latency", &Route::playback_latency)
.endClass ()
.deriveWSPtrClass <Playlist, SessionObject> ("Playlist")
@ -1314,8 +1324,12 @@ LuaBindings::common (lua_State* L)
.addCast<IOProcessor> ("to_ioprocessor")
.addCast<UnknownProcessor> ("to_unknownprocessor")
.addCast<Amp> ("to_amp")
.addCast<DiskIOProcessor> ("to_diskioprocessor")
.addCast<DiskReader> ("to_diskreader")
.addCast<DiskWriter> ("to_diskwriter")
.addCast<PeakMeter> ("to_peakmeter")
.addCast<MonitorProcessor> ("to_monitorprocessor")
.addCast<Send> ("to_send")
#if 0 // those objects are not yet bound
.addCast<CapturingProcessor> ("to_capturingprocessor")
.addCast<DelayLine> ("to_delayline")
@ -1326,8 +1340,22 @@ LuaBindings::common (lua_State* L)
.addFunction ("active", &Processor::active)
.addFunction ("activate", &Processor::activate)
.addFunction ("deactivate", &Processor::deactivate)
.addFunction ("output_streams", &PluginInsert::output_streams)
.addFunction ("input_streams", &PluginInsert::input_streams)
.addFunction ("input_latency", &Processor::input_latency)
.addFunction ("output_latency", &Processor::output_latency)
.addFunction ("capture_offset", &Processor::capture_offset)
.addFunction ("playback_offset", &Processor::playback_offset)
.addFunction ("output_streams", &Processor::output_streams)
.addFunction ("input_streams", &Processor::input_streams)
.addFunction ("signal_latency", &Processor::signal_latency)
.endClass ()
.deriveWSPtrClass <DiskIOProcessor, Processor> ("DiskIOProcessor")
.endClass ()
.deriveWSPtrClass <DiskReader, DiskIOProcessor> ("DiskReader")
.endClass ()
.deriveWSPtrClass <DiskWriter, DiskIOProcessor> ("DiskWriter")
.endClass ()
.deriveWSPtrClass <IOProcessor, Processor> ("IOProcessor")
@ -1344,6 +1372,20 @@ LuaBindings::common (lua_State* L)
.addFunction ("panner_shell", &Route::panner_shell)
.endClass ()
.deriveWSPtrClass <Send, Delivery> ("Send")
.addFunction ("get_delay_in", &Send::get_delay_in)
.addFunction ("get_delay_out", &Send::get_delay_out)
.endClass ()
.deriveWSPtrClass <InternalSend, Send> ("InternalSend")
.endClass ()
.deriveWSPtrClass <Return, IOProcessor> ("Return")
.endClass ()
.deriveWSPtrClass <InternalReturn, Return> ("InternalReturn")
.endClass ()
.beginNamespace ("Plugin")
.beginClass <Plugin::IOPortDescription> ("IOPortDescription")
.addData ("name", &Plugin::IOPortDescription::name)
@ -2007,7 +2049,10 @@ LuaBindings::common (lua_State* L)
.addFunction ("set_output_device_name", &AudioBackend::set_output_device_name)
.endClass()
.beginClass <PortEngine> ("PortEngine")
.beginClass <LatencyRange> ("LatencyRange")
.addVoidConstructor ()
.addData ("min", &LatencyRange::min)
.addData ("max", &LatencyRange::max)
.endClass()
.beginClass <PortManager> ("PortManager")
@ -2169,9 +2214,8 @@ LuaBindings::common (lua_State* L)
.addFunction ("get_block_size", &Session::get_block_size)
.addFunction ("worst_output_latency", &Session::worst_output_latency)
.addFunction ("worst_input_latency", &Session::worst_input_latency)
.addFunction ("worst_track_latency", &Session::worst_track_latency)
.addFunction ("worst_track_out_latency", &Session::worst_track_out_latency)
.addFunction ("worst_playback_latency", &Session::worst_playback_latency)
.addFunction ("worst_route_latency", &Session::worst_route_latency)
.addFunction ("worst_latency_preroll", &Session::worst_latency_preroll)
.addFunction ("cfg", &Session::cfg)
.addFunction ("route_groups", &Session::route_groups)
.addFunction ("new_route_group", &Session::new_route_group)

View File

@ -4,14 +4,59 @@ ardour { ["type"] = "Snippet", name = "Dump Latency",
}
function factory () return function ()
local all_procs = true
local show_ports = false
print (" -- Session --")
print ("Worst Output Latency: ", Session:worst_output_latency ())
print ("Worst Input Latency: ", Session:worst_input_latency ())
print ("Worst Track Latency: ", Session:worst_track_latency ())
print ("Worst Playback Latency:", Session:worst_playback_latency ())
print (" -- Tracks --")
for t in Session:get_tracks ():iter () do
print (string.format ("%-24s roll-delay: %4d proc: %4d io: %4d",
t:name(), t:initial_delay (), t:signal_latency (), t:output():latency()))
print ("Worst Track Latency: ", Session:worst_route_latency ())
print ("Worst Latency Preroll: ", Session:worst_latency_preroll ())
print (" -- Routes --")
for t in Session:get_routes ():iter () do
print (string.format ("%-30s signal-latency: %4d align: %4d play: %4d || in: %4d out: %4d",
t:name(),
t:signal_latency (), t:playback_latency (false), t:playback_latency (true),
t:input():latency(), t:output():latency()))
local i = 0
while true do
local proc = t:nth_processor (i)
if proc:isnil () then break end
if all_procs and not proc:to_send():isnil () then
print (string.format (" * %-27s L: %4d in: %4d out: %4d capt: %4d play %4d DLY-SRC: %4d DLY-DST: %4d",
string.sub (proc:name(), 0, 27) , proc:signal_latency(),
proc:input_latency(), proc:output_latency(),
proc:capture_offset(), proc:playback_offset(),
proc:to_send():get_delay_in(), proc:to_send():get_delay_out()
))
elseif all_procs or not proc:to_diskioprocessor():isnil () then
print (string.format (" * %-27s L: %4d in: %4d out: %4d capt: %4d play %4d",
string.sub (proc:name(), 0, 27) , proc:signal_latency(),
proc:input_latency(), proc:output_latency(),
proc:capture_offset(), proc:playback_offset()
))
end
i = i + 1
end
end
if show_ports then
print (" -- Ports -- (latencies: port, priv, pub)")
local a = Session:engine()
_, t = a:get_ports (ARDOUR.DataType("audio"), ARDOUR.PortList())
-- table 't' holds argument references. t[2] is the PortList
for p in t[2]:iter() do
local lp = p:get_connected_latency_range (ARDOUR.LatencyRange(), true)
local lc = p:get_connected_latency_range (ARDOUR.LatencyRange(), false)
local ppl = p:private_latency_range (true)
local pcl = p:private_latency_range (false)
local bpl = p:public_latency_range (true)
local bcl = p:public_latency_range (false)
print (string.format ("%-30s play: (%4d, %4d) (%4d, %4d) (%4d, %4d) capt: (%4d, %4d) (%4d, %4d) (%4d, %4d)",
p:name(),
lp[1].min, lp[1].max, ppl.min, ppl.max, bpl.min, bpl.max,
lc[1].min, lc[1].max, pcl.min, pcl.max, bcl.min, bcl.max))
end
end
end end

View File

@ -1,12 +1,14 @@
ardour { ["type"] = "Snippet", name = "portengine" }
function factory () return function ()
a = Session:engine()
local a = Session:engine()
print ("----- Port objects from Ardour's engine ----");
_, t = a:get_ports (ARDOUR.DataType("audio"), ARDOUR.PortList())
-- table 't' holds argument references. t[2] is the PortList
for p in t[2]:iter() do
print (p:name())
local lp = p:get_connected_latency_range (ARDOUR.LatencyRange(), true)
local lc = p:get_connected_latency_range (ARDOUR.LatencyRange(), false)
print (p:name(), " -- Play lat.", lp[1].min, lp[1].max, "Capt lat.", lc[1].min, lc[1].max)
end
print ("----- Port names queries from the backend ----");
@ -20,7 +22,7 @@ function factory () return function ()
_, t = a:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput, C.StringVector())
for n in t[4]:iter() do
local printed_name = false;
_, ct = a:get_connections (n, C.StringVector())
local _, ct = a:get_connections (n, C.StringVector())
for c in ct[2]:iter() do
if (not printed_name) then
printed_name = true;