fix bypassing plugins with sidechain i/o
[ardour.git] / scripts / hplp.lua
index f894732e7db90323e861c5a8c23bbf3dd01dd94a..40cd22254efffefcae31ba2dacf5f1512b8e4481 100644 (file)
@@ -76,11 +76,12 @@ function dsp_configure (ins, outs)
                        filters[c][k] = ARDOUR.DSP.Biquad (rate) -- initialize filters
                end
        end
+       cur = {0, 0, 0, 0}
 end
 
 -- helper functions for parameter interpolation
 function param_changed (ctrl)
-       if ctrl[1] == cur[1] and ctrl[2] == cur[2] and ctrl[3] == cur[3] and ctrl[4] == cur[4] then
+       if math.floor(ctrl[1]) == math.floor(cur[1]) and math.floor(ctrl[2]) == math.floor(cur[2]) and ctrl[3] == cur[3] and ctrl[4] == cur[4] then
                return false
        end
        return true
@@ -139,7 +140,7 @@ function dsp_run (ins, outs, n_samples)
                siz = 64
        end
 
-       local o = cur[2]
+       local o = math.floor(cur[2])
 
        while n_samples > 0 do
                if changed then apply_params (CtrlPorts:array ()) end
@@ -149,16 +150,12 @@ function dsp_run (ins, outs, n_samples)
                for c = 1,#ins do
                        -- check if output and input buffers for this channel are identical
                        -- http://manual.ardour.org/lua-scripting/class_reference/#C:FloatArray
-                       if false then --- ins[c]:sameinstance (outs[c]) then
-                               for k = 1,o do
-                                       filters[c][k]:run (ins[c]:offset (off), siz) -- in-place processing
-                               end
-                       else
+                       if not ins[c]:sameinstance (outs[c]) then
                                -- http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:DSP
                                ARDOUR.DSP.copy_vector (outs[c]:offset (off), ins[c]:offset (off), siz)
-                               for k = 1,o do
-                                       filters[c][k]:run (outs[c]:offset (off), siz)
-                               end
+                       end
+                       for k = 1,o do
+                               filters[c][k]:run (outs[c]:offset (off), siz) -- in-place processing
                        end
                end
 
@@ -267,7 +264,7 @@ function render_inline (ctx, w, max_h)
        grid_freq (ctx, w, h, 10000)
        ctx:unset_dash ()
 
-       local o = cur[2]
+       local o = math.floor(cur[2])
        -- draw transfer function line
        ctx:set_source_rgba (.8, .8, .8, 1.0)
        ctx:move_to (-.5, db_to_y (o * filt:dB_at_freq (freq_at_x (0, w)), h))