You need to load the time domain coefficients using (loadTimeDomainCoefficients). You need to define the window size N for the algorithm using init. This assumes that all input audio data (which is filtered) will be of the same window size (block size) as the time domain coefficients. Call the filter method with input to convolve with h to produce the output.
#include <iostream>
int main(
int argc,
char *argv[]){
int chCnt=2;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> h;
h=Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>::Random(N,chCnt);
int Mx=10;
int Nx=Mx*200;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>
x,
y;
x=Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>::Random(Nx,chCnt);
y.setZero(x.rows(), x.cols());
for (int i=0; i<Nx/Mx; i++)
fir.
filter(x.block(i*Mx, 0, Mx, chCnt), y.block(i*Mx, 0, Mx, chCnt));
vector<string> args(1); args[0]=string("");
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> yHat, A;
A.setOnes(1,1);
yHat.setZero(x.rows(), x.cols());
for (int i=0; i<chCnt; i++){
vector<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> > input, output;
input.push_back(h.col(i));
input.push_back(A);
input.push_back(x.col(i));
octave.
runM(
"filter", input, output);
yHat.col(i)=output[0];
}
double err=(y-yHat).array().abs().sum()/(double)y.rows()/(double)y.cols();
double rms=x.array().abs().sum()/(double)x.rows()/(double)x.cols();
cout<<"rms="<<rms<<endl;
cout<<"err="<<err<<endl;
cout<<"err/rms="<<err/rms<<endl;
cout<<"error = "<<20.*log10(err/rms)<<" dB"<<endl;
return 0;
}