Digital Signal Processing Reference
In-Depth Information
// Echo_control.c Echo effects with fading
//3 sliders to control effects: buffer size, amplitude, fading
#include "DSK6713_AIC23.h" //codec-DSK file support
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ; //set sampling rate
short input, output;
short buffer[8000];
//max size of buffer
short bufferlength = 1000;
//initial buffer size
short i = 0;
//buffer index
short delay = 3;
//determines size of buffer
short delay_flag = 1;
//flag if buffer size changes
short amplitude = 5;
//amplitude control by slider
short echo_type = 1;
//1 for fading(0 with no fading)
main()
{
short new_count;
//count for new buffer
comm_poll();
//init DSK, codec, McBSP
while(1)
//infinite loop
{
output=input+0.1*amplitude*buffer[i];//newest + oldest samples
if (echo_type == 1)
//if fading is desired
{
new_count = (i-1) % bufferlength; //previous buffer location
buffer[new_count] = output;
//to store most recent output
}
output_sample(output); //output delayed sample
input = input_sample(); //newest input sample data
if (delay_flag != delay) //if delay has changed
{ //new buffer size
delay_flag = delay;
//reint for future change
bufferlength = 1000*delay;
//new buffer length
i = 0;
//reinit buffer count
}
buffer[i] = input;
//store input sample
i++;
//increment buffer index
if (i == bufferlength) i=0;
//if @ end of buffer reinit
}
}
FIGURE 2.17. Echo generation with controls for different effects ( echo_control.c ).
.wav file, Theforce.wav (on the CD), for input, as in Example 2.10. The output
is the sum of the newest input sample plus the oldest sample. Note that for fading,
the output is stored in the buffer.
1. Build and run this project as echo_control .
2. Access the three sliders: amplitude, delay, and type. The GEL file
echo_control.gel is shown in Figure 2.18. Set the amplitude slider to posi-
Search WWH ::




Custom Search