FIRフィルタの実装2 Double Size FIFO Buffer


// N : number of coefficients
// h(n) : filter coefficients, n = 0,…N-1
// x(n) : stored input data, n = 0,…2N-1
// input sample : variable that contains the newest input sample
// index : variable that contains the current place where the new sample is to be stored

x[index] = input_sample;
// Filter the data
ynew = 0;
for (i=0;i<N;i++){
    ynew = ynew + h(i)*x(index-i);
}
index = index + 1;

if (index>=2*N){
    for (i=N-2;i>=0;i--){
    x[i+N+1] = x[i];
}
index = N-1;
}