28bool Signal::Source::operator<(
68decltype(
Signal::samples)::const_iterator Signal::cbegin()
const noexcept
79 const std::size_t index
85std::span<const Signal::Sample::AmplitudeT> Signal::amplitudes() const noexcept
90bool Signal::is_uniformly_sampled() const noexcept
102 return time_offsets.has_value() ? baseline_time + (*time_offsets)[index] : baseline_time;
118 const Signal& old_signal,
124 samples(old_signal.samples),
125 timing_baseline(old_signal.timing_baseline),
126 fs_source(old_signal.fs_source),
127 time_offsets(old_signal.time_offsets)
136 samples.emplace_back(amplitude);
150 samples.emplace_back(amplitude);
169 samples.emplace_back(amplitude);
180 samples.emplace_back(amplitude);
201void Signal::set_source(
209void Signal::set_time_offset(
210 const Sample::TimeT new_time_offset
213 timing_baseline.time_offset = new_time_offset;
216void Signal::set_sample_rate(
217 const std::size_t new_sample_rate
220 timing_baseline.sample_rate = new_sample_rate;
221 timing_baseline.sample_rate_r = new_sample_rate == 0 ? 0 : 1.0f /
static_cast<float>(new_sample_rate);
231 const auto expected =
235 if (
const auto offset = given_time - expected; std::abs(offset) <= epsilon) {
263 "Signal {} rejected out-of-order sample at time {}s (previous sample was accepted at "
EchoMap portable logger specification.
Audio signal class specification.
A participant in a runtime object model with a numerically unique identifier and display name.
A single channel of discretely sampled audio data.
void reserve_samples(std::size_t count)
Reserves memory to store the given number of total samples in the channel.
std::uint64_t get_sample_count() const noexcept
Retrieves the total number of samples in the Signal stream.
static constexpr std::pair< Sample::AmplitudeT, Sample::AmplitudeT > normalised_range
The range within which the amplitude values are normalised.
void emplace_sample_from_source(Sample::AmplitudeT amplitude)
Emplace an externally sourced sample to the back of the channel sample data.
void emplace_sample(Sample::AmplitudeT amplitude)
Emplace a sample to the back of the channel sample data.
std::vector< Sample::AmplitudeT > samples
Amplitude sample stream.
std::optional< Source > fs_source
External source, if any, of the Signal Sample stream.
Baseline timing_baseline
A baseline of timing parameters.
std::optional< std::vector< Sample::TimeT > > time_offsets
An optional vector of explicit timestamps for each sample.
const std::optional< Source > & observe_source() const noexcept
Retrieves the optional Source of the Signal.
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.
void emplace_time(Sample::TimeT given_time)
Implementation helper to associate the latest amplitude sample with the given time.
The main EchoMap outermost namespace for all non-exported symbols.
Sample::TimeT time_offset
Timestamp, in seconds, of the first sample.
std::size_t sample_rate
Constant sample rate, in Hz, of the signal.
A PCM float-32 sampled audio point at an explicit time offset.
float AmplitudeT
Type for sample amplitudes.
float TimeT
Type for sample times.
std::size_t channel
The channel number of the Signal within the given file.
std::filesystem::path path
The path (absolute or relative to CWD) of the source wave file.