float TaudioFilterHeadphone2::conv(const int nx, const int nk, const float *sx, const float *sk,const int offset) { /* k = reminder of offset / nx */ int k = offset >= 0 ? offset % nx : nx + (offset % nx); if(nk + k <= nx) { return af_filter_fir(nk, sx + k, sk); } else { return af_filter_fir(nk + k - nx, sx, sk + nx - k) + af_filter_fir(nx - k, sx + k, sk); } }
/* Convolution on a ring buffer * nx: length of the ring buffer * nk: length of the convolution kernel * sx: ring buffer * sk: convolution kernel * offset: offset on the ring buffer, can be */ static float conv(const int nx, const int nk, const float *sx, const float *sk, const int offset) { /* k = reminder of offset / nx */ int k = offset >= 0 ? offset % nx : nx + (offset % nx); if(nk + k <= nx) return af_filter_fir(nk, sx + k, sk); else return af_filter_fir(nk + k - nx, sx, sk + nx - k) + af_filter_fir(nx - k, sx + k, sk); }
/* C implementation of parallel FIR filter y(k)=w(k) * x(k) (where * denotes convolution) n number of filter taps, where mod(n,4)==0 d number of filters xi current index in xq w filter taps k by n big x input signal must be a circular buffers which are indexed backwards y output buffer s output buffer stride */ inline _ftype_t* af_filter_pfir(unsigned int n, unsigned int d, unsigned int xi, _ftype_t** w, _ftype_t** x, _ftype_t* y, unsigned int s) { register _ftype_t* xt = *x + xi; register _ftype_t* wt = *w; register int nt = 2*n; while(d-- > 0){ *y = af_filter_fir(n,wt,xt); wt+=n; xt+=nt; y+=s; } return y; }
/* C implementation of parallel FIR filter y(k)=w(k) * x(k) (where * denotes convolution) n number of filter taps, where mod(n,4)==0 d number of filters xi current index in xq w filter taps k by n big x input signal must be a circular buffers which are indexed backwards y output buffer s output buffer stride */ FLOAT_TYPE* af_filter_pfir(unsigned int n, unsigned int d, unsigned int xi, const FLOAT_TYPE** w, const FLOAT_TYPE** x, FLOAT_TYPE* y, unsigned int s) { register const FLOAT_TYPE* xt = *x + xi; register const FLOAT_TYPE* wt = *w; register int nt = 2*n; while(d-- > 0) { *y = af_filter_fir(n,wt,xt); wt+=n; xt+=nt; y+=s; } return y; }