4 category = "Amplifier",
6 author = "Robin Gareus",
7 email = "robin@gareus.org",
8 site = "http://gareus.org",
10 An Example DSP Plugin for processing audio, to
11 be used with Ardour's Lua scripting facility.]]
15 -- return possible i/o configurations
16 function dsp_ioconfig ()
17 -- -1, -1 = any number of channels as long as input and output count matches
18 return { [1] = { audio_in = -1, audio_out = -1}, }
21 -- optional function, called when configuring the plugin
22 function dsp_configure (ins, outs)
23 -- store configuration in global variable
24 audio_ins = ins:n_audio();
25 local audio_outs = outs:n_audio()
26 assert (audio_ins == audio_outs)
29 -- this variant asks for a complete *copy* of the
30 -- audio data in a lua-table.
31 -- after processing the data is copied back.
33 -- this also exemplifies the direct "connect and run" process function,
34 -- where the channel-mapping needs to be done in lua.
36 function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
37 for c = 1,audio_ins do
38 -- Note: lua starts counting at 1, ardour's ChanMapping::get() at 0
39 local ib = in_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped input buffer for given cannel
40 local ob = out_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped output buffer for given cannel
41 assert (ib ~= ARDOUR.ChanMapping.Invalid);
42 assert (ob ~= ARDOUR.ChanMapping.Invalid);
43 local a = bufs:get_audio (ib):data (offset):get_table(n_samples) -- copy audio-data from input buffer
44 for s = 1,n_samples do
45 a[s] = a[s] * 2; -- amplify data in lua table
47 bufs:get_audio(ob):data(offset):set_table(a, n_samples) -- copy back