mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-01-24 00:34:44 +01:00
beginning of notch filter implementation
This commit is contained in:
parent
c1942ac51d
commit
f8ff67c5b0
@ -2,6 +2,7 @@
|
|||||||
#include <dsp/block.h>
|
#include <dsp/block.h>
|
||||||
#include <dsp/types.h>
|
#include <dsp/types.h>
|
||||||
#include <dsp/utils/window_functions.h>
|
#include <dsp/utils/window_functions.h>
|
||||||
|
#include <fftw3.h>
|
||||||
|
|
||||||
namespace dsp {
|
namespace dsp {
|
||||||
namespace filter_window {
|
namespace filter_window {
|
||||||
@ -269,4 +270,70 @@ namespace dsp {
|
|||||||
float _sampleRate, _baudRate, _alpha;
|
float _sampleRate, _baudRate, _alpha;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class NotchWindow : public filter_window::generic_window {
|
||||||
|
public:
|
||||||
|
NotchWindow() {}
|
||||||
|
|
||||||
|
NotchWindow(float frequency, float width, float sampleRate, int tapCount) { init(frequency, width, sampleRate, tapCount); }
|
||||||
|
|
||||||
|
~NotchWindow() {
|
||||||
|
if (fft_in) { fftwf_free(fft_in); }
|
||||||
|
if (fft_out) { fftwf_free(fft_out); }
|
||||||
|
fftwf_destroy_plan(fft_plan);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init(float frequency, float width, float sampleRate, int tapCount) {
|
||||||
|
_frequency = frequency;
|
||||||
|
_width = width;
|
||||||
|
_sampleRate = sampleRate;
|
||||||
|
_tapCount = _tapCount;
|
||||||
|
|
||||||
|
fft_in = (complex_t*)fftwf_malloc(_tapCount * sizeof(complex_t));
|
||||||
|
fft_out = (complex_t*)fftwf_malloc(_tapCount * sizeof(complex_t));
|
||||||
|
|
||||||
|
fft_plan = fftwf_plan_dft_1d(_tapCount, (fftwf_complex*)fft_in, (fftwf_complex*)fft_out, FFTW_BACKWARD, FFTW_ESTIMATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setFrequency(float frequency) {
|
||||||
|
_frequency = frequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setWidth(float width) {
|
||||||
|
_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSampleRate(float sampleRate) {
|
||||||
|
_sampleRate = sampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setTapCount(int count) {
|
||||||
|
_tapCount = count;
|
||||||
|
if (fft_in) { fftwf_free(fft_in); }
|
||||||
|
if (fft_out) { fftwf_free(fft_out); }
|
||||||
|
fftwf_destroy_plan(fft_plan);
|
||||||
|
|
||||||
|
fft_in = (complex_t*)fftwf_malloc(_tapCount * sizeof(complex_t));
|
||||||
|
fft_out = (complex_t*)fftwf_malloc(_tapCount * sizeof(complex_t));
|
||||||
|
|
||||||
|
fft_plan = fftwf_plan_dft_1d(_tapCount, (fftwf_complex*)fft_in, (fftwf_complex*)fft_out, FFTW_BACKWARD, FFTW_ESTIMATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getTapCount() {
|
||||||
|
return _tapCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void createTaps(float* taps, int tapCount, float factor = 1.0f) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
complex_t* fft_in = NULL;
|
||||||
|
complex_t* fft_out = NULL;
|
||||||
|
float _frequency, _width, _sampleRate;
|
||||||
|
int _tapCount;
|
||||||
|
|
||||||
|
fftwf_plan fft_plan;
|
||||||
|
|
||||||
|
};
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user