Tidy reasampler_processor.h ceiling, restamp contour publish, tighten pitch-shift test bound

Splits BuiltCapture/sourceRateRefusalText into processor_snapshot.h; fixes stale lock-nesting notes; restamp now also publishes liveContours_ like reload; tightens a slack test bound and one drifted comment.
This commit is contained in:
2026-09-25 14:29:43 -04:00
parent 648fa515ad
commit 30bc5a9e77
7 changed files with 40 additions and 26 deletions
+11 -7
View File
@@ -80,10 +80,10 @@ std::optional<DecodedPcm> decodeRelative(const std::string& projectDir,
// The ONE decode + build the reload and the bake snapshot share, so a baked render can
// never be built from a different fold than the one the user is hearing.
ReaSamplerProcessor::BuiltCapture buildFromRef(const SelectedSample& sel,
const InstrumentParams& params,
const std::string& projectDir,
ChannelMode mode, int renderRate) {
BuiltCapture buildFromRef(const SelectedSample& sel,
const InstrumentParams& params,
const std::string& projectDir,
ChannelMode mode, int renderRate) {
std::optional<DecodedPcm> pcm = decodeRelative(projectDir, sel.relativePath, mode);
if (!pcm) return {};
if (!sourceRateSupported(pcm->sampleRate, renderRate)) return {std::nullopt, true};
@@ -172,8 +172,9 @@ std::string ReaSamplerProcessor::reloadInstrument() {
// collapses every automated envelope stage to zero frames.
builtSampleRate_.store(sample.outputRate(), std::memory_order_relaxed);
{
// reloadMutex_ (held for this whole function) nests livePublishMutex_ here;
// publishLiveParams never holds reloadMutex_, so this is the only nesting.
// reloadMutex_ (held for this whole function) nests livePublishMutex_ here, the
// same nesting restampHostRateLocked takes under its own reloadMutex_-held
// callers; publishLiveParams never holds reloadMutex_.
std::lock_guard<std::mutex> lp(livePublishMutex_);
liveParams_.publish(instrument::engine::foldLive(sample.play, sample.keyTrack));
// The model's contours, so a reload-tier contour edit (a point added, deleted or
@@ -206,7 +207,7 @@ std::string ReaSamplerProcessor::usageInstanceGuid() {
return instanceGuid_;
}
ReaSamplerProcessor::BuiltCapture ReaSamplerProcessor::bakeSnapshot(int renderRate) {
BuiltCapture ReaSamplerProcessor::bakeSnapshot(int renderRate) {
const std::string selId = selectedSampleId();
if (selId.empty()) return {};
const InstrumentParams params = instrumentParams();
@@ -443,6 +444,9 @@ bool ReaSamplerProcessor::restampHostRateLocked(SampleData& sample, int renderRa
builtSampleRate_.store(sample.outputRate(), std::memory_order_relaxed);
std::lock_guard<std::mutex> lp(livePublishMutex_);
liveParams_.publish(instrument::engine::foldLive(sample.play, sample.keyTrack));
// Symmetric with reloadInstrument's own publish pair: a re-stamp is a rebuild too, so the
// drain's sounding voices need the model's contours refreshed beside the live params.
liveContours_.publish(instrument::engine::foldContours(sample.play));
return true;
}