ABSTRACT

Before we can start looking at some fi nite impulse response (FIR) algorithms, we need to deal with the concept of long delay lines or circular buffers. Not only are they used for the delay effects, but also they are needed to make long FIR fi lters. In this chapter we’ll take a break from the DSP fi lter algorithms and develop some digital delays. If you think back to the infi nite impulse response (IIR) fi lters you’ve worked on so far you will remember that after implementing the difference equation, you need to shuffl e the z −1 delay element values. You do this by overwriting the delays backwards, like this:

m_f_z2 5 m_f_z1; m_f_z1 5 xn ; // xn is the input sample

Suppose you had a fi lter that was higher than a second-order one and you had to implement z −4 using discrete variables for each delay element. You might wind up writing something like this to do the shuffl ing:

m_f_z4 5 m_f_z3; m_f_z3 5 m_f_z2; m_f_z2 5 m_f_z1; m_f_z1 5 xn ; // xn is the input sample

But what happens when the delay line gets really long, like z −1024 or, for a 1-second digital delay, z −44100 ? It’s going to be diffi cult to implement the delay shuffl ing this way. Not only would it be tedious to code, it would also be very ineffi cient to have to implement all those read/write operations each sample period. The answer to the problem of long delay lines is called circular buffering.