Clouds firmware hacking help

I’m trying to implement some new effects on Clouds, nothing special, just some very basic effects for me to learn with.

Currently I am trying to process the audio buffer through my own simple filter. I am trying to do it without fx_engine.h because I haven’t fully grasped it yet. However, I am running into issues where the signal does seem to filter, but it is picking up high pitched artifacts/distortion. Is it viable to process the buffer like this below, or do I need to use the fx_engine.h properties?

Also any explanations on the fx_engine.h file would be helpful, particularly the Context class. I am slowly starting to understand it and parts of it make sense to me, but as someone that is coming from C and doesn’t have ample C++ experience, it is a bit foreign. Either way I am learning a great deal already and having lots of fun with this

Here is a snipped from my Process function in my new fx header file (it was based off reverb.h but stripped down). I am just trying to filter the left and right channel with the coefficients based off a potentiometer value (the amount variable).

// Filter: y(n) = a0 * x(n) + a1 * x(n - 1)
float a1 = amount;
float a0 = a1 - 1.0f;
float z1_left = 0.0f;
float z1_right = 0.0f;

while (size–) {
// process left channel
float xn = in_out->l;
float xn_1 = z1_left;
float yn = a0 * xn + a1 * xn_1;
z1_left = xn;
in_out->l = yn;

// process right channel
xn = in_out->r;
xn_1 = z1_right;
yn = a0 * xn + a1 * xn_1;
z1_right = xn;
in_out->r = yn;

fx_engine has been written to make it easy to port code written for the FV-1 (it mimics the instruction set and architecture of this chip). You don’t have to use it. The Context class stores the “state” of the chip (value of accumulator, write pointer, LFOs), and is small enough for all its members to stay in registers while the FX code runs.

Regarding your code, do you increment in_out?

Got it. Yes I am incrementing, here is the full snippet below. My init does nothing since i am not using the fx_engine.

(Sorry for formatting. Lines that start with spaces are just merging with the previous line, and i’m not sure how to fix it)

void Init(uint16_t* buffer) {
// engine_.Init(buffer);
}

void Process(FloatFrame* in_out, size_t size) {
float amount = amount_;
if (amount > 0.49f) {
amount = 0.49f;
} else if (amount < 0.0f) {
amount = 0.0f;
}

// filter setup
float a1_left = amount;
float a1_right = amount;
float a0_left = a1_left - 1.0f;
float a0_right = a1_right - 1.0f;
float z1_left = 0.0f;
float z1_right = 0.0f;

while (size–) {

// process left channel
float xn = in_out->l;
float xn_1 = z1_left;
float yn = a0_left * xn + a1_left * xn_1;
z1_left = xn;
in_out->l = yn;
// process right channel
xn = in_out->r;
xn_1 = z1_right;
yn = a0_right * xn + a1_right * xn_1;
z1_right = xn;
in_out->r = yn;
++in_out;
}
}

Ok got it, stupid mistake. I was forgetting to normalize my fc. Thanks!