From 177c26dcb5e826fc0d14fa08b785eaa012aeabbe Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 23 Jan 2020 23:33:02 -0500 Subject: [PATCH] Fix VST3 validation errors (#1503) The VST3 validation errors were caused by 2 things 1. The MIDI fake params didn't have a name; now they do 2. The MIDI controller would just ask for an assignment for controllers outside range, I guess to test if I returned false? Which I now do? I guess? Closes #1396 --- src/vst3/SurgeVst3Processor.cpp | 25 ++++++++++++++++++++++++- src/vst3/SurgeVst3Processor.h | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/vst3/SurgeVst3Processor.cpp b/src/vst3/SurgeVst3Processor.cpp index 8ce896d3b91..4c05d690875 100644 --- a/src/vst3/SurgeVst3Processor.cpp +++ b/src/vst3/SurgeVst3Processor.cpp @@ -16,6 +16,7 @@ #include #include #include +#include using namespace Steinberg::Vst; @@ -654,6 +655,19 @@ tresult PLUGIN_API SurgeVst3Processor::getParameterInfo(int32 paramIndex, Parame info.unitId = 0; // meta.clump; // FIXME - set the title + wchar_t nm[512]; + auto im = paramIndex - midi_controller_0; + auto ich = im % 16; + auto icc = im / 16; + + swprintf(nm, 512, L"MIDI CC %d Ch.%d", icc, ich ); + +#if MAC || LINUX + std::copy(nm, nm + 128, info.title); +#else + swprintf(reinterpret_cast(info.title), 128, L"%S", nm); +#endif + } else { @@ -697,6 +711,12 @@ tresult PLUGIN_API SurgeVst3Processor::getParameterInfo(int32 paramIndex, Parame info.defaultNormalizedValue = meta.fdefault; info.unitId = 0; // meta.clump; info.flags = ParameterInfo::kCanAutomate; + + //char nm[512]; + //surgeInstance->getParameterName( id, nm ); + // std::cout << "gPID " << paramIndex << " " << " " << info.id << std::endl; + + } return kResultOk; } @@ -828,6 +848,10 @@ tresult PLUGIN_API SurgeVst3Processor::getMidiControllerAssignment(int32 busInde CtrlNumber midiControllerNumber, ParamID& id /*out*/) { + // Why even ask me? But you do. So... + if( midiControllerNumber >= kCountCtrlNumber || midiControllerNumber < 0 ) + return kResultFalse; + /* ** Alrighty dighty. What VST3 wants us to do here is, for the controller number, ** tell it a parameter to map to. We alas don't have a parameter to map to because @@ -836,7 +860,6 @@ tresult PLUGIN_API SurgeVst3Processor::getMidiControllerAssignment(int32 busInde */ id = midi_controller_0 + midiControllerNumber * 16 + channel; - // std::cout << "getMidiControllerAssignment " << channel << " midiControllerNumber=" << midiControllerNumber << " id=" << id << std::endl; return kResultTrue; } diff --git a/src/vst3/SurgeVst3Processor.h b/src/vst3/SurgeVst3Processor.h index b1dcc93848e..f662bc5418c 100644 --- a/src/vst3/SurgeVst3Processor.h +++ b/src/vst3/SurgeVst3Processor.h @@ -144,7 +144,7 @@ class SurgeVst3Processor : public Steinberg::Vst::SingleComponentEffect, FpuState _fpuState; int midi_controller_0, midi_controller_max; - const int n_midi_controller_params = 16 * Steinberg::Vst::ControllerNumbers::kCountCtrlNumber; + const int n_midi_controller_params = 16 * (Steinberg::Vst::ControllerNumbers::kCountCtrlNumber); public: OBJ_METHODS(SurgeVst3Processor, Steinberg::Vst::SingleComponentEffect)