1ardour { 2 ["type"] = "dsp", 3 name = "Simple Amp II", 4 category = "Example", 5 license = "MIT", 6 author = "Ardour Team", 7 description = [[ 8 An Example DSP Plugin for processing audio, to 9 be used with Ardour's Lua scripting facility.]] 10} 11 12-- see amp1.lua 13function dsp_ioconfig () 14 return { [1] = { audio_in = -1, audio_out = -1}, } 15end 16 17function dsp_configure (ins, outs) 18 audio_ins = ins:n_audio(); 19 local audio_outs = outs:n_audio() 20 assert (audio_ins == audio_outs) 21end 22 23 24-- this variant modifies the audio data in-place 25-- in Ardour's buffer. 26-- 27-- It relies on the fact that by default Ardour requires 28-- plugins to process data in-place (zero copy). 29-- 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. 33 34function 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); 41 42 local bi = bufs:get_audio(ib) 43 local bo = bufs:get_audio(ob) 44 assert (bi == bo) 45 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) 49 end 50 end 51end 52