EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
SignalDFTPanel.hpp
Go to the documentation of this file.
1
9
10#ifndef ECHOMAP_SIGNALDFTPANEL_HPP
11#define ECHOMAP_SIGNALDFTPANEL_HPP
12
13#include <sigc++/scoped_connection.h>
14
15#include <string>
16
19#include "IProjectPanel.hpp"
20
21namespace echomap
22{
23
24class Signal;
27class DFTResult;
28class EchoMap;
29class Worker;
30
34class SignalDFTPanel final : public IProjectPanel
35{
36public:
47 explicit SignalDFTPanel(
48 Worker* parent_worker,
49 WorkerResultDespatcher& despatcher,
50 EchoMap* app,
51 const Project* initial_project = nullptr
52 );
53
54 ~SignalDFTPanel() noexcept override;
55
56 SignalDFTPanel(const SignalDFTPanel&) = delete;
57 SignalDFTPanel& operator=(const SignalDFTPanel&) = delete;
58
60 SignalDFTPanel& operator=(SignalDFTPanel&&) noexcept = delete;
61
62 void draw() noexcept override;
63
64 [[nodiscard]] const char* get_imgui_name() const noexcept override;
65
66 void change_active_project(const Project* new_project) override;
67
68 static const char* get_imgui_stable_name() noexcept;
69
70private:
72 {
73 const FrequencySpectrum* spectrum;
74 int index_offset;
75 };
76
77 static ImPlotPoint get_indexed_frequency_bin(
78 int index,
79 void* user_data
80 ) noexcept;
81
82 void handle_completed_dft(DFTResult&& result);
83
84 void draw_configuration_section() noexcept;
85 void draw_configuration_window_function() noexcept;
86 void draw_configuration_transform_size() noexcept;
87 void draw_configuration_scale_type() noexcept;
88 void draw_configuration_preview_actions() noexcept;
89
90 void draw_preview_section() noexcept;
91 void draw_preview_of_signal(std::shared_ptr<Signal> signal) noexcept;
92
93 void reset_available_transform_sizes();
94 void update_spectrum_bounds(const FrequencySpectrum& spectrum) noexcept;
95 void update_spectrum_bounds() noexcept;
96 void update_available_sizes(std::uint64_t maximum_sample_count);
97 void reset_viewport_bounds() noexcept;
98
99 const FrequencySpectrum* get_spectra(
100 std::shared_ptr<Signal> signal,
101 WindowFunctions::AllFunctions window_function,
102 std::size_t transform_size
103 );
104
114
115 ImPlotRect viewport_bounds;
116
117 std::string panel_name;
118 ImPlotSpec plotting_spec_2d;
119 Worker* parent_worker;
120 const Project* active_project = nullptr;
121 EchoMap* app;
122
126 struct CacheKey
127 {
128 id_type source_id;
129 WindowFunctions::AllFunctions window_function;
130 std::size_t transform_size;
131
132 bool operator==(const CacheKey& key) const;
133 };
134
139 {
140 enum class State : std::uint8_t
141 {
142 NotRequested,
143 Success,
144 Pending,
145 Failed,
146 } status{State::NotRequested};
147
149 };
150
155 {
156 [[nodiscard]] std::size_t operator()(const CacheKey& key) const noexcept;
157
158 private:
159 static std::size_t combine(
160 std::size_t seed,
161 std::size_t value
162 ) noexcept;
163 };
164
166 bool use_log_scale = false;
167 static constexpr unsigned int default_size_log = 7;
170
171
172 WindowFunctions::AllFunctions selected_window = WindowFunctions::Constant{};
173
175};
176
177} // namespace echomap
178
179#endif // ECHOMAP_SIGNALDFTPANEL_HPP
IDAllocator specification.
IProjectPanel specification.
WindowFunctions specification.
Denotes a completed DFT computation from a DFTTask.
Definition DFTResult.hpp:27
The EchoMap maintains state for the application including WebGPU and Dear ImGui context,...
Definition EchoMap.hpp:35
A Signal sampled in the frequency domain.
An IPanel which can receive updates to the application-wide active Project.
void change_active_project(const Project *new_project) override
Updates the active Project being described by the IPanel.
unsigned int selected_size_log
Base-2 log of selected transform size.
SignalDFTPanel(Worker *parent_worker, WorkerResultDespatcher &despatcher, EchoMap *app, const Project *initial_project=nullptr)
Create a new SignalDFTPanel to display DFTs of Signal waveforms in the frequency domain.
ImPlotRect spectrum_bounds
The minimal bounding box required to fully contain the DFT spectrum plot.
std::unordered_map< CacheKey, CacheValue, CacheKeyHash > spectra_cache
Cached DFT spectra.
ImPlotRect viewport_bounds
The user-controlled bounding box of the DFT plots.
std::vector< std::string > available_sizes
Strings of all available transform sizes.
void draw() noexcept override
Draw the panel to the active rendering context.
static constexpr unsigned int default_size_log
Base-2 log of the minimum transform size.
bool use_log_scale
Should the DFT be plotted with a linear or base-10 logarithmic freq.
const char * get_imgui_name() const noexcept override
Retrieves the name of the IPanel for Dear ImGui API functions.
A single channel of discretely sampled audio data.
Definition Signal.hpp:40
Aggregation of callable DSP window functions.
Manages channels for WorkerResult message routing.
A Worker provides an encapsulated thread-safe despatch model for submitting work and reviewing result...
Definition Worker.hpp:45
T lowest(T... args)
T max(T... args)
The main EchoMap outermost namespace for all non-exported symbols.
STL namespace.
The hash functor for CacheKey.
A three-way key into the FrequencySpectrum cache.
A keyed value within the FrequencySpectrum cache, either denoting a pending, failed,...
The Constant invocable window function.