48 static runtime::Result<TempoMap, TempoMapError>
56 std::span<const TempoPoint>
points() const noexcept {
63 std::vector<TempoPoint> points_;
91class CompiledTempoMap {
118 bool matches(std::span<const TempoPoint> points)
const noexcept;
124 return segments_.size();
134 double start_bpm = 120.0;
135 double end_bpm = 120.0;
139 long double samples_from_segment_start(
const Segment& segment,
140 std::int64_t delta_ticks)
const noexcept;
141 long double ticks_from_segment_start(
const Segment& segment,
142 long double delta_samples)
const noexcept;
143 long double fractional_samples_to_ticks_in_segment(
long double sample,
144 std::size_t segment)
const noexcept;
145 long double fractional_ticks_to_samples_in_segment(
long double tick,
146 std::size_t segment)
const noexcept;
147 std::size_t segment_for_tick(
TickPosition tick)
const noexcept;
148 std::size_t segment_for_sample(
SamplePosition sample)
const noexcept;
150 std::size_t segment)
const noexcept;
152 std::size_t segment)
const noexcept;
155 : sample_rate_(sample_rate), segments_(std::move(segments)) {}
157 RationalRate sample_rate_;
158 std::vector<Segment> segments_;
180 return segment_index_;
185 std::size_t segment_index_ = 0;
187 bool positioned_ =
false;
200 return segment_index_;
205 std::size_t segment_index_ = 0;
206 long double tick_ = 0.0L;
207 bool positioned_ =
false;
Result<T, E> — either holds a T or an E, never both.
Definition result.hpp:76
Definition compiled_tempo_map.hpp:91
bool matches(std::span< const TempoPoint > points) const noexcept
True when this compiled map was built from exactly these canonical editable points.
long double fractional_samples_to_ticks(long double sample) const noexcept
Continuous inverse of fractional_ticks_to_samples() for render-time mapping.
static runtime::Result< CompiledTempoMap, TempoMapError > compile(std::span< const TempoPoint > points, RationalRate sample_rate) noexcept
double tempo_at_tick(TickPosition tick) const noexcept
long double fractional_ticks_to_samples(long double tick) const noexcept
Continuous counterpart to ticks_to_samples() for render-time interpolation.
RationalRate sample_rate() const noexcept
Definition compiled_tempo_map.hpp:120
double maximum_tempo_between(TickPosition start, TickPosition end) const noexcept
Maximum tempo over [start, end], including every intersected ramp extremum.
friend class TempoCursor
Definition compiled_tempo_map.hpp:128
SamplePosition ticks_to_samples(TickPosition tick) const noexcept
static runtime::Result< CompiledTempoMap, TempoMapError > compile(const TempoMap &map, RationalRate sample_rate) noexcept
Definition compiled_tempo_map.hpp:96
SampleToTickResult resolve_sample(SamplePosition sample) const noexcept
friend class TempoTickCursor
Definition compiled_tempo_map.hpp:129
TickPosition samples_to_ticks(SamplePosition sample) const noexcept
std::size_t segment_count() const noexcept
Definition compiled_tempo_map.hpp:123
long double advance_fractional(long double sample) noexcept
Continuous monotonic counterpart to advance().
SampleToTickResult seek(SamplePosition sample) noexcept
double tempo_at_tick(TickPosition tick) noexcept
TempoCursor(const CompiledTempoMap &map) noexcept
Definition compiled_tempo_map.hpp:167
SampleToTickResult advance(SamplePosition sample) noexcept
std::size_t segment_index() const noexcept
Definition compiled_tempo_map.hpp:179
void reset(const CompiledTempoMap &map) noexcept
Definition compiled_tempo_map.hpp:44
constexpr auto operator<=>(const TempoMap &) const =default
std::span< const TempoPoint > points() const noexcept
Definition compiled_tempo_map.hpp:56
TempoMap()
Definition compiled_tempo_map.hpp:46
static runtime::Result< TempoMap, TempoMapError > create(std::span< const TempoPoint > points) noexcept
runtime::Result< TempoMap, TempoMapError > replacing_points(std::span< const TempoPoint > points) const noexcept
Definition compiled_tempo_map.hpp:52
TempoTickCursor(const CompiledTempoMap &map) noexcept
Definition compiled_tempo_map.hpp:195
std::size_t segment_index() const noexcept
Definition compiled_tempo_map.hpp:199
TempoTickCursor()=default
long double advance_fractional(long double tick) noexcept
Definition beat_division.hpp:11
constexpr std::uint32_t kMaximumCompiledSampleRate
Definition compiled_tempo_map.hpp:17
TempoCurve
Definition compiled_tempo_map.hpp:19
@ LinearInTicks
Definition compiled_tempo_map.hpp:21
@ Constant
Definition compiled_tempo_map.hpp:20
constexpr double kMinimumCompiledTempoBpm
Definition compiled_tempo_map.hpp:15
constexpr double kMaximumCompiledTempoBpm
Definition compiled_tempo_map.hpp:16
TempoMapError
Definition compiled_tempo_map.hpp:31
@ InvalidFinalCurve
Definition compiled_tempo_map.hpp:36
@ InvalidCurve
Definition compiled_tempo_map.hpp:35
@ InvalidSampleRate
Definition compiled_tempo_map.hpp:38
@ InvalidBpm
Definition compiled_tempo_map.hpp:34
@ SampleRangeExceeded
Definition compiled_tempo_map.hpp:39
@ UnorderedPoints
Definition compiled_meter_map.hpp:41
@ Empty
Definition compiled_meter_map.hpp:38
@ MissingTickZero
Definition compiled_meter_map.hpp:39
Result<T, E> — success / failure union for fallible operations.
Definition rational_time.hpp:14
Definition rational_time.hpp:9
Definition compiled_tempo_map.hpp:66
bool exact
Definition compiled_tempo_map.hpp:70
TickPosition tick
Definition compiled_tempo_map.hpp:67
SamplePosition represented_sample
Definition compiled_tempo_map.hpp:68
std::uint64_t absolute_error_samples
Definition compiled_tempo_map.hpp:69
Definition compiled_tempo_map.hpp:24
TickPosition tick
Definition compiled_tempo_map.hpp:25
double bpm
Definition compiled_tempo_map.hpp:26
TempoCurve curve_to_next
Definition compiled_tempo_map.hpp:27
constexpr auto operator<=>(const TempoPoint &) const =default