13
0
livetrax/share/scripts/_amp1.lua

48 lines
1.6 KiB
Lua
Raw Normal View History

2016-02-23 09:44:41 -05:00
ardour {
["type"] = "dsp",
name = "Simple Amp",
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.]]
}
-- return possible i/o configurations
function dsp_ioconfig ()
-- -1, -1 = any number of channels as long as input and output count matches
return { [1] = { audio_in = -1, audio_out = -1}, }
end
-- optional function, called when configuring the plugin
function dsp_configure (ins, outs)
-- store configuration in global variable
audio_ins = ins:n_audio();
local audio_outs = outs:n_audio()
assert (audio_ins == audio_outs)
end
-- this variant asks for a complete *copy* of the
-- audio data in a lua-table.
-- after processing the data is copied back.
--
-- this also exemplifies the direct "connect and run" process function,
-- where the channel-mapping needs to be done in lua.
function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
for c = 1,audio_ins do
-- Note: lua starts counting at 1, ardour's ChanMapping::get() at 0
2016-07-10 10:48:38 -04:00
local ib = in_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped input buffer for given channel
local ob = out_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped output buffer for given channel
2016-02-23 09:44:41 -05:00
assert (ib ~= ARDOUR.ChanMapping.Invalid);
assert (ob ~= ARDOUR.ChanMapping.Invalid);
local a = bufs:get_audio (ib):data (offset):get_table(n_samples) -- copy audio-data from input buffer
for s = 1,n_samples do
a[s] = a[s] * 2; -- amplify data in lua table
end
bufs:get_audio(ob):data(offset):set_table(a, n_samples) -- copy back
end
end