kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.65k stars 253 forks source link

fir filter with complex signal #109

Closed mipac closed 3 years ago

mipac commented 3 years ago

Hi,

Is it possible to use a kfr::filter_fir with complex signal?

for example:

float beta = 0.3f;
kfr::univector< complex<float> > taps_v(taps);
kfr::expression_pointer<complex<float>> kaiser = kfr::to_pointer(kfr::window_kaiser<complex<float>>(taps, beta));
kfr::fir_lowpass(taps_v, cutoff, kaiser, true);  // ERROR

m_filter = make_shared<kfr::filter_fir< complex<float> > >(taps_v);

kfr::univector<complex<float>> out;
kfr::univector<complex<float>> in = ...;
m_filter->apply(out, in);

generate the error :

include/kfr/dsp/fir_design.hpp:41:25: error: no match for ‘operator*’ (operand types are ‘double’ and ‘std::complex<float>’)
     const T scale = 2.0 * cutoff;
                     ~~~~^~~~~~~~

what is the good syntax ? forgot to mention that I use std::complex in all my code

regards

mipac commented 3 years ago

ok sorry for noise, this kind of filter design need real univector for taps

next you build complex taps vector with univector ctaps(taps_v) and then you can build a filter_fir with ctaps to deal with complex signal

hope that help someone ;)