Ξ-W2-T1: the resample bake chain — instrument renders, extension banks, one click re-points and resets

This commit is contained in:
2026-08-01 16:26:28 -04:00
parent 6c982cd617
commit 60308a3655
52 changed files with 2212 additions and 55 deletions
+45
View File
@@ -0,0 +1,45 @@
// bake_plan — the programmed note resolved against a concrete sample rate: the frame
// window the offline pass renders, and the two event frames inside it.
//
// Separate from bake_render because the plan is what a preview and a bake must agree on;
// the render is only one consumer of it.
#pragma once
#include <cstdint>
#include <optional>
#include "core/instrument/note/note_program.h"
namespace reasampler::instrument::bake {
// Until the capture-signal popup ships, the bake needs a program to render. A zero end
// offset ends the capture exactly at note-off, which truncates every release — so the
// default opens the window past the gate by this much.
inline constexpr double kDefaultReleaseTailMs = 500.0;
// The program a bake uses when nothing has been entered: one quarter note at the default
// velocity, opening at note-on and closing kDefaultReleaseTailMs after the release starts.
note::NoteProgram defaultBakeProgram();
// The render window in frames. Frame 0 is the start of the captured file, NOT note-on:
// a negative start offset opens the capture before the note, and noteOnFrame is where the
// note actually lands inside it.
struct BakePlan {
std::int64_t totalFrames = 0;
std::int64_t noteOnFrame = 0; // in [0, totalFrames]
std::int64_t noteOffFrame = 0; // in [noteOnFrame, totalFrames]
// The capture's root: rendering AT root is what makes the root survivable, which is
// why the root parameter is the one processing control a bake does not reset.
int note = 60;
int velocity = 100;
int sampleRate = 0;
};
// nullopt for a collapsed window, a non-positive rate, or a window that rounds to no
// frames — a degenerate buffer is refused rather than rendered. `rootNote` and the
// resolved velocity are clamped into MIDI range.
std::optional<BakePlan> planBake(const note::ResolvedNote& resolved, int sampleRate,
int rootNote);
} // namespace reasampler::instrument::bake