2024-05-04 03:27:32 -07:00
|
|
|
#pragma once
|
|
|
|
|
2024-10-20 19:11:57 -07:00
|
|
|
#include "pch.h"
|
2024-05-04 03:27:32 -07:00
|
|
|
#include <cstddef>
|
|
|
|
#include <math.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <complex>
|
2024-10-22 03:33:07 -07:00
|
|
|
#include "biquad.h"
|
2024-05-04 03:27:32 -07:00
|
|
|
|
2024-10-20 19:35:55 -07:00
|
|
|
#if EFI_UNIT_TEST
|
|
|
|
typedef uint16_t adcsample_t;
|
|
|
|
#endif
|
|
|
|
|
2024-05-04 03:27:32 -07:00
|
|
|
namespace fft {
|
|
|
|
|
|
|
|
typedef float real_type;
|
|
|
|
typedef std::complex<real_type> complex_type;
|
|
|
|
|
2024-10-22 03:33:07 -07:00
|
|
|
bool fft_adc_sample(float * w, float ratio, float sensitivity, const adcsample_t* data_in, complex_type* data_out, const size_t size);
|
|
|
|
bool fft_adc_sample_filtered(Biquad& knockFilter, float * w, float ratio, float sensitivity, const adcsample_t* data_in, complex_type* data_out, const size_t size);
|
2024-05-04 03:27:32 -07:00
|
|
|
bool fft(const real_type* data_in, complex_type* data_out, const size_t size);
|
|
|
|
|
|
|
|
void rectwin(float * w, unsigned n);
|
|
|
|
void hann(float * w, unsigned n, bool sflag);
|
|
|
|
void hamming(float * w, unsigned n, bool sflag);
|
|
|
|
void blackman(float * w, unsigned n, bool sflag);
|
|
|
|
void blackmanharris(float * w, unsigned n, bool sflag);
|
|
|
|
|
2024-10-22 03:33:07 -07:00
|
|
|
float fast_sqrt(float x);
|
|
|
|
float amplitude(const complex_type& fft);
|
2024-05-04 03:27:32 -07:00
|
|
|
|
2024-10-20 19:35:55 -07:00
|
|
|
}
|
2024-05-04 03:27:32 -07:00
|
|
|
|