Files
reasampler/src/core/instrument/map/trigger_seam.h
T
daniel 65f6070348 Bake window: derived note lengths carry exact durations, not ladder rungs — a long take is no longer cut at 384 beats
Hold keeps its picker. Also: one home for the %-fold, duration-ordered Hold travel, and a corrupt tail degrades to absent rather than fabricating one.
2026-08-01 21:10:38 -04:00

26 lines
1.2 KiB
C++

// trigger_seam — the shared Trigger play-span formula: how a %-length becomes the source-frame
// span the voice plays, the overlay draws over, and the bake's window holds. One home so those
// cannot disagree about where a Trigger note ends.
//
// playLengthFrames = round(clamp01(lengthFraction) * (frameCount - startFrame))
#pragma once
#include <cstdint>
namespace reasampler::instrument::map {
// `startFrame` is the effective start point (0 when absent), `lengthFraction` the EFFECTIVE one
// — fold it through effectiveLengthFraction (play_params.h) first, or a stored-but-inert %-knob
// shortens the span. Returns 0 for an empty post-start span and for any fraction that is not
// above zero, NaN included; the fraction is clamped to 1.0 and the result to the span, so a
// corrupt stored value cannot reach past the source.
//
// Voice::start evaluates this same clamped formula inline rather than calling it: the engine
// does not depend on `map/`, in either direction.
std::int64_t triggerPlayLength(double lengthFraction,
std::int64_t frameCount,
std::int64_t startFrame);
} // namespace reasampler::instrument::map