5 author = "Ardour Team",
7 description = [[Linear Timecode Decoder with mixer strip inline display]]
10 function dsp_ioconfig ()
11 return { { audio_in = 1, audio_out = 1}, }
14 function dsp_init (rate)
17 ltc_reader = ARDOUR.DSP.LTCReader (rate / 25, ARDOUR.DSP.LTC_TV_STANDARD.LTC_TV_FILM_24)
18 self:shmem():allocate(5)
21 function dsp_run (ins, outs, n_samples)
22 if ins[1] ~= outs[1] then
23 ARDOUR.DSP.copy_vector (outs[1]:offset (0), ins[1]:offset (0), n_samples)
25 ltc_reader:write (ins[1]:offset (0), n_samples, 0)
26 timeout = timeout + n_samples
27 local to_ui = self:shmem():to_int(0):array()
31 rv, tc = ltc_reader:read (0, 0, 0, 0)
34 self:shmem():atomic_set_int (0, 1)
35 self:shmem():atomic_set_int (1, tc[1])
36 self:shmem():atomic_set_int (2, tc[2])
37 self:shmem():atomic_set_int (3, tc[3])
38 self:shmem():atomic_set_int (4, tc[4])
42 if timeout > samplerate then
43 if 0 ~= self:shmem():atomic_get_int (0) then
44 self:shmem():atomic_set_int (0, 0)
50 -------------------------------------------------------------------------------
53 local txt = nil -- a pango context
56 function render_inline (ctx, displaywidth, max_h)
58 txt = Cairo.PangoLayout (ctx, "Mono 10px")
61 local d = self:shmem():to_int(0):array()
63 txt:set_text("--:--:--:--")
65 txt:set_text(string.format("%02d:%02d:%02d:%02d", d[2], d[3], d[4], d[5]))
68 -- compute the size of the display
69 local txtwidth, lineheight = txt:get_pixel_size()
70 local displayheight = math.min(vpadding + (lineheight + vpadding), max_h)
73 ctx:rectangle (0, 0, displaywidth, displayheight)
74 ctx:set_source_rgba (.2, .2, .2, 1.0)
76 ctx:set_source_rgba (.8, .8, .8, 1.0)
77 ctx:move_to ((displaywidth - txtwidth) / 2, 1)
78 txt:show_in_cairo_context (ctx)
80 return {displaywidth, displayheight}