FIRフィルタの実装1 FIFO(first-in-first-out) Buffer


// N : number of coefficients
// h(n) : filter coefficients, n = 0,…N-1
// x(n) : stored input data, n = 0,…N-1
// input sample : variable that contains the newest input sample

// Shift in the new sample. Note the data is shifted starting at the end

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