AU: mark preset dirty when parameter changes
[ardour.git] / scripts / _smash.lua
1 ardour { ["type"] = "dsp", name = "Sound Smasher", category = "Dynamics", license = "MIT", author = "Ardour Lua Task Force", description = [[Another simple DSP example]] }
2
3 function dsp_ioconfig () return
4         -- -1, -1 = any number of channels as long as input and output count matches
5         { { audio_in = -1, audio_out = -1}, }
6 end
7
8
9 -- the DSP callback function to process audio audio
10 -- "ins" and "outs" are http://manual.ardour.org/lua-scripting/class_reference/#C:FloatArray
11 function dsp_run (ins, outs, n_samples)
12         for c = 1, #outs do -- for each output channel (count from 1 to number of output channels)
13
14                 if ins[c] ~= outs[c] then -- if processing is not in-place..
15                         ARDOUR.DSP.copy_vector (outs[c], ins[c], n_samples) -- ..copy data from input to output.
16                 end
17
18                 -- direct audio data access, in-place processing of output buffer
19                 local buf = outs[c]:array() -- get channel's 'c' data as lua array reference
20
21                 -- process all audio samples
22                 for s = 1, n_samples do
23                         buf[s] = math.atan (1.5707 * buf[s]) -- some non-linear gain.
24
25                         -- NOTE: doing the maths per sample in lua is not super-efficient
26                         -- (vs C/C++ vectorized functions -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:DSP)
27                         -- but it is very convenient, especially for prototypes and quick solutions.
28                 end
29
30         end
31 end