A Delay effect can be implemented in real time thanks to a FIR filter or to an IIR filter.
The FIR filter for delay effect can be implement thanks to the following input-output equation ($e[t]$ is the input, $s[t]$ is the output): $$ s[t] = e[t] + \alpha e[t-D] $$ $\alpha\geq 0$ is the attenuation factor, and $D$ the time delay.
The IIR filter for delay effect can be implement thanks to the following input-output equation ($e[t]$ is the input, $s[t]$ is the output): $$ s[t] = \alpha e[t] + \beta s[t-D] $$ $\alpha\geq 0$ is the scaling factor, $\beta\geq 0$ the attenuation factor and $D\geq 0$ the time delay.
For both filters performs:
(1) check the linearity, the time-invariance andthe causality,
(2) Determine the transfert functions and the impulse response (for the IIR filter, determine the impulse response only for the cases $D=1$ and $D=2$).
(3) Determine the complex gain and the frequency response of the filter.
Performs a Matlab implementation and analysis of the two filters