HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Fourier.h
Go to the documentation of this file.
1#pragma once
2#include "HephShared.h"
3#include "Complex.h"
6
9namespace Heph
10{
15 class HEPH_API Fourier final
16 {
17 private:
18 static constexpr bool DIRECTION_FORWARD = true;
19 static constexpr bool DIRECTION_BACKWARD = false;
20
21 public:
22 Fourier() = delete;
23 Fourier(const Fourier&) = delete;
24 Fourier& operator=(const Fourier&) = delete;
25
26 public:
33 static ComplexBuffer FFT(const DoubleBuffer& doubleBuffer);
34
42 static ComplexBuffer FFT(const DoubleBuffer& doubleBuffer, size_t fftSize);
43
49 static void FFT(ComplexBuffer& complexBuffer);
50
57 static void FFT(ComplexBuffer& complexBuffer, size_t fftSize);
58
65 static void IFFT(DoubleBuffer& doubleBuffer, ComplexBuffer& complexBuffer);
66
73 static void IFFT(ComplexBuffer& complexBuffer, bool scale);
74
80 static double BinFrequencyToIndex(size_t sampleRate, size_t fftSize, double frequency);
81
87 static double IndexToBinFrequency(size_t sampleRate, size_t fftSize, size_t index);
88
93 static size_t CalculateFFTSize(size_t bufferSize);
94
100 static DoubleBuffer Convolve(const DoubleBuffer& source, const DoubleBuffer& kernel);
101
107 static DoubleBuffer Convolve(const DoubleBuffer& source, const DoubleBuffer& kernel, ConvolutionMode convolutionMode);
108
109 private:
110 static void ReverseBits(ComplexBuffer& complexBuffer, size_t fftSize);
111 static void FFT_Internal(ComplexBuffer& complexBuffer, size_t fftSize, bool direction);
112 };
113}
#define HEPH_API
Definition HephShared.h:132
buffer for storing complex numbers.
Definition ComplexBuffer.h:22
buffer for storing doubles.
Definition DoubleBuffer.h:14
class for calculating FFT and Convolution.
Definition Fourier.h:16
static size_t CalculateFFTSize(size_t bufferSize)
static double BinFrequencyToIndex(size_t sampleRate, size_t fftSize, double frequency)
static void IFFT(DoubleBuffer &doubleBuffer, ComplexBuffer &complexBuffer)
static DoubleBuffer Convolve(const DoubleBuffer &source, const DoubleBuffer &kernel, ConvolutionMode convolutionMode)
static ComplexBuffer FFT(const DoubleBuffer &doubleBuffer, size_t fftSize)
static void FFT(ComplexBuffer &complexBuffer)
static ComplexBuffer FFT(const DoubleBuffer &doubleBuffer)
static double IndexToBinFrequency(size_t sampleRate, size_t fftSize, size_t index)
static DoubleBuffer Convolve(const DoubleBuffer &source, const DoubleBuffer &kernel)
static void FFT(ComplexBuffer &complexBuffer, size_t fftSize)
static void IFFT(ComplexBuffer &complexBuffer, bool scale)