Video-Frame (not sample)
[ardour.git] / scripts / _dump_latency.lua
1 ardour { ["type"] = "Snippet", name = "Dump Latency",
2         license     = "MIT",
3         author      = "Ardour Team",
4 }
5
6 function factory () return function ()
7         local all_procs = true
8         local show_ports = false
9
10         print (" -- Session --")
11         print ("Worst Output Latency:  ", Session:worst_output_latency ())
12         print ("Worst Input Latency:   ", Session:worst_input_latency ())
13         print ("Worst Track Latency:   ", Session:worst_route_latency ())
14         print ("Worst Latency Preroll: ", Session:worst_latency_preroll ())
15
16         print (" -- Routes --")
17         for t in Session:get_routes ():iter () do
18                 print (string.format ("%-30s  signal-latency: %4d align: %4d play: %4d || in: %4d out: %4d",
19                 t:name(),
20                 t:signal_latency (), t:playback_latency (false), t:playback_latency (true),
21                 t:input():latency(), t:output():latency()))
22                 local i = 0
23                 while true do
24                         local proc = t:nth_processor (i)
25                         if proc:isnil () then break end
26                         if all_procs and not proc:to_send():isnil () then
27                                 print (string.format (" * %-27s  L: %4d  in: %4d  out: %4d capt: %4d play %4d  DLY-SRC: %4d DLY-DST: %4d",
28                                 string.sub (proc:name(), 0, 27) , proc:signal_latency(),
29                                 proc:input_latency(), proc:output_latency(),
30                                 proc:capture_offset(), proc:playback_offset(),
31                                 proc:to_send():get_delay_in(), proc:to_send():get_delay_out()
32                                 ))
33                         elseif all_procs or not proc:to_diskioprocessor():isnil () then
34                                 print (string.format (" * %-27s  L: %4d  in: %4d  out: %4d capt: %4d play %4d",
35                                 string.sub (proc:name(), 0, 27) , proc:signal_latency(),
36                                 proc:input_latency(), proc:output_latency(),
37                                 proc:capture_offset(), proc:playback_offset()
38                                 ))
39                         end
40                         i = i + 1
41                 end
42         end
43
44         if show_ports then
45                 print (" -- Ports -- (latencies: port, priv, pub)")
46                 local a = Session:engine()
47                 _, t = a:get_ports (ARDOUR.DataType("audio"), ARDOUR.PortList())
48                 -- table 't' holds argument references. t[2] is the PortList
49                 for p in t[2]:iter() do
50                         local lp = p:get_connected_latency_range (ARDOUR.LatencyRange(), true)
51                         local lc = p:get_connected_latency_range (ARDOUR.LatencyRange(), false)
52                         local ppl = p:private_latency_range (true)
53                         local pcl = p:private_latency_range (false)
54                         local bpl = p:public_latency_range (true)
55                         local bcl = p:public_latency_range (false)
56                         print (string.format ("%-30s  play: (%4d, %4d) (%4d, %4d) (%4d, %4d)  capt: (%4d, %4d) (%4d, %4d) (%4d, %4d)",
57                         p:name(),
58                         lp[1].min, lp[1].max, ppl.min, ppl.max, bpl.min, bpl.max,
59                         lc[1].min, lc[1].max, pcl.min, pcl.max, bcl.min, bcl.max))
60                 end
61         end
62 end end