fix(drop): recognize TCP/MCP FX-button hotspot for instrument drop (S-VIEW-BUG-1)

The FX-hotspot classifier matched only fx_ (the FX-chain/floating windows),
so a drop on a track TCP FX button (info tcp*) never armed the drop and the
capture fell through to arrange as audio. Widen to fx_/tcp/mcp in a pure,
unit-tested predicate; shell calls it.
This commit is contained in:
2026-07-27 13:26:10 -04:00
parent 3b9b78b82c
commit fef595be91
4 changed files with 74 additions and 15 deletions
+8
View File
@@ -39,6 +39,14 @@ std::string buildInstrumentDropChunk(const std::string& sampleId) {
return encodeBase64(instrumentDropStateBytes(sampleId));
}
bool infoNamesFxHotspot(const std::string& info) {
// See the header contract. The FX-chain / floating-FX windows report "fx_*"; the track /
// mixer panel that carries the FX button reports "tcp*" / "mcp*". Prefix-match all three —
// the TCP/MCP surfaces are the fix for S-VIEW-BUG-1 (the "fx_"-only predicate missed them).
auto startsWith = [&info](const char* p) { return info.rfind(p, 0) == 0; };
return startsWith("fx_") || startsWith("tcp") || startsWith("mcp");
}
std::string encodeBase64(const std::vector<std::uint8_t>& bytes) {
std::string out;
out.reserve(((bytes.size() + 2) / 3) * 4);
+20
View File
@@ -49,6 +49,26 @@ namespace reasampler {
// Deterministic: the same sampleId always yields the same blob (base64 of the same bytes).
std::string buildInstrumentDropChunk(const std::string& sampleId);
// -- FX-drop-target classification (S-VIEW-BUG-1) ------------------------------
//
// Pure classifier for GetThingFromPoint's info string: is the point over a surface where an
// instrument drop should instantiate ReaSampler 9000 on the resolved track? This is string
// logic (no REAPER types), so it lives here and is unit-tested outside the DAW — the shell
// (instrument_drop_win) only supplies the info bytes GetThingFromPoint filled.
//
// THE BUG (S-VIEW-BUG-1): the original shell predicate matched ONLY "fx_" — but per the SDK
// (reaper_plugin_functions.h §GetThingFromPoint) "fx_chain"/"fx_N" are the FX-CHAIN and
// FLOATING-FX windows; a hit on the TRACK PANEL (where the TCP/MCP FX button actually lives —
// the intuitive "drop onto the track's FX chain" target) reports a string that BEGINS WITH
// "tcp" or "mcp" (e.g. "tcp.fx"). So dropping on the TCP FX button never armed the drop; the
// gesture fell through and the file dropped to arrange as audio. The drop target is therefore
// EITHER of the SDK's two documented FX-bearing surfaces:
// * the FX chain / floating FX window -> info begins with "fx_" ("fx_chain", "fx_0", ...)
// * the track/mixer panel that hosts the FX button -> info begins with "tcp" or "mcp"
// A single-capture drag released over any of these, on a resolved track, is an instrument drop.
// Any other info ("arrange", "spacer_0", "", ...) is not an FX hotspot.
bool infoNamesFxHotspot(const std::string& info);
// The raw (pre-base64) component-state bytes — exposed so the round-trip test can decode them
// back through the instrument's OWN reader (sample_map::deserializeComponentState) and assert
// the capture is selected, proving buildInstrumentDropChunk feeds the instrument exactly what
+4 -15
View File
@@ -5,10 +5,10 @@
#include "instrument_drop_win.h"
#include <cstring>
#include <string>
#include "app_version.h" // vstPluginName() — the CHANNEL-correct FX name (stable/beta pairing)
#include "app_version.h" // vstPluginName() — the CHANNEL-correct FX name (stable/beta pairing)
#include "instrument_drop.h" // infoNamesFxHotspot — the PURE, unit-tested hotspot classifier
#include "reaper_plugin.h"
@@ -23,19 +23,6 @@
namespace reasampler {
namespace {
// GetThingFromPoint's info string prefixes (verified against reaper_plugin_functions.h:
// "Updates infoOut with information such as 'arrange', 'fx_chain', 'fx_0' ... If a track
// panel is hit, string will begin with 'tcp' or 'mcp' or 'tcp.mute' etc"). The FX region
// reports "fx_chain" (the FX list area) or "fx_N" (a specific FX button). We treat either
// as the FX hotspot — the S17 drop target.
bool infoNamesFxHotspot(const char* info) {
return std::strncmp(info, "fx_", 3) == 0;
}
} // namespace
FxDropTarget resolveFxDropTarget(int screenX, int screenY) {
FxDropTarget out;
char info[256] = {0};
@@ -46,6 +33,8 @@ FxDropTarget resolveFxDropTarget(int screenX, int screenY) {
MediaTrack* track = GetThingFromPoint(screenX, screenY, info, sizeof(info));
out.track = track;
out.overReaperUi = (track != nullptr) || (info[0] != '\0');
// S-VIEW-BUG-1: the hotspot is either the FX chain/floating window ("fx_*") OR the track/
// mixer panel that hosts the FX button ("tcp*"/"mcp*"). The pure classifier owns the rule.
out.overFxHotspot = (track != nullptr) && infoNamesFxHotspot(info);
return out;
}