FastLED 3.9.15
Loading...
Searching...
No Matches

◆ fft_unit_test()

void fl::FFTContext::fft_unit_test ( span< const i16 > buffer,
FFTBins * out )
inline

Definition at line 70 of file fft_impl.cpp.

70 {
71
72 // FASTLED_ASSERT(512 == m_cq_cfg.samples, "FFTImpl samples mismatch and
73 // are still hardcoded to 512");
74 out->clear();
75 // allocate
76 FASTLED_STACK_ARRAY(kiss_fft_cpx, fft, m_cq_cfg.samples);
77 FASTLED_STACK_ARRAY(kiss_fft_cpx, cq, m_cq_cfg.bands);
78 // initialize
79 kiss_fftr(m_fftr_cfg, buffer.data(), fft);
81 const float maxf = m_cq_cfg.fmax;
82 const float minf = m_cq_cfg.fmin;
83 const float delta_f = (maxf - minf) / m_cq_cfg.bands;
84 // begin transform
85 for (int i = 0; i < m_cq_cfg.bands; ++i) {
86 i32 real = cq[i].r;
87 i32 imag = cq[i].i;
88 float r2 = float(real * real);
89 float i2 = float(imag * imag);
90 float magnitude = sqrt(r2 + i2);
91 float magnitude_db = 20 * log10(magnitude);
92 float f_start = minf + i * delta_f;
93 float f_end = f_start + delta_f;
94 FASTLED_UNUSED(f_start);
95 FASTLED_UNUSED(f_end);
96
97 if (magnitude <= 0.0f) {
98 magnitude_db = 0.0f;
99 }
100
101 // FASTLED_UNUSED(magnitude_db);
102 // FASTLED_WARN("magnitude_db: " << magnitude_db);
103 // out->push_back(magnitude_db);
104 out->bins_raw.push_back(magnitude);
105 out->bins_db.push_back(magnitude_db);
106 }
107 }
AudioAnalyzeFFT1024 fft
#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE)
Definition array.h:185
cq_kernels_t m_kernels
Definition fft_impl.cpp:126
kiss_fftr_cfg m_fftr_cfg
Definition fft_impl.cpp:125
cq_kernel_cfg m_cq_cfg
Definition fft_impl.cpp:127
void apply_kernels(kiss_fft_cpx fft[], kiss_fft_cpx cq[], struct sparse_arr kernels[], struct cq_kernel_cfg cfg)
void kiss_fftr(kiss_fftr_cfg st, const kiss_fft_scalar *timedata, kiss_fft_cpx *freqdata)
Definition kiss_fftr.cpp:67
#define FASTLED_UNUSED(x)
Definition unused.h:4

References apply_kernels(), fl::FFTBins::bins_db, fl::FFTBins::bins_raw, fl::FFTBins::clear(), fl::Slice< T >::data(), FASTLED_STACK_ARRAY, FASTLED_UNUSED, fft, kiss_fftr(), m_cq_cfg, m_fftr_cfg, and m_kernels.

+ Here is the call graph for this function: