Merge pull request #879 from jpcima/vst-keyswitch-controller
Implement the VST keyswitch interface
This commit is contained in:
commit
645c221abc
2 changed files with 61 additions and 3 deletions
|
|
@ -167,6 +167,30 @@ tresult PLUGIN_API SfizzVstControllerNoUi::getMidiControllerAssignment(int32 bus
|
|||
return kResultTrue;
|
||||
}
|
||||
|
||||
int32 PLUGIN_API SfizzVstControllerNoUi::getKeyswitchCount(int32 busIndex, int16 channel)
|
||||
{
|
||||
(void)channel;
|
||||
|
||||
if (busIndex != 0)
|
||||
return 0;
|
||||
|
||||
return keyswitches_.size();
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::getKeyswitchInfo(int32 busIndex, int16 channel, int32 keySwitchIndex, Vst::KeyswitchInfo& info)
|
||||
{
|
||||
(void)channel;
|
||||
|
||||
if (busIndex != 0)
|
||||
return kResultFalse;
|
||||
|
||||
if (keySwitchIndex < 0 || keySwitchIndex >= keyswitches_.size())
|
||||
return kResultFalse;
|
||||
|
||||
info = keyswitches_[keySwitchIndex];
|
||||
return kResultTrue;
|
||||
}
|
||||
|
||||
tresult PLUGIN_API SfizzVstControllerNoUi::getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string)
|
||||
{
|
||||
switch (tag) {
|
||||
|
|
@ -291,9 +315,9 @@ tresult SfizzVstControllerNoUi::notify(Vst::IMessage* message)
|
|||
static_cast<Vst::ProgramListWithPitchNames*>(getProgramList(kProgramListID));
|
||||
for (int16 pitch = 0; pitch < 128; ++pitch) {
|
||||
Steinberg::String pitchName;
|
||||
if (!desc.keyLabel[pitch].empty())
|
||||
if (desc.keyUsed.test(pitch) && !desc.keyLabel[pitch].empty())
|
||||
pitchName = Steinberg::String(desc.keyLabel[pitch].c_str());
|
||||
else if (!desc.keyswitchLabel[pitch].empty())
|
||||
else if (desc.keyswitchUsed.test(pitch) && !desc.keyswitchLabel[pitch].empty())
|
||||
pitchName = Steinberg::String(desc.keyswitchLabel[pitch].c_str());
|
||||
|
||||
list->setPitchName(0, pitch, pitchName);
|
||||
|
|
@ -303,6 +327,33 @@ tresult SfizzVstControllerNoUi::notify(Vst::IMessage* message)
|
|||
if (unitHandler)
|
||||
unitHandler->notifyProgramListChange(kProgramListID, 0);
|
||||
|
||||
// update the key switches and notify
|
||||
size_t idKeyswitch = 0;
|
||||
for (int16 pitch = 0; pitch < 128; ++pitch)
|
||||
idKeyswitch += desc.keyswitchUsed.test(pitch);
|
||||
keyswitches_.resize(idKeyswitch);
|
||||
|
||||
idKeyswitch = 0;
|
||||
for (int16 pitch = 0; pitch < 128; ++pitch) {
|
||||
if (!desc.keyswitchUsed.test(pitch))
|
||||
continue;
|
||||
Vst::KeyswitchInfo info {};
|
||||
info.typeId = Vst::kNoteOnKeyswitchTypeID;
|
||||
Steinberg::String(desc.keyswitchLabel[pitch].c_str()).copyTo(info.title);
|
||||
Steinberg::String(desc.keyswitchLabel[pitch].c_str()).copyTo(info.shortTitle);
|
||||
info.keyswitchMin = pitch; // TODO reexamine this when supporting keyswitch groups
|
||||
info.keyswitchMax = pitch; // TODO reexamine this when supporting keyswitch groups
|
||||
info.keyRemapped = pitch;
|
||||
info.unitId = Vst::kRootUnitId;
|
||||
info.flags = 0;
|
||||
keyswitches_[idKeyswitch++] = info;
|
||||
}
|
||||
|
||||
Vst::IComponentHandler* componentHandler = getComponentHandler();
|
||||
if (componentHandler)
|
||||
// NOTE(jpc) I think that's the right one, but it needs confirmation
|
||||
componentHandler->restartComponent(Vst::kNoteExpressionChanged);
|
||||
|
||||
//
|
||||
sfzDescriptionUpdate_->deferUpdate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "public.sdk/source/vst/vstparameters.h"
|
||||
#include "public.sdk/source/common/threadchecker.h"
|
||||
#include "pluginterfaces/vst/ivstmidicontrollers.h"
|
||||
#include "pluginterfaces/vst/ivstnoteexpression.h"
|
||||
#include "vstgui/plugin-bindings/vst3editor.h"
|
||||
#include <sfizz_message.h>
|
||||
#include <mutex>
|
||||
|
|
@ -21,7 +22,8 @@ using namespace Steinberg;
|
|||
using namespace VSTGUI;
|
||||
|
||||
class SfizzVstControllerNoUi : public Vst::EditControllerEx1,
|
||||
public Vst::IMidiMapping {
|
||||
public Vst::IMidiMapping,
|
||||
public Vst::IKeyswitchController {
|
||||
public:
|
||||
virtual ~SfizzVstControllerNoUi() {}
|
||||
|
||||
|
|
@ -30,6 +32,9 @@ public:
|
|||
|
||||
tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id) override;
|
||||
|
||||
int32 PLUGIN_API getKeyswitchCount (int32 busIndex, int16 channel) override;
|
||||
tresult PLUGIN_API getKeyswitchInfo (int32 busIndex, int16 channel, int32 keySwitchIndex, Vst::KeyswitchInfo& info) override;
|
||||
|
||||
tresult PLUGIN_API getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string) override;
|
||||
tresult PLUGIN_API getParamValueByString(Vst::ParamID tag, Vst::TChar* string, Vst::ParamValue& valueNormalized) override;
|
||||
|
||||
|
|
@ -41,6 +46,7 @@ public:
|
|||
OBJ_METHODS(SfizzVstControllerNoUi, Vst::EditControllerEx1)
|
||||
DEFINE_INTERFACES
|
||||
DEF_INTERFACE(Vst::IMidiMapping)
|
||||
DEF_INTERFACE(Vst::IKeyswitchController)
|
||||
END_DEFINE_INTERFACES(Vst::EditControllerEx1)
|
||||
REFCOUNT_METHODS(Vst::EditControllerEx1)
|
||||
|
||||
|
|
@ -52,6 +58,7 @@ protected:
|
|||
Steinberg::IPtr<ScalaUpdate> scalaUpdate_;
|
||||
Steinberg::IPtr<PlayStateUpdate> playStateUpdate_;
|
||||
Vst::ParamID midiMapping_[Vst::kCountCtrlNumber] {};
|
||||
std::vector<Vst::KeyswitchInfo> keyswitches_;
|
||||
};
|
||||
|
||||
class SfizzVstController : public SfizzVstControllerNoUi, public VSTGUI::VST3EditorDelegate {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue