Files
reasampler/src/shell/capture/provenance_shell.h
T

79 lines
4.3 KiB
C++

#pragma once
#include "core/namespaces.h"
// provenance_shell — the REAPER-facing reads Milestone 10 needs, in one place.
//
// The PURE provenance module (provenance.h) owns the fingerprint encoding, the
// recipe model, the FX-identity fold, and the parent-detection DECISION — all over
// plain strings/values. This shell gathers those strings/values FROM REAPER:
// * the in-scope FX-chain identity of a source track (name/GUID/enabled rows),
// * the media-file paths of a resolved capture's source items,
// * the active book's bank samples resolved to absolute file paths,
// * a canonical track-GUID string back to a live MediaTrack*.
//
// REAPER-facing: the .cpp includes reaper_plugin_functions.h WITHOUT
// REAPERAPI_IMPLEMENT (main.cpp owns the API pointers; here they are extern —
// CLAUDE.md §contract). MediaTrack is forward-declared so this header stays
// SDK-lite. It depends on the pure provenance module (FxIdentityEntry / recipe /
// BankFileRef) and bank_book (to enumerate the active book's samples).
#include <optional>
#include <string>
#include <vector>
#include "core/model/provenance.h"
class MediaTrack;
class MediaItem;
namespace reasampler {
class BankBook;
// The in-scope FX-chain identity of a source track (Track scope), folded to the
// pure provenance string. Reads the track's own FX chain via TrackFX_GetCount /
// TrackFX_GetFXName / TrackFX_GetFXGUID / TrackFX_GetEnabled in chain order.
std::string fxChainIdentityForTrack(MediaTrack* tr);
// The in-scope FX-chain identity for Item scope: enumerates each item's active
// take FX chain via TakeFX_GetCount / TakeFX_GetFXName / TakeFX_GetFXGUID /
// TakeFX_GetEnabled, in item order then FX order, combined with
// combineChainIdentities so distinct per-item partitions never collide. Returns
// the combined identity string (empty combined identity for a no-FX or no-item
// set). The items vector is the same source-item set the shell collected for the
// item-scope capture (selected items whose owning tracks were also collected).
std::string fxChainIdentityForItems(const std::vector<MediaItem*>& items);
// Reads the media-file path of every SELECTED media item's active take source
// (GetMediaItemTake_Source -> GetMediaSourceFileName), normalized to forward-slash.
// Unresolvable items (no take / no source / empty name) are omitted — never an
// empty string in the result, so detectParent's "not in bank" branch is honest.
// The active-project selection is read directly (mirrors main.cpp's collectors).
// This is the ITEM-scope source set (the user selected the items being resampled).
std::vector<std::string> selectedItemSourceFiles();
// The TRACK-scope source set: the media-file paths of the items ON `tracks` that
// OVERLAP the capture range [startSeconds, endSeconds). For a track capture the user
// selects the track, not the item, so the "what audio is being captured" set is the
// range-overlapping items on the source tracks. Same normalize + omit-unresolvable
// contract as selectedItemSourceFiles. An item overlaps iff its [pos, pos+len)
// intersects the range with positive overlap (a zero-length touch does not count).
std::vector<std::string> trackItemSourceFiles(const std::vector<MediaTrack*>& tracks,
double startSeconds, double endSeconds);
// Enumerates the ACTIVE book's samples across every bank (pool + named) as pure
// BankFileRefs — each sample id paired with its file resolved to a normalized
// ABSOLUTE path against `projectDir` (resolveBankFile + normalizeSlashes). A sample
// whose path cannot be resolved (empty projectDir / empty relativePath) is emitted
// with an empty absolutePath, which detectParent never matches. `projectDir` is the
// current .rpp parent (the shell resolves it; empty -> all refs unresolved).
std::vector<BankFileRef> bankFileRefs(const BankBook& book, const std::string& projectDir);
// Resolves a canonical track-GUID string (guidString form) to a live MediaTrack*
// in the active project by scanning tracks and comparing guidString(tr). Returns
// nullptr when no live track carries that GUID (the source track was deleted since
// capture — a re-capture failure mode the caller reports). The master track is not
// scanned (it has no membership GUID and is never a capture source).
MediaTrack* trackByGuid(const std::string& guid);
} // namespace reasampler