Implicit feedback loop

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hi guys,

I'm trying to replace a "classic" z^-1 feedback loop with its implicit version. The original code is something like that:

Code: Select all

float last = 0.f; //it's global

for (int i = 0; i < samples; ++i)
{
   signal[i] = signal[i] + last * feedback;
   last = signal[i]; 
}
I tried to figure out the implicit version following Urs's tutorials but I'm sure I'm wrong.

Code: Select all

float s = 0.f; //it's global

for (int i = 0; i < samples; ++i)
{
   float y = (signal[i] + s) * feedback;
   signal[i] = signal[i] + y;
   s = 2.f * y - s;
}
In the implicit version, I can get a "nice" powerful feedback only if I do "signal + y * 2.f". I'm pretty sure there's a better way to do that and any advice will be greatly appreciated.

Thanks!
Luca

Post

I don't think Urs was really about solving the unit delay as he was about solving methods where the present value relied upon the present output. Feedback in the way you're describing it is some previous output influencing the current one. I mean, I can kinda ballpark what you're suggesting, but it's not going to do what you want it to do.

For example, let's imagine that a "real-time" feedback algorithm might look like this:

y[n] = x[n] + g*y[n] + s[n]

Present input plus the gain of whatever the current output is, right? Okay, reshuffle the equation:

y[n] - g*y[n] = x[n] + s[n]
y[n] * (1 - g) = x[n] + s[n]
y[n] = (x[n] + s[n])/(1-g)

With s[n] = 2*y[n] - s[n]

So I actually built this real quick in Reaper JS. The nice thing is that it does precisely what you might expect it to - values of g that are very negative reduce volume, as g approaches zero it boosts volume, as g goes positive it raises amplitude dramatically.

Basically, it's a fancy volume control. If you modify it a little to

y[n] = x[n] + g*(y[n] + s[n])

Then it works a little more conventionally for g 0 ... 1. Either way, it's a fancy volume control.

Post

In other words, a unit delay feedback equation would be something like

y[n] = x[n] + g*y[n-1]

There is no y[n] on the right hand side of the equation. Since there is none, there is no implicit equation juggling a la Urs.

Post

For a lowpass of course you'd write

y[n] = g*(x[n] - y[n]) + s[n]

and

s[n+1] = 2*y[n] - s[n]

:)

Post

Thanks guys. Yes, I already implemented the code for a LPF and it works. I was assuming that I could (someway) solve the state to get a feedback signal without have to store the previous sample, to be used in a trivial waveshaper.. something like y = tanh(input + y-1 * fbk)

I guess I'll stick with the z-1 approach for now.

Cheers,
Luca

Post

Audiority wrote:Thanks guys. Yes, I already implemented the code for a LPF and it works. I was assuming that I could (someway) solve the state to get a feedback signal without have to store the previous sample, to be used in a trivial waveshaper.. something like y = tanh(input + y-1 * fbk)

I guess I'll stick with the z-1 approach for now.

Cheers,
Luca
I think it's important to mention that, even in analog feedback loops, there is some lowpass filtering.

Post

True. I just reminded that while looking at some schematics today. The non-linear feedback will often include an RC filter in the path.

Post Reply

Return to “DSP and Plugin Development”