ffffd57361fceda61cc44c236874c7d8c00f7d0f
[ardour.git] / scripts / amp3.lua
1 ardour {
2         ["type"]    = "dsp",
3         name        = "Simple Amp III",
4         license     = "MIT",
5         author      = "Robin Gareus",
6         email       = "robin@gareus.org",
7         site        = "http://gareus.org",
8         description = [[
9         An Example DSP Plugin for processing audio, to
10         be used with Ardour's Lua scripting facility.]]
11 }
12
13 function dsp_ioconfig ()
14         return
15         {
16                 { audio_in = -1, audio_out = -1},
17         }
18 end
19
20
21 function dsp_params ()
22         return
23         {
24                 { ["type"] = "input", name = "Gain", min = -20, max = 20, default = 6, unit="dB", scalepoints = { ["0"] = 0, ["twice as loud"] = 6 , ["half as loud"] = -6 } },
25         }
26 end
27
28
29 -- use ardour's vectorized functions
30 --
31 -- This is as efficient as Ardour doing it itself in C++
32 -- Lua function overhead is negligible
33 --
34 -- this also exemplifies the /simpler/ way of delegating the
35 -- channel-mapping to ardour.
36
37 function dsp_run (ins, outs, n_samples)
38         local ctrl = CtrlPorts:array() -- get control port array (read/write)
39         local gain = ARDOUR.DSP.dB_to_coefficient (ctrl[1])
40         assert (#ins == #outs) -- ensure that we can run in-place (channel count matches)
41         for c = 1,#ins do
42                 assert (ins[c]:sameinstance(outs[c])) -- check in-place
43                 ARDOUR.DSP.apply_gain_to_buffer (ins[c], n_samples, gain); -- process in-place
44         end
45 end