feat(panel): add Insert as FX — ReaSampler 9000 onto the selected track, preloaded with the focused capture, over the existing instrument-drop body

This commit is contained in:
2026-08-03 16:06:22 -04:00
parent 5042e2709b
commit fcd1ed022c
14 changed files with 323 additions and 18 deletions
+54
View File
@@ -0,0 +1,54 @@
// insert_fx_action.cpp — see insert_fx_action.h. main.cpp owns the API pointers; this TU
// gets them extern via the WANT list.
#include "shell/actions/insert_fx_action.h"
#include <cstdint>
#include <string>
#include <vector>
#include "core/ui/insert_fx_enable.h" // the refusal fold + its wording
#include "core/wire/instrument_drop.h" // buildInstrumentDropPreset — the pure payload
#include "shell/actions/instrument_drop_win.h" // performInstrumentDrop — the shared drop body
#include "shell/panel/panel_bank_ops.h" // bankPanelSelectedSampleIds
#include "reaper_plugin.h"
#define REAPERAPI_MINIMAL
#define REAPERAPI_WANT_GetSelectedTrack
#define REAPERAPI_WANT_ShowConsoleMsg
#include "reaper_plugin_functions.h"
namespace reasampler {
namespace {
void report(const std::string& sentence) {
if (ShowConsoleMsg) ShowConsoleMsg(("ReaSampler: " + sentence + "\n").c_str());
}
} // namespace
void doInsertAsFx() {
const std::vector<std::string> selected = bankPanelSelectedSampleIds();
// seltrackidx 0 = the FIRST selected track, master excluded (SDK header) — the same
// "the selected track" the Media-Explorer ingest surface targets. A multi-track
// selection therefore loads onto the first, rather than refusing or fanning out.
MediaTrack* track = GetSelectedTrack ? GetSelectedTrack(nullptr, 0) : nullptr;
const ui::InsertFxRefusal refusal =
ui::insertFxRefusal(static_cast<int>(selected.size()), track != nullptr);
if (refusal != ui::InsertFxRefusal::None) {
report(ui::insertFxRefusalMessage(refusal));
return;
}
// performInstrumentDrop opens its own undo block (one Ctrl-Z) and rolls the FX back
// itself if the preset never applies — there is nothing here to group with it, so no
// second block is opened around it.
if (!performInstrumentDrop(track, wire::buildInstrumentDropPreset(selected.front())))
report("could not add ReaSampler 9000 to the selected track -- check the plug-in "
"is installed and scanned");
}
} // namespace reasampler