whitespace editing and comments + add ability to substitute routes at will
[ardour.git] / scripts / s_portengine.lua
1 ardour { ["type"] = "Snippet", name = "portengine" }
2 function factory () return function ()
3
4         local a = Session:engine()
5         print ("----- Port objects from Ardour's engine ----");
6         _, t = a:get_ports (ARDOUR.DataType("audio"), ARDOUR.PortList())
7         -- table 't' holds argument references. t[2] is the PortList
8         for p in t[2]:iter() do
9                 local lp = p:get_connected_latency_range (ARDOUR.LatencyRange(), true)
10                 local lc = p:get_connected_latency_range (ARDOUR.LatencyRange(), false)
11                 print (p:name(), " -- Play lat.", lp[1].min, lp[1].max, "Capt lat.", lc[1].min, lc[1].max)
12         end
13
14         print ("----- Port names queries from the backend ----");
15         _, t = a:get_backend_ports ("", ARDOUR.DataType("audio"), 0, C.StringVector())
16         -- table 't' holds argument references. t[4] is the StringVector
17         for n in t[4]:iter() do
18                 print (n)
19         end
20
21         print ("----- Connections from the backend ----");
22         _, t = a:get_backend_ports ("", ARDOUR.DataType("audio"), ARDOUR.PortFlags.IsOutput, C.StringVector())
23         for n in t[4]:iter() do
24                 local printed_name = false;
25                 local _, ct = a:get_connections (n, C.StringVector())
26                 for c in ct[2]:iter() do
27                         if (not printed_name) then
28                                 printed_name = true;
29                                 print (n)
30                         end
31                         print (" ->", c)
32                 end
33         end
34
35 end end