EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Loading...
Searching...
No Matches
SignalFactory.hpp
Go to the documentation of this file.
1
7
8#ifndef ECHOMAP_SIGNALFACTORY_H
9#define ECHOMAP_SIGNALFACTORY_H
10
11#include <dr_wav.h>
12
13#include <memory>
14#include <span>
15#include <vector>
16
17#include "../Signal.hpp"
18
19namespace echomap
20{
21
22class Signal;
23
30{
31public:
36
37 [[nodiscard]] bool operator==(const SignalFactory& other) const;
38 [[nodiscard]] bool operator<(const SignalFactory& other) const;
39
50 [[nodiscard]] static std::vector<std::unique_ptr<Signal>> load_wave_file(const char* file_path);
51
71 static void load_wave_file(
72 const char* file_path,
73 // ReSharper disable once CppConstParameterInDeclaration - Superfluous const required for Doxygen matching.
74 const std::span<SignalFactory* const> channel_factories // NOLINT(*-avoid-const-params-in-decls)
75 );
76
85 [[nodiscard]] static std::unique_ptr<Signal> downsample(
86 const Signal& source,
87 float downsample_factor,
88 std::string_view name = {}
89 );
90
91 [[nodiscard]] std::unique_ptr<Signal> take_signal() noexcept;
92 [[nodiscard]] const Signal& observe_signal() const noexcept;
93
94 void emplace_sample(Signal::Sample::AmplitudeT amplitude) const;
95 void emplace_sample(const Signal::Sample& sample) const;
96 void emplace_sample(
99 ) const;
100
101 void emplace_sample_from_source(Signal::Sample::AmplitudeT amplitude) const;
102 void emplace_sample_from_source(const Signal::Sample& sample) const;
103 void emplace_sample_from_source(
106 ) const;
107
108 void set_signal_name(std::string_view name) const;
109 void set_time_offset(Signal::Sample::TimeT time_offset) const noexcept;
110 void set_sample_rate(std::size_t sample_rate) const noexcept;
111 void set_source(
112 const std::filesystem::path& path,
113 std::size_t channel
114 ) const;
115
116private:
129 drwav& drwav_info,
130 std::string_view file_path,
131 std::span<Signal* const> signal_ptrs
132 );
133
154 [[nodiscard]] static std::unique_ptr<Signal> lttb_downsample(
155 const Signal& source,
156 size_t threshold,
158 );
159
166};
167
168} // namespace echomap
169
170#endif // ECHOMAP_SIGNALFACTORY_H
Audio signal class specification.
static void load_wave_file_into_channels(drwav &drwav_info, std::string_view file_path, std::span< Signal *const > signal_ptrs)
Loads the time-series sampled data into the given Signal objects.
std::unique_ptr< Signal > target
The Signal being built by the factory.
static std::unique_ptr< Signal > lttb_downsample(const Signal &source, size_t threshold, std::string_view name)
Create a new Signal by downsampling the data points of an existing Signal to the given threshold.
static std::unique_ptr< Signal > downsample(const Signal &source, float downsample_factor, std::string_view name={})
Downsamples an existing Signal instance across all channels to the given number of samples.
SignalFactory()
Begin constructing a new Signal.
static std::vector< std::unique_ptr< Signal > > load_wave_file(const char *file_path)
Loads a WAV file from the file system.
A single channel of discretely sampled audio data.
Definition Signal.hpp:40
The main EchoMap outermost namespace for all non-exported symbols.
A PCM float-32 sampled audio point at an explicit time offset.
Definition Signal.hpp:46
float AmplitudeT
Type for sample amplitudes.
Definition Signal.hpp:48
float TimeT
Type for sample times.
Definition Signal.hpp:47