# how do I derive the system equation for a simple delay with feedback?

I am a software engineer, and just learning digital signal processing formally, though I've hacked around before a fair amount.

I'm implementing a delay audio VST and I'm trying to wrap my head around how one creates equations of the output given a system diagram. I'm not used to circuit diagrams (they're weirdly parallel to me), so I'm trying to figure out how one goes from this system diagram:

to an equation. As best I can tell, the equation for this is:

y[t] = x[t] + y[t - T] * gain


where x[t] is the input on the far left, y[t] is the output on the far right, and the delay time in samples is T.

Is this correct?

I don't fully see how the system diagram implies the second term is y[t - T] rather than x[t - T], but intuitively, I know it must be, because an audio delay unit can't really incorporate feedback if the original signal delay only happens once (feedback must enable the ever-decaying ringing with time). Otherwise we'd get just a shifted version of the original, added to the original. This would be boring.

## 1 Answer

In such cases it helps to define an additional signal $$w[n]$$ at the input of the delay. Now you can write down two equations describing the system:

\begin{align}w[n]&=x[n]+g\cdot w[n-N]\\y[n]&=x[n]+w[n-N]\end{align}\tag{1}

where $$N$$ denotes the delay (in samples) and $$g$$ is the feedback gain. From the second equation you can express $$w[n-N]$$ in terms of $$x[n]$$ and $$y[n]$$:

$$w[n-N]=y[n]-x[n]\tag{2}$$

Plugging this into the first equation gives

$$y[n+N]-x[n+N]=x[n]+g\cdot \left(y[n]-x[n]\right)\tag{3}$$

Rearranging and subtracting $$N$$ from all indices results in

$$y[n]=x[n]+(1-g)x[n-N]+g\cdot y[n-N]\tag{4}$$

Eq. $$(4)$$ is the (single) difference equation describing the system. However, it's more efficient to implement the system using the two equations given in $$(1)$$.

• Hm, when you say define an additional signal 𝑤[𝑛] at the input of the delay, you are essentially drawing a box around, what exactly? Is it starting at the arrow directly into the "+" circle before the delay and then ending as the output coming from the "Delay" box? If so, I'm not sure why you'd write the time index as 𝑤[𝑛-N] in the y[n] equation - doesn't the delay happen inside of w? Just trying to figure out what subsystem you're referring to. – lollercoaster Sep 7 '19 at 2:48
• @lollercoaster: The signal $w[n]$ is just directly at the input of the delay. That's why at the output of the delay you have $w[n-N]$. – Matt L. Sep 9 '19 at 5:46