diff options
author | Robin Gareus <robin@gareus.org> | 2018-10-19 19:13:36 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2018-10-20 00:24:38 +0200 |
commit | bfc35e514b2ffe06e9b0b8c54bb4ec283d931f5b (patch) | |
tree | 733a42e0aba8244127e04aa0420433e591e6780a | |
parent | 4c02780262879c5f47fa9fa774611e5c989c158c (diff) |
Example convolution plugin (Lua script, hardcoded IR)
-rw-r--r-- | scripts/_convolv.lua | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/scripts/_convolv.lua b/scripts/_convolv.lua new file mode 100644 index 0000000000..b2f6b477ab --- /dev/null +++ b/scripts/_convolv.lua @@ -0,0 +1,57 @@ +ardour { ["type"] = "dsp", name = "Lua Convolver", license = "MIT", author = "Ardour Lua Task Force", description = [[Another simple DSP example]] } + +function dsp_ioconfig () return + { + { audio_in = 1, audio_out = 1}, + { audio_in = 1, audio_out = 2}, + { audio_in = 2, audio_out = 2}, + } +end + +local conv, mode, ir_file + +ir_file = "/tmp/reverbs/St Nicolaes Church.wav" +ir_file = "/tmp/reverbs/Large Wide Echo Hall.wav" + +function dsp_configure (ins, outs) + if outs:n_audio() == 1 then + assert (ins:n_audio() == 1) + mode = ARDOUR.DSP.IRChannelConfig.Mono + elseif ins:n_audio() == 1 then + assert (outs:n_audio() == 2) + mode = ARDOUR.DSP.IRChannelConfig.MonoToStereo + else + assert (ins:n_audio() == 2) + assert (outs:n_audio() == 2) + mode = ARDOUR.DSP.IRChannelConfig.Stereo + end + + conv = ARDOUR.DSP.Convolver (Session, ir_file, mode, 0) + collectgarbage () +end + +function dsp_latency () + if conv then + return conv:latency() + else + return 0 + end +end + +-- the DSP callback function to process audio audio +-- "ins" and "outs" are http://manual.ardour.org/lua-scripting/class_reference/#C:FloatArray +function dsp_run (ins, outs, n_samples) + assert (#ins <= #outs) + + for c = 1, #ins do + if ins[c] ~= outs[c] then -- if processing is not in-place.. + ARDOUR.DSP.copy_vector (outs[c], ins[c], n_samples) -- ..copy data from input to output. + end + end + + if #outs == 1 then + conv:run (outs[1], n_samples) + else + conv:run_stereo (outs[1], outs[2], n_samples) + end +end |