1-pole high pass filter in Lua with VCV Prototype

Hi all,

EDIT: edited inquiry to reflect forum structure

I’m having a blast trying out the Lua scripting for the Prototype module. I have very minimal experience with DSP, mostly using Reaktor and JSFX. A question… perhaps due to my lack of familiarity with the VCV Prototype paradigm or DSP in general (I’m very much in the copy/pasting phase).

I hit a roadblock when implementing a 1-pole high pass filter. The last bits are:

lp_outl = 2*filterinput*lp_a0 + lp_outl*lp_b1
filteroutput = (filterinput-lp_outl)*outgain

And I get the following error:

attempt to perform arithmetic on global 'lp_outl' (a nil value)

I presume this is because I am using a recursive definition, but I don’t quite understand the fix.

Additionally, can someone shed some light on when it is appropriate to define variables in the body of function process(block) vs … block.bufferSize do. In JSFX, there is space for performing math on parameters at the control rate vs the samplerate, but I am unclear on where those distinctions lie in the Lua scripting model.

On this forum, typically thread topics are questions, and responses are answers or discussions to eventually obtain an answer. I have edited your title to refer to the question at hand.

Did you define lp_outl as a global in your script? Something like lp_outl = 0.0 at the root level of your script?

Code in process() runs every block. Code at the root level of your script runs once when your script is loaded before processing blocks.

Edit: saw my mistake.

Yeah, that passes audio for sure. I failed to init that variable in the root level. Thanks.