luaproc: assert instance access
This commit is contained in:
parent
204c8016c7
commit
5bbfd0d1bd
@ -34,8 +34,17 @@ end
|
|||||||
|
|
||||||
function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
|
function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
|
||||||
for c = 1,audio_ins do
|
for c = 1,audio_ins do
|
||||||
local b = in_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped buffer
|
-- ensure that processing does happen in-place
|
||||||
local a = bufs:get_audio(b):data(offset):array() -- get a reference (pointer to array)
|
local ib = in_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped input buffer for given cannel
|
||||||
|
local ob = out_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped output buffer for given cannel
|
||||||
|
assert (ib ~= ARDOUR.ChanMapping.Invalid);
|
||||||
|
assert (ob ~= ARDOUR.ChanMapping.Invalid);
|
||||||
|
|
||||||
|
local bi = bufs:get_audio(ib)
|
||||||
|
local bo = bufs:get_audio(ob)
|
||||||
|
assert (bi:sameinstance(bo))
|
||||||
|
|
||||||
|
local a = bufs:get_audio(ib):data(offset):array() -- get a reference (pointer to array)
|
||||||
for s = 1,n_samples do
|
for s = 1,n_samples do
|
||||||
a[s] = a[s] * 2; -- modify data in-place (shared with ardour)
|
a[s] = a[s] * 2; -- modify data in-place (shared with ardour)
|
||||||
end
|
end
|
||||||
|
@ -31,15 +31,15 @@ end
|
|||||||
-- This is as efficient as Ardour doing it itself in C++
|
-- This is as efficient as Ardour doing it itself in C++
|
||||||
-- Lua function overhead is negligible
|
-- Lua function overhead is negligible
|
||||||
--
|
--
|
||||||
-- this also exemplifies the /simpler/ way of letting ardour to
|
-- this also exemplifies the /simpler/ way of delegating the
|
||||||
-- the channel and offset mapping.
|
-- channel-mapping to ardour.
|
||||||
|
|
||||||
function dsp_run (ins, outs, n_samples)
|
function dsp_run (ins, outs, n_samples)
|
||||||
local ctrl = CtrlPorts:array() -- get control port array (read/write)
|
local ctrl = CtrlPorts:array() -- get control port array (read/write)
|
||||||
local gain = ARDOUR.DSP.dB_to_coefficient (ctrl[1])
|
local gain = ARDOUR.DSP.dB_to_coefficient (ctrl[1])
|
||||||
assert (#ins == #outs) -- ensure that we can run in-place
|
assert (#ins == #outs) -- ensure that we can run in-place (channel count matches)
|
||||||
for c = 1,#ins do
|
for c = 1,#ins do
|
||||||
--for c in pairs (ins) do -- also works, slightly less effective
|
assert (ins[c]:sameinstance(outs[c])) -- check in-place
|
||||||
ARDOUR.DSP.apply_gain_to_buffer (ins[c], n_samples, gain); -- process in-place
|
ARDOUR.DSP.apply_gain_to_buffer (ins[c], n_samples, gain); -- process in-place
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user