Class thl::dsp::sampler::LoopMarkers#

class LoopMarkers#

Turns Start / End / Loop markers into a playable LoopRegion.

On top of LoopRegion::from_normalized():

  • Minimum span: End keeps its side of Start (End == Start plays forwards) at least min_span frames away; at the sample’s edge Start gives way instead. A zero-length region would be silent.

  • Snap (optional): Start, End and Loop move to the nearest upward zero crossing within snap_radius frames. The direction is always the raw markers’, so a Start snapping past a close End never reverses the region, and End never snaps back inside the minimum span.

  • Joined: whether both ends of the loop jump (End, and the frame the head re-enters at) landed on crossings, i.e. the join is in phase and an equal-gain crossfade is right.

The result is cached on its inputs (the markers, the snap flag and the view’s first-channel address and length), so an unmoved marker costs nothing. The cache cannot see audio replaced at the same address with the same length: call invalidate() when the sample changes.

Real-Time Safety

resolve() is real-time safe; a cache miss with snap on scans up to 3 * (2 * snap_radius + 1) frames.

Public Functions

inline void set_spans(size_t min_span, size_t snap_radius)#

Minimum span and snap radius, in frames.

inline void invalidate()#

Forget the cached result (e.g. the sample was replaced in place).

inline LoopRegion resolve(const SampleView &view, float start, float end, float loop, bool snap, bool &joined)#

Resolve normalised markers against view.

Parameters:

joined – Set to true when the loop join is in phase (see class).