how oculd I get this counter working in an audio effect for scripting DSP in C? the…
- User
how oculd I get this counter working in an audio effect for scripting DSP in C? the coutner doesn't actually change, despite the fact, that it should increment every sample, so I need to make thisevaluated elsewise. /* Welcome to Formula!
codeIf this is your first time, be sure to check out the tutorials under the 'Saved files' tab.*/
formula_main { float output = input; int counter; counter++; DEBUG(counter);
codeif (counter >= 1) { counter = 0; return output; }}
- Assistant
The issue you're encountering with the
countervariable not updating as expected in the DSP script stems from the fact that the variable is declared inside the function, which makes it local to this function. Since is called (assumedly) for each audio sample, is re-initialized to its default (uninitialized) value each time, effectively resetting it before it has a chance to increment. Hence, does not maintain its value across function calls, preventing it from functioning as intended. - User
why doesn't this downsample code for an audio plugin for scripting DSP n lua not work? require "include/protoplug"
--Welcome to Lua Protoplug effect (version 1.4.0)
stereoFx.init()
local counter = 0
function stereoFx.Channel:init() end
function stereoFx.Channel:processBlock(s, smax) for i = 0,smax do counter = counter+1;
codeif counter >= samples then counter = 0; s[i] = s[i]; endend end
params = plugin.manageParams { { name = "Samples"; type = "int"; min = 1; max = 100; default = 1; changed = function(val) samples = val end; };
}
- Assistant