Digital Signal Processing Reference
In-Depth Information
// Adaptpredict.C Adaptive predictor to cancel interference
#include "DSK6713_AIC23.h" //codec-DSK support file
Uint32 fs=DSK6713_AIC23_FREQ_8KHZ;//set sampling rate
#include "wbsignal.h" //wide-band signal table look-up
#define beta 1E-14 //rate of convergence
#define N 60 //# of coefficients of adapt FIR
const short bufferlength = NS; //buffer length for wideband signal
short splusn[N+1];
//buffer wideband signal+interference
float w[N+1];
//buffer for weights of adapt FIR
float delay[N+1];
//buffer for input to adapt FIR
interrupt void c_int11() //ISR
{
static short buffercount=0; //init buffer
int i;
float yn, E;
//yn=out adapt FIR, error signal
short wb_signal;
//wideband desired signal
short noise;
//external interference
wb_signal=wbsignal[buffercount]; //wideband signal from look-up table
noise = input_sample(); //external input as interference
splusn[0] = wb_signal + noise; //wideband signal+interference
delay[0] = splusn[3]; //delayed input to adaptive FIR
yn = 0; //init output of adaptive FIR
for (i = 0; i < N; i++)
yn += (w[i] * delay[i]); //output of adaptive FIR filter
E = splusn[0] - yn; //(wideband+noise)-out adapt FIR
for (i = N-1; i >= 0; i--)
{
w[i] = w[i]+(beta*E*delay[i]); //update weights of adapt FIR
delay[i+1] = delay[i]; //update buffer delay samples
splusn[i+1] = splusn[i]; //update buffer corrupted wideband
}
buffercount++; //incr buffer count of wideband
if (buffercount >= bufferlength) //if buffer count=length of buffer
buffercount = 0; //reinit count
output_sample((short)E); //overall output
return;
}
void main()
{
int T = 0;
for (T = 0; T < N; T++) //init variables
{
w[T] = 0.0;
//buffer for weights of adaptive FIR
delay[T] = 0.0;
//buffer for delay samples
splusn[T] = 0;
//buffer for wideband+interference
}
comm_intr(); //init DSK, codec, McBSP
while(1); //infinite loop
}
FIGURE 7.24. Adaptive predictor program for cancellation of narrowband interference in
the presence of a wideband signal ( adaptpredict.c ).
Search WWH ::




Custom Search