Bake window derives itself: %-knob fold, declick pad, Gate held to exhaustion, preview velocity; Hold is the one knob a loop needs

This commit is contained in:
2026-08-01 20:26:04 -04:00
parent d3894dae6d
commit 19aeb92775
36 changed files with 1040 additions and 274 deletions
+41 -1
View File
@@ -3,7 +3,8 @@
//
// Covers triggerPlayLength: zero play length, startFrame set, startFrame past frameCount,
// rounding, and the Finding 1 regression (start-point set — the case that was broken before
// this module existed).
// this module existed); plus effectiveLengthFraction, the spline fold every consumer of the
// span must go through.
#include "../src/core/instrument/map/trigger_seam.h"
@@ -57,7 +58,46 @@ static void testPlayLengthRounding() {
CHECK(triggerPlayLength(0.6, 3, 0) == 2);
}
// --- effectiveLengthFraction --------------------------------------------------
// A drawn contour covers the FULL sample length, so the stored %-knob goes inert. It is not
// cleared, though — a pre-spline value survives in the record, and every reader that takes it
// raw plays, draws or bakes a fraction of the take.
static void testDrawnEnvelopeFoldsTheFractionToOne() {
PlayParams p;
p.trigger.lengthFraction = 0.25;
CHECK(effectiveLengthFraction(p) == 0.25); // staged: the knob is what it says
p.ampSpline.mode = EnvMode::Spline;
CHECK(effectiveLengthFraction(p) == 1.0); // drawn: the whole take
CHECK(p.trigger.lengthFraction == 0.25); // …and the stored value is untouched
// Flipping back restores the stored fraction, which is why the fold cannot be a write.
p.ampSpline.mode = EnvMode::Staged;
CHECK(effectiveLengthFraction(p) == 0.25);
}
// The fold reads the SAME predicate the engine's Gate refusal does, gating flags included: a
// Spline mode on a DISABLED pitch/filter envelope binds no cursor, so it must not fold.
static void testDisabledEnvelopesDoNotFoldTheFraction() {
PlayParams p;
p.trigger.lengthFraction = 0.5;
p.pitchSpline.mode = EnvMode::Spline;
CHECK(effectiveLengthFraction(p) == 0.5); // pitchEnv.enabled is still false
p.pitchEnv.enabled = true;
CHECK(effectiveLengthFraction(p) == 1.0);
p.pitchEnv.enabled = false;
p.filterSpline.mode = EnvMode::Spline;
CHECK(effectiveLengthFraction(p) == 0.5); // filter.enabled is still false
p.filter.enabled = true;
CHECK(effectiveLengthFraction(p) == 1.0);
}
int main() {
testDrawnEnvelopeFoldsTheFractionToOne();
testDisabledEnvelopesDoNotFoldTheFraction();
testPlayLengthNoStartPoint();
testPlayLengthWithStartPoint();
testPlayLengthZeroFrameCount();