refactor(ingest): ME-import adds RS9k to selected track, not a new track

No track is created; no routing changes. No selected track -> bank
import proceeds, instrument placement is refused with a console message
explaining why. createTrackWithInstrument removed (was sole caller).
This commit is contained in:
2026-07-27 14:18:10 -04:00
parent 8576832c84
commit 3a95ce61fe
3 changed files with 58 additions and 89 deletions
-44
View File
@@ -6,7 +6,6 @@
#include "instrument_drop_win.h"
#include <string>
#include <vector>
#include "app_version.h" // vstPluginName() — the CHANNEL-correct FX name (stable/beta pairing)
#include "instrument_drop.h" // infoNamesFxHotspot — the PURE, unit-tested hotspot classifier
@@ -20,12 +19,6 @@
#define REAPERAPI_WANT_TrackFX_SetNamedConfigParm
#define REAPERAPI_WANT_Undo_BeginBlock2
#define REAPERAPI_WANT_Undo_EndBlock2
#define REAPERAPI_WANT_CountTracks
#define REAPERAPI_WANT_InsertTrackInProject
#define REAPERAPI_WANT_GetTrack
#define REAPERAPI_WANT_DeleteTrack
#define REAPERAPI_WANT_GetSetMediaTrackInfo_String
#define REAPERAPI_WANT_TrackList_AdjustWindows
#include "reaper_plugin_functions.h"
namespace reasampler {
@@ -88,41 +81,4 @@ bool performInstrumentDrop(MediaTrack* track, const std::string& chunkBase64) {
return ok;
}
MediaTrack* createTrackWithInstrument(const std::string& trackName,
const std::string& chunkBase64) {
if (chunkBase64.empty()) return nullptr;
// Append a new track at the end of the active project (proj=0). flags=0: no default FX/
// envelopes — we add exactly the one instrument ourselves. InsertTrackInProject returns
// void, so re-fetch the appended track by its (now-last) zero-based index. The index BEFORE
// insertion equals the new track's index AFTER insertion (append at the tail).
const int newIndex = CountTracks(nullptr);
InsertTrackInProject(nullptr, newIndex, /*flags=*/0);
MediaTrack* track = GetTrack(nullptr, newIndex);
if (!track) return nullptr; // insertion did not yield a fetchable track — nothing to clean up
// Name the track after the imported sound (RS5k parity). P_NAME writes are propagated to
// the panels by TrackList_AdjustWindows below. GetSetMediaTrackInfo_String takes a non-const
// buffer even when setting, so copy into a mutable vector.
if (!trackName.empty()) {
std::vector<char> nameBuf(trackName.begin(), trackName.end());
nameBuf.push_back('\0');
GetSetMediaTrackInfo_String(track, "P_NAME", nameBuf.data(), /*setNewValue=*/true);
}
// Add + inject the pre-loaded instrument. No inner undo block — the caller owns the grouping
// so track-create + persist + FX collapse to one Ctrl-Z. All-or-nothing on failure.
if (!loadInstrumentOntoTrack(track, chunkBase64)) {
// Roll back the track we just created so the project is left exactly as it was (no
// orphaned empty track). DeleteTrack removes the track and everything on it.
DeleteTrack(track);
TrackList_AdjustWindows(false);
return nullptr;
}
// Repaint the TCP/MCP so the new named track + its FX appear immediately.
TrackList_AdjustWindows(false);
return track;
}
} // namespace reasampler