13
0
livetrax/scripts/amp3.lua

45 lines
1.2 KiB
Lua
Raw Normal View History

2016-02-23 09:44:41 -05:00
ardour {
["type"] = "dsp",
name = "Simple Amp III",
category = "Example",
2016-02-23 09:44:41 -05:00
license = "MIT",
author = "Ardour Lua Task Force",
2016-02-23 09:44:41 -05:00
description = [[
An Example DSP Plugin for processing audio, to
be used with Ardour's Lua scripting facility.]]
}
function dsp_ioconfig ()
return
{
{ audio_in = -1, audio_out = -1},
}
end
function dsp_params ()
return
{
{ ["type"] = "input", name = "Gain", min = -20, max = 20, default = 6, unit="dB", scalepoints = { ["0"] = 0, ["twice as loud"] = 6 , ["half as loud"] = -6 } },
}
end
-- use ardour's vectorized functions
--
-- This is as efficient as Ardour doing it itself in C++
-- Lua function overhead is negligible
--
2016-04-13 21:08:58 -04:00
-- this also exemplifies the /simpler/ way of delegating the
-- channel-mapping to ardour.
2016-02-23 09:44:41 -05:00
function dsp_run (ins, outs, n_samples)
local ctrl = CtrlPorts:array() -- get control port array (read/write)
local gain = ARDOUR.DSP.dB_to_coefficient (ctrl[1])
2016-04-13 21:08:58 -04:00
assert (#ins == #outs) -- ensure that we can run in-place (channel count matches)
2016-02-23 09:44:41 -05:00
for c = 1,#ins do
2016-04-13 21:08:58 -04:00
assert (ins[c]:sameinstance(outs[c])) -- check in-place
2016-02-23 09:44:41 -05:00
ARDOUR.DSP.apply_gain_to_buffer (ins[c], n_samples, gain); -- process in-place
end
end