42 #define _USE_MATH_DEFINES
53 #include <unsupported/Eigen/FFT>
59 using namespace RTPROCESSINGLIB;
60 using namespace Eigen;
81 #ifdef EIGEN_FFTW_DEFAULT
82 fftw_make_planner_thread_safe();
85 m_iFilterOrder = fftLength;
87 int highpasss,lowpasss;
88 int highpass_widths,lowpass_widths;
90 int resp_size = fftLength/2+1;
92 double pi4 = M_PI/4.0;
95 RowVectorXcd filterFreqResp = RowVectorXcd::Ones(resp_size);
98 highpasss = ((resp_size-1)*highpass)/(0.5*sFreq);
99 lowpasss = ((resp_size-1)*lowpass)/(0.5*sFreq);
101 lowpass_widths = ((resp_size-1)*lowpass_width)/(0.5*sFreq);
102 lowpass_widths = (lowpass_widths+1)/2;
104 if (highpass_width > 0.0) {
105 highpass_widths = ((resp_size-1)*highpass_width)/(0.5*sFreq);
106 highpass_widths = (highpass_widths+1)/2;
114 if (highpasss > highpass_widths + 1) {
119 for (
k = 0;
k < resp_size;
k++)
120 filterFreqResp(
k) = 0.0;
122 for (
k = -w+1, s = highpasss-w+1;
k < w;
k++, s++) {
123 if (s >= 0 && s < resp_size) {
124 c = cos(pi4*(
k*mult+add));
125 filterFreqResp(s) = filterFreqResp(s).real()*c*c;
133 if (lowpass_widths > 0) {
138 for (
k = -w+1, s = lowpasss-w+1;
k < w;
k++, s++) {
139 if (s >= 0 && s < resp_size) {
140 c = cos(pi4*(
k*mult+add));
141 filterFreqResp(s) = filterFreqResp(s).real()*c*c;
145 for (
k = s;
k < resp_size;
k++)
146 filterFreqResp(
k) = 0.0;
149 for (
k = lowpasss;
k < resp_size;
k++)
150 filterFreqResp(
k) = 0.0;
157 Eigen::FFT<double> fft;
158 fft.SetFlag(fft.HalfSpectrum);