8#ifndef ECHOMAP_SIGNAL_HPP
9#define ECHOMAP_SIGNAL_HPP
39class Signal :
public Object<Signal>
68 [[nodiscard]]
bool operator<(
const Source& other)
const;
101 [[nodiscard]] Sample::TimeT get_time_offset() const noexcept;
102 [[nodiscard]]
std::
size_t get_sample_rate() const noexcept;
104 [[nodiscard]] decltype(
samples)::const_iterator begin() const;
105 [[nodiscard]] decltype(
samples)::const_iterator end() const;
106 [[nodiscard]] decltype(
samples)::const_iterator cbegin() const noexcept;
107 [[nodiscard]] decltype(
samples)::const_iterator cend() const noexcept;
109 [[nodiscard]] auto timed_samples()
const
112 std::views::transform([
this](
const std::size_t index) -> Sample {
118 [[nodiscard]] std::span<const Sample::AmplitudeT> amplitudes() const noexcept;
120 [[nodiscard]]
bool is_uniformly_sampled() const noexcept;
132 Signal(const Signal& old_signal);
133 Signal(const Signal& old_signal,
134 std::string_view new_name);
147 friend class SignalFactory;
244 void set_time_offset(
Sample::TimeT new_time_offset)
noexcept;
245 void set_sample_rate(
std::size_t new_sample_rate)
noexcept;
static constexpr std::string_view class_name
Display name for objects of the type determined by the templated class.
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.
Provides basic timing information relating to the Signal samples.
Sample::TimeT time_offset
Timestamp, in seconds, of the first sample.
std::size_t sample_rate
Constant sample rate, in Hz, of the signal.
float sample_rate_r
Reciprocal of the sample rate; zero if sample rate is zero.
A PCM float-32 sampled audio point at an explicit time offset.
float AmplitudeT
Type for sample amplitudes.
AmplitudeT amplitude
Normalised amplitude at the time.
float TimeT
Type for sample times.
Indicates an external source of a Signal on the filesystem.
bool dirty
Does the Signal contain additional samples?
std::size_t channel
The channel number of the Signal within the given file.
bool is_loaded
Has the Signal loaded all samples from the filesystem?
std::filesystem::path path
The path (absolute or relative to CWD) of the source wave file.