EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
FrequencySpectrum.hpp
Go to the documentation of this file.
1
9
10#ifndef ECHOMAP_FREQUENCYSPECTRUM_HPP
11#define ECHOMAP_FREQUENCYSPECTRUM_HPP
12
13#include <vector>
14
15#include "Object.hpp"
17
18namespace echomap
19{
20
22
26class FrequencySpectrum : public Object<FrequencySpectrum>
27{
28public:
33 struct Bin
34 {
35 float frequency;
36 float magnitude;
37 float phase;
38 };
39
40private:
42
43public:
44 [[nodiscard]] decltype(bins)::const_iterator begin() const;
45 [[nodiscard]] decltype(bins)::const_iterator end() const;
46 [[nodiscard]] decltype(bins)::const_iterator cbegin() const noexcept;
47 [[nodiscard]] decltype(bins)::const_iterator cend() const noexcept;
48
49 [[nodiscard]] std::size_t get_bin_count() const noexcept;
50
51 [[nodiscard]] float get_minimum_frequency() const noexcept;
52 [[nodiscard]] float get_maximum_frequency() const noexcept;
53 [[nodiscard]] float get_minimum_magnitude() const noexcept;
54 [[nodiscard]] float get_maximum_magnitude() const noexcept;
55
56 const WindowFunctions::AllFunctions& observe_preprocessor() const noexcept;
57
58private:
59 friend FrequencySpectrumFactory;
60
61 explicit FrequencySpectrum(
62 WindowFunctions::AllFunctions preprocessor,
63 std::string_view name
64 );
65
66 void reserve_bins(std::size_t bin_count);
67
68 void emplace_bin(
69 float frequency,
70 float magnitude,
71 float phase
72 );
73
74 WindowFunctions::AllFunctions preprocessor;
75
76 float minimum_frequency = std::numeric_limits<float>::max();
77 float maximum_frequency = std::numeric_limits<float>::min();
78 float minimum_magnitude = std::numeric_limits<float>::max();
79 float maximum_magnitude = std::numeric_limits<float>::min();
80};
81
82template <> constexpr std::string_view Object<FrequencySpectrum>::class_name = "FreqSpec";
83
84} // namespace echomap
85
86#endif // ECHOMAP_FREQUENCYSPECTRUM_HPP
Object specification.
WindowFunctions specification.
Provides a static helper to perform discrete Fourier transforms on Signal objects to produce frequenc...
static constexpr std::string_view class_name
Definition Object.hpp:235
Aggregation of callable DSP window functions.
The main EchoMap outermost namespace for all non-exported symbols.
STL namespace.
A bin within the spectrum, denoting the magnitude (and optionally, complex phase) of a Signal at a gi...
float magnitude
The magnitude of the frequency, in dBfs (decibels relative to full scale).
float phase
The complex phase of the DFT value, in radians.
float frequency
The frequency quantised by the Bin, in Hz.