|
EchoMap 2026-07-25 6d3977c
An experimental cross-platform digital signal processing application for sound-source localisation.
|
A single channel of discretely sampled audio data. More...
#include <Signal.hpp>
Classes | |
| struct | Sample |
| A PCM float-32 sampled audio point at an explicit time offset. More... | |
| struct | Source |
| Indicates an external source of a Signal on the filesystem. More... | |
| struct | Baseline |
| Provides basic timing information relating to the Signal samples. More... | |
Public Member Functions | |
| std::uint64_t | get_sample_count () const noexcept |
| Retrieves the total number of samples in the Signal stream. | |
| const std::optional< Source > & | observe_source () const noexcept |
| Retrieves the optional Source of the Signal. | |
| Sample::TimeT | get_time_offset () const noexcept |
| std::size_t | get_sample_rate () const noexcept |
| decltype(samples) ::const_iterator | begin () const |
| decltype(samples) ::const_iterator | end () const |
| decltype(samples) ::const_iterator | cbegin () const noexcept |
| decltype(samples) ::const_iterator | cend () const noexcept |
| auto | timed_samples () const |
| Sample::AmplitudeT | operator[] (std::size_t index) const noexcept |
| std::span< const Sample::AmplitudeT > | amplitudes () const noexcept |
| bool | is_uniformly_sampled () const noexcept |
| Sample::TimeT | get_time_at_index (std::size_t index) const noexcept |
| Determines the corresponding time of the amplitude appearing at the given index in the sample array. | |
| Signal (const Signal &old_signal) | |
| Signal (const Signal &old_signal, std::string_view new_name) | |
| Public Member Functions inherited from echomap::Object< Signal > | |
| ~Object ()=default | |
| Non-virtual base destructor. | |
| id_type | get_id () const noexcept |
| bool | is_valid () const noexcept |
| void | set_name (const std::string_view new_name) |
| std::string_view | get_name () const noexcept |
| const char * | get_imgui_name () const noexcept |
| Object (const Object &)=delete | |
| Object & | operator= (const Object &)=delete |
| bool | operator== (const Object &other) const noexcept |
| Determine shallow equality between two Object instances. | |
Static Public Attributes | |
| static constexpr std::pair< Sample::AmplitudeT, Sample::AmplitudeT > | normalised_range = {-1.0f, 1.0f} |
| The range within which the amplitude values are normalised. | |
Private Member Functions | |
| Signal (std::string_view name={}, const std::optional< Source > &source={}) | |
| Creates an empty optionally named Signal. | |
| void | emplace_sample (Sample::AmplitudeT amplitude) |
| Emplace a sample to the back of the channel sample data. | |
| void | emplace_sample (Sample::TimeT time, Sample::AmplitudeT amplitude) |
| Emplace a sample to the back of the channel sample data. | |
| void | emplace_sample (const Sample &sample) |
| Emplace a sample to the back of the channel sample data. | |
| void | emplace_sample_from_source (Sample::AmplitudeT amplitude) |
| Emplace an externally sourced sample to the back of the channel sample data. | |
| void | emplace_sample_from_source (Sample::TimeT time, Sample::AmplitudeT amplitude) |
| Emplace an externally sourced sample to the back of the channel sample data. | |
| void | emplace_sample_from_source (const Sample &sample) |
| Emplace an externally sourced sample to the back of the channel sample data. | |
| void | reserve_samples (std::size_t count) |
| Reserves memory to store the given number of total samples in the channel. | |
| void | set_source (const std::filesystem::path &path, std::size_t channel) |
| void | set_time_offset (Sample::TimeT new_time_offset) noexcept |
| void | set_sample_rate (std::size_t new_sample_rate) noexcept |
| void | emplace_time (Sample::TimeT given_time) |
| Implementation helper to associate the latest amplitude sample with the given time. | |
Private Attributes | |
| std::vector< Sample::AmplitudeT > | samples |
| Amplitude sample stream. | |
| Baseline | timing_baseline |
| A baseline of timing parameters. | |
| std::optional< Source > | fs_source |
| External source, if any, of the Signal Sample stream. | |
| std::optional< std::vector< Sample::TimeT > > | time_offsets |
| An optional vector of explicit timestamps for each sample. | |
Friends | |
| class | SignalFactory |
Additional Inherited Members | |
| Static Public Member Functions inherited from echomap::Object< Signal > | |
| static std::string_view | get_class_name () noexcept |
| Protected Member Functions inherited from echomap::Object< Signal > | |
| void | move_identity_from (Object &&other) noexcept |
| Helper for derived classes to provide move-assignment operations. | |
A single channel of discretely sampled audio data.
Signals always store their sampled time series in memory, but they optionally express an external source. This is currently a file specification on the local file system, and an internal channel number, indicating the origin of the sample data.
Signal objects must be constructed by a SignalFactory. Following release from the factory, all non-metadata state is immutable, particularly the Sample time series. Trivial metadata (such as the display name from Object) may be modified at will.
Definition at line 39 of file Signal.hpp.
| echomap::Signal::Signal | ( | const Signal & | old_signal | ) |
Definition at line 105 of file Signal.cpp.
| echomap::Signal::Signal | ( | const Signal & | old_signal, |
| std::string_view | new_name ) |
Definition at line 117 of file Signal.cpp.
|
explicitprivate |
Creates an empty optionally named Signal.
| name | Optional display name. |
| source | Optional file system source path indicating the origin of the file. |
Definition at line 19 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 85 of file Signal.cpp.
|
nodiscard |
Definition at line 58 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 68 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 73 of file Signal.cpp.
|
private |
Emplace a sample to the back of the channel sample data.
| sample | The Sample to insert at the back of the stream. |
| std::runtime_error | The time of the Sample violated the monotonically increasing invariant. |
Definition at line 157 of file Signal.cpp.
|
private |
Emplace a sample to the back of the channel sample data.
The inserted amplitude sample will be associated with the next timestep, computed automatically based on the defined sample rate and time offset.
| amplitude | Amplitude of the sample to insert. |
Definition at line 131 of file Signal.cpp.
|
private |
Emplace a sample to the back of the channel sample data.
| time | The time to associate with the amplitude, in seconds. |
| amplitude | The amplitude to associate with the time. |
| std::runtime_error | The time of the Sample violated the monotonically increasing invariant. |
Definition at line 144 of file Signal.cpp.
|
private |
Emplace an externally sourced sample to the back of the channel sample data.
| sample | The Sample to insert at the back of the stream. |
| std::runtime_error | The time of the Sample violated the monotonically increasing invariant. |
Definition at line 184 of file Signal.cpp.
|
private |
Emplace an externally sourced sample to the back of the channel sample data.
The inserted amplitude sample will be associated with the next timestep, computed automatically based on the defined sample rate and time offset.
| amplitude | Amplitude of the sample to insert. |
Definition at line 164 of file Signal.cpp.
|
private |
Emplace an externally sourced sample to the back of the channel sample data.
| time | The time to associate with the amplitude, in seconds. |
| amplitude | The amplitude to associate with the time. |
| std::runtime_error | The time of the Sample violated the monotonically increasing invariant. |
Definition at line 174 of file Signal.cpp.
|
private |
Implementation helper to associate the latest amplitude sample with the given time.
| given_time | The time to associate with the latest sample. |
| std::runtime_error | The time of the Sample violated the monotonically increasing invariant. |
Definition at line 224 of file Signal.cpp.
|
nodiscard |
Definition at line 63 of file Signal.cpp.
|
nodiscardnoexcept |
Retrieves the total number of samples in the Signal stream.
Definition at line 38 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 53 of file Signal.cpp.
|
nodiscardnoexcept |
Determines the corresponding time of the amplitude appearing at the given index in the sample array.
| index | The index of the amplitude in the sample array. |
Definition at line 95 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 48 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 90 of file Signal.cpp.
|
nodiscardnoexcept |
Retrieves the optional Source of the Signal.
The return value of this operation can be used to determine the origin of the Signal: if the optional is empty, the signal should be considered "embedded". Otherwise, it has an origin on the filesystem at the given SignalSource.
If the Signal has an external source, the stored samples in the Signal object do not necessarily match the external file, as callers may have invoked emplace_sample with arbitrary samples. The Source should only be considered a hint. This can be checked by inspecting the Source::dirty flag.
Definition at line 43 of file Signal.cpp.
|
nodiscardnoexcept |
Definition at line 78 of file Signal.cpp.
|
private |
Reserves memory to store the given number of total samples in the channel.
| count | The number of Sample objects to pre-allocate. |
Definition at line 191 of file Signal.cpp.
|
privatenoexcept |
Definition at line 216 of file Signal.cpp.
|
private |
Definition at line 201 of file Signal.cpp.
|
privatenoexcept |
Definition at line 209 of file Signal.cpp.
|
inlinenodiscard |
Definition at line 109 of file Signal.hpp.
|
friend |
Definition at line 147 of file Signal.hpp.
|
private |
External source, if any, of the Signal Sample stream.
Definition at line 257 of file Signal.hpp.
|
staticconstexpr |
The range within which the amplitude values are normalised.
Definition at line 74 of file Signal.hpp.
|
private |
Amplitude sample stream.
Definition at line 55 of file Signal.hpp.
|
private |
An optional vector of explicit timestamps for each sample.
If provided, the timestamps provide a sample-by-sample indication of the time corresponding with amplitudes in the sample time series data. The scalars are specified as offsets relative to the baseline time, which is computed as \( b_i = t_0 + i \delta t \), where \( t_0 \) is the global time offset, \( \delta t \) is the reciprocal of the sample rate, and \( i \) is the integer zero-based index such that \( 0 < i \leq \vert S \vert \), where \( \vert S \vert \) denotes the size of the sample set \( S \).
This is useful to support variably sampled time series, such as in the result of LTTB downsampling. Whether explicit timestamps are provided is rather opaque to the user: they can request timing information, which may be inferred from the baseline or indexed from this array as appropriate.
When a new sample is emplaced, a time can be provided. If the given time is different than what would be expected from the baseline, this vector is updated with the suitable offset. If it doesn't exist, it is created.
Definition at line 281 of file Signal.hpp.
|
private |
A baseline of timing parameters.
Definition at line 256 of file Signal.hpp.