|
HART
0.2.0
High level Audio Regression and Testing
|
Frequency-domain representation of a multi-channel audio signal. More...
#include <hart_spectrum.hpp>
Public Member Functions | |
| template<typename SampleType > | |
| Spectrum (const AudioBuffer< SampleType > &buffer) | |
| Constructs spectrum from an audio buffer. | |
| size_t | getNumChannels () const |
| Returns number of channels. | |
| size_t | getNumBins () const |
| Returns number of frequency bins per channel. | |
| size_t | getFFTSize () const |
| Returns FFT size. | |
| double | getSampleRateHz () const |
| Returns sample rate in Hz. | |
| double | getBinFrequencyHz (size_t binIndex) const |
| Returns frequency corresponding to a bin index. | |
| double | getBinWidthHz () const |
| std::complex< double > | getBinValue (size_t channel, size_t binIndex) const |
| Returns complex value of a frequency bin, by bin index. | |
| std::complex< double > | getBinValue (size_t channel, double frequencyHz) const |
| Returns complex value of a frequency bin, by frequency. | |
| double | getBinMagnitude (size_t channel, size_t binIndex) const |
| Returns magnitude of a frequency bin, by bin index. | |
| double | getBinMagnitude (size_t channel, double frequencyHz) const |
| Returns magnitude of a frequency bin, by frequency. | |
| const std::complex< double > * | operator[] (size_t channel) const |
| Returns pointer to read-only magnitudes of a specific channel. | |
| std::complex< double > * | operator[] (size_t channel) |
| Returns pointer to mutable magnitudes of a specific channel. | |
| size_t | findClosestBin (double frequencyHz) const |
| Finds closest FFT bin to a given frequency. | |
| std::pair< size_t, size_t > | getBinIndices (const Slice &slice) const |
| Returns a pair of indices representing a provided slice. | |
Static Public Member Functions | |
| static Spectrum | zeros (size_t numChannels, size_t signalDurationFrames, double sampleRateHz) |
Frequency-domain representation of a multi-channel audio signal.
Stores complex spectra for each channel independently. Spectrum is constructed by performing FFT on the entire signal, zero-padding to the next power-of-two size if necessary.
Current implementation assumptions:
fftSize / 2 + 1 bins)Definition at line 29 of file hart_spectrum.hpp.
|
inline |
Constructs spectrum from an audio buffer.
| buffer | Audio buffer to perform FFT on |
| hart::SampleRateError | if the audio buffer has no sample rate metadata |
Definition at line 36 of file hart_spectrum.hpp.
|
inlinestatic |
Definition at line 69 of file hart_spectrum.hpp.
|
inline |
Returns number of channels.
Definition at line 100 of file hart_spectrum.hpp.
|
inline |
Returns number of frequency bins per channel.
Definition at line 106 of file hart_spectrum.hpp.
|
inline |
Returns FFT size.
Definition at line 112 of file hart_spectrum.hpp.
|
inline |
Returns sample rate in Hz.
Definition at line 118 of file hart_spectrum.hpp.
|
inline |
Returns frequency corresponding to a bin index.
Definition at line 124 of file hart_spectrum.hpp.
|
inline |
Definition at line 132 of file hart_spectrum.hpp.
|
inline |
Returns complex value of a frequency bin, by bin index.
Definition at line 138 of file hart_spectrum.hpp.
|
inline |
Returns complex value of a frequency bin, by frequency.
Definition at line 150 of file hart_spectrum.hpp.
|
inline |
Returns magnitude of a frequency bin, by bin index.
Definition at line 156 of file hart_spectrum.hpp.
|
inline |
Returns magnitude of a frequency bin, by frequency.
Definition at line 162 of file hart_spectrum.hpp.
|
inline |
Returns pointer to read-only magnitudes of a specific channel.
Definition at line 168 of file hart_spectrum.hpp.
|
inline |
Returns pointer to mutable magnitudes of a specific channel.
Definition at line 177 of file hart_spectrum.hpp.
|
inline |
Finds closest FFT bin to a given frequency.
Definition at line 186 of file hart_spectrum.hpp.
|
inline |
Returns a pair of indices representing a provided slice.
| slice | A Slice instance. Valid slice types are Slice::Type::whole Slice::Type::bins and Slice::Type::freq |
| first | Index representing the beginning of the range, inclusive |
| second | Index representing the end of the range, non-inclusive |
Definition at line 200 of file hart_spectrum.hpp.