1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:47:35 +00:00

LibDSP: Generalize & improve FFT

Several related improvements to our Fast Fourier Transform
implementation:
- FFT now operates on spans, allowing it to use many more container
  types other than Vector. It's intended anyways that FFT transmutes the
  input data.
- FFT is now constexpr, moving the implementation to the header and
  removing the cpp file. This means that if we have static collections
  of samples, we can transform them at compile time.
- sample_data.data() weirdness is now gone.
This commit is contained in:
kleines Filmröllchen 2022-03-03 21:16:30 +01:00 committed by Andreas Kling
parent 428d4ae337
commit 00dd8f8fbe
4 changed files with 36 additions and 66 deletions

View file

@ -26,7 +26,7 @@ void BarsVisualizationWidget::paint_event(GUI::PaintEvent& event)
if (m_sample_buffer.is_empty())
return;
LibDSP::fft(m_sample_buffer, false);
LibDSP::fft(m_sample_buffer.span(), false);
double max = AK::sqrt(m_sample_count * 2.);
double freq_bin = m_samplerate / (double)m_sample_count;