From 5453f4966c9b49f607d9a0e4fbdaf063512f38d0 Mon Sep 17 00:00:00 2001 From: daniel-c-harvey Date: Sun, 26 Jul 2026 18:20:41 -0400 Subject: [PATCH] fix(embed): WM_GETMINMAXINFO size hints, remove dead selectedId_, fix selectedZone_ comment, decay embedPeak_ on early returns --- src/vst/reasampler_embed.cpp | 18 +++++++++++++++--- src/vst/reasampler_embed.h | 6 +++--- src/vst/reasampler_processor.cpp | 2 ++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/vst/reasampler_embed.cpp b/src/vst/reasampler_embed.cpp index 959ed8c..43d6e30 100644 --- a/src/vst/reasampler_embed.cpp +++ b/src/vst/reasampler_embed.cpp @@ -82,14 +82,12 @@ void ReaSamplerEmbed::refresh() { if (!processor_) { samples_.clear(); map_.zones.clear(); - selectedId_.clear(); selectedZone_ = -1; return; } auto banks = processor_->bridge().readReasamplerExtState(reasampler::kProjExtBanksKey); samples_ = banks ? listSamples(*banks) : std::vector{}; map_ = processor_->performanceMap(); - selectedId_ = processor_->selectedSampleId(); if (selectedZone_ >= static_cast(map_.zones.size())) selectedZone_ = -1; } @@ -106,6 +104,20 @@ TPtrInt ReaSamplerEmbed::embed_message(int msg, TPtrInt parm2, TPtrInt parm3) { return 0; case REAPER_FXEMBED_WM_DESTROY: return 0; + case REAPER_FXEMBED_WM_GETMINMAXINFO: { + auto* hints = reinterpret_cast(parm3); + if (!hints) return 0; + // Minimum usable strip height: the keymap must not collapse below its floor + // (kEmbedKeymapMinHeight) plus the level band. + hints->min_width = 64; + hints->max_width = 0; // 0 = unconstrained + hints->min_height = kEmbedKeymapMinHeight + kEmbedLevelBandHeight; + hints->max_height = 0; // 0 = unconstrained + // Preferred aspect: wide strip, roughly 8:1 (w:h). 16.16 fixed point. + hints->preferred_aspect = (8 << 16) / 1; + hints->minimum_aspect = (4 << 16) / 1; + return 1; + } #ifdef _WIN32 case REAPER_FXEMBED_WM_PAINT: return paint(parm2, parm3) ? 1 : 0; @@ -114,7 +126,7 @@ TPtrInt ReaSamplerEmbed::embed_message(int msg, TPtrInt parm2, TPtrInt parm3) { return onMouseDown(parm3) ? REAPER_FXEMBED_RETNOTIFY_INVALIDATE : 0; #endif default: - return 0; // unhandled messages (cursor, wheel, hittest, minmax) fall through + return 0; // unhandled messages (cursor, wheel, hittest) fall through } } diff --git a/src/vst/reasampler_embed.h b/src/vst/reasampler_embed.h index b4bad22..8db5d0b 100644 --- a/src/vst/reasampler_embed.h +++ b/src/vst/reasampler_embed.h @@ -90,9 +90,9 @@ private: // Snapshotted for the current paint (refreshed each paint off the audio thread). std::vector samples_; PerformanceMap map_; - std::string selectedId_; - // The zone the last click selected (mirrored to the processor's editor-shared selection - // where meaningful); -1 = none. Drives the strip's highlight. + // The zone the last click selected (local/visual only — S6 selection constraint; the + // processor's editor-shared selection is NOT updated from here); -1 = none. + // Drives the strip's highlight. int selectedZone_ = -1; }; diff --git a/src/vst/reasampler_processor.cpp b/src/vst/reasampler_processor.cpp index db7febd..fc00d58 100644 --- a/src/vst/reasampler_processor.cpp +++ b/src/vst/reasampler_processor.cpp @@ -348,6 +348,7 @@ tresult PLUGIN_API ReaSamplerProcessor::process(ProcessData& data) { } if (data.numOutputs <= 0 || !data.outputs || data.numSamples <= 0) { + embedPeak_.store(0.f, std::memory_order_relaxed); return kResultOk; } AudioBusBuffers& out = data.outputs[0]; @@ -356,6 +357,7 @@ tresult PLUGIN_API ReaSamplerProcessor::process(ProcessData& data) { // 64-bit host processing is not supported by the mono float core; emit silence // rather than mis-render. REAPER runs 32-bit float by default. if (data.symbolicSampleSize != kSample32) { + embedPeak_.store(0.f, std::memory_order_relaxed); for (int32 ch = 0; ch < out.numChannels; ++ch) { if (double* buf = out.channelBuffers64[ch]) { for (int32 i = 0; i < frames; ++i) buf[i] = 0.0;