3 name = "Simple Amp II",
6 author = "Ardour Lua Task Force",
8 An Example DSP Plugin for processing audio, to
9 be used with Ardour's Lua scripting facility.]]
13 function dsp_ioconfig ()
14 return { [1] = { audio_in = -1, audio_out = -1}, }
17 function dsp_configure (ins, outs)
18 audio_ins = ins:n_audio();
19 local audio_outs = outs:n_audio()
20 assert (audio_ins == audio_outs)
24 -- this variant modifies the audio data in-place
25 -- in Ardour's buffer.
27 -- It relies on the fact that by default Ardour requires
28 -- plugins to process data in-place (zero copy).
30 -- Every assignment directly calls a c-function behind
31 -- the scenes to get/set the value.
32 -- It's a bit more efficient than "Amp I" on most systems.
34 function dsp_runmap (bufs, in_map, out_map, n_samples, offset)
35 for c = 1,audio_ins do
36 -- ensure that processing does happen in-place
37 local ib = in_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped input buffer for given cannel
38 local ob = out_map:get(ARDOUR.DataType("audio"), c - 1); -- get id of mapped output buffer for given cannel
39 assert (ib ~= ARDOUR.ChanMapping.Invalid);
40 assert (ob ~= ARDOUR.ChanMapping.Invalid);
42 local bi = bufs:get_audio(ib)
43 local bo = bufs:get_audio(ob)
44 assert (bi:sameinstance(bo))
46 local a = bufs:get_audio(ib):data(offset):array() -- get a reference (pointer to array)
47 for s = 1,n_samples do
48 a[s] = a[s] * 2; -- modify data in-place (shared with ardour)