1 ardour { ["type"] = "dsp", name = "DSP Plugin Communication" }
2 function dsp_ioconfig () return { { audio_in = -1, audio_out = -1} } end
4 function dsp_init (rate)
5 self:shmem ():allocate (1)
8 function dsp_configure (ins, outs)
11 function dsp_params ()
14 { ["type"] = "output", name = "self", min = 0, max = 8},
15 { ["type"] = "output", name = "gain", min = 0, max = 2},
19 function dsp_run (ins, outs, n_samples)
20 local ctrl = CtrlPorts:array ()
21 local route = self:route ()
22 local shmem = self:shmem ()
27 local s = -1; -- 'self' this plugin instance
29 -- iterate overall plugins on this track,
30 -- find all LuaProc instances of this plugin (unique_id),
32 local proc = route:nth_plugin (i)
34 and not proc:to_insert():plugin (0):to_luaproc():isnil ()
35 and proc:to_insert():plugin (0):unique_id () == self:unique_id () then
36 if (self:id ():to_s() == proc:to_insert():plugin (0):id ():to_s()) then
37 s = l; -- *this* plugin instance
40 -- use shared-memory are of the first plugin instance for all.
42 -- (the first plugin writes there, all later plugins only read,
43 -- plugins on a track are executed in order, in the same thread)
44 shmem = proc:to_insert():plugin (0):to_luaproc():shmem ()
46 l = l + 1 -- count total instances of this plugin-type
54 -- calculate digital peak of all channels
57 if not ins[c]:sameinstance (outs[c]) then
58 ARDOUR.DSP.copy_vector (outs[c], ins[c], n_samples)
60 peak = ARDOUR.DSP.compute_peak(outs[c], n_samples, peak)
64 -- actual inter-plugin communication
65 local a = shmem:to_float (0):array ()
67 -- the first plugin saves the peak
71 -- all later plugins display the difference to the first.