Based on: Audio Effects: Using External Memory by Douglas L. Jones, Swaroop Appadwedula, Matthew Berry, Mark Haun, Dima Moussa, Daniel Sachs
Summary: You will implement three audio effects: a fixed-length delay, a variable-length delay, and a feedback-echo. All require storing many samples in external memory.
Many audio effects require storing thousands of samples in memory on the DSP. Because there is not enough memory on the DSP microprocessor itself to store so many samples, external memory must be used.
In this exercise, you will use external memory to implement a long audio delay and an audio echo.
You will implement three audio effects: a long, fixed-length delay, a variable-length delay, and a feedback-echo.
First, implement the 131,072-sample delay shown in Figure 1. Store the samples in a buffer in SDRAM with alignment 0x40000h. Do this by adding a line in your userlinker.cmd file to create a new section in memory:
Allocate a buffer of the size you need in the assembly file. Be sure to place it in the section you just created.
Since the memory address is now greater than 16-bits, you will need to do a MOV dbl() in order to get the full address into an auxiliary register.
.bigbuffer: align=0x40000 {} > SDRAM![]() |
Remember that arithmetic operations that act on the
accumulators, such as the add instruction,
operate on the complete 32- or 40-bit value. Also keep in
mind that since 131,072 is a power of two, you can use
masking (via the and instruction) to implement
the circular buffer easily. This delay will be easy to
verify on the oscilloscope. (How long, in seconds, do you
expect this delay to be?) If you want, you may assume the delay will be a power-of-2 for easier implementation.
Once you have your fixed-length delay working, make a copy and modify it so that the delay can be changed to any length between zero (or one) and 131,072 samples by changing the value stored in one double-word pair in memory. You should keep the buffer length equal to 131,072 and change only your addressing of the sample being read back; it is more difficult to change the buffer size to a length that is not a power of two.
Verify that your code works as expected by timing the delay from input to output and ensuring that it is approximately the correct length.
Last, copy and modify your code so that the value taken from the end of the variable delay from Variable-delay implementation is multiplied by a gain factor and then added back into the input, and the result is both saved into the delay line and sent out to the digital-to-analog converters. Figure 2 shows the block diagram. (It may be necessary to multiply the input by a gain as well to prevent overflow.) This will make a one-tap feedback echo, an simple audio effect that sounds remarkably good. To test the effect, connect the DSP EVM input to a CD player or microphone and connect the output to a loudspeaker. Verify that the echo can be heard multiple times, and that the spacing between echoes matches the delay length you have chosen.
![]() |
"Real-Time DSP with MATLAB"