EchoMap
2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
Toggle main menu visibility
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
19
namespace
echomap
20
{
21
22
class
Signal
;
23
29
class
SignalFactory
30
{
31
public
:
35
SignalFactory
();
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(
97
Signal::Sample::TimeT
time,
98
Signal::Sample::AmplitudeT
amplitude
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(
104
Signal::Sample::TimeT
time,
105
Signal::Sample::AmplitudeT
amplitude
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
116
private
:
128
static
void
load_wave_file_into_channels
(
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,
157
std::string_view
name
158
);
159
165
std::unique_ptr<Signal>
target
;
166
};
167
168
}
// namespace echomap
169
170
#endif
// ECHOMAP_SIGNALFACTORY_H
Signal.hpp
Audio signal class specification.
std::string_view
echomap::SignalFactory::load_wave_file_into_channels
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.
Definition
SignalFactory.cpp:253
echomap::SignalFactory::target
std::unique_ptr< Signal > target
The Signal being built by the factory.
Definition
SignalFactory.hpp:165
echomap::SignalFactory::lttb_downsample
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.
Definition
SignalFactory.cpp:313
echomap::SignalFactory::downsample
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.
Definition
SignalFactory.cpp:140
echomap::SignalFactory::SignalFactory
SignalFactory()
Begin constructing a new Signal.
Definition
SignalFactory.cpp:25
echomap::SignalFactory::load_wave_file
static std::vector< std::unique_ptr< Signal > > load_wave_file(const char *file_path)
Loads a WAV file from the file system.
Definition
SignalFactory.cpp:63
echomap::Signal
A single channel of discretely sampled audio data.
Definition
Signal.hpp:40
memory
echomap
The main EchoMap outermost namespace for all non-exported symbols.
Definition
ActionController.hpp:20
std::filesystem::path
std::size_t
span
echomap::Signal::Sample
A PCM float-32 sampled audio point at an explicit time offset.
Definition
Signal.hpp:46
echomap::Signal::Sample::AmplitudeT
float AmplitudeT
Type for sample amplitudes.
Definition
Signal.hpp:48
echomap::Signal::Sample::TimeT
float TimeT
Type for sample times.
Definition
Signal.hpp:47
std::unique_ptr
vector
src
objects
factories
SignalFactory.hpp
Generated by
1.17.0