Keep CC assignments in array, so they may be reassigned
This commit is contained in:
parent
89a6830e1e
commit
77719d788e
3 changed files with 32 additions and 23 deletions
|
|
@ -9,7 +9,6 @@
|
||||||
#include "SfizzVstParameters.h"
|
#include "SfizzVstParameters.h"
|
||||||
#include "base/source/fstreamer.h"
|
#include "base/source/fstreamer.h"
|
||||||
#include "base/source/updatehandler.h"
|
#include "base/source/updatehandler.h"
|
||||||
#include "pluginterfaces/vst/ivstmidicontrollers.h"
|
|
||||||
|
|
||||||
tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +64,7 @@ tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||||
parameters.addParameter(Steinberg::String("Pitch bend"), nullptr, 0, 0.5, 0, pid++, Vst::kRootUnitId);
|
parameters.addParameter(Steinberg::String("Pitch bend"), nullptr, 0, 0.5, 0, pid++, Vst::kRootUnitId);
|
||||||
|
|
||||||
// MIDI controllers
|
// MIDI controllers
|
||||||
for (unsigned i = 0; i < kNumControllerParams; ++i) {
|
for (unsigned i = 0; i < sfz::config::numCCs; ++i) {
|
||||||
Steinberg::String title;
|
Steinberg::String title;
|
||||||
Steinberg::String shortTitle;
|
Steinberg::String shortTitle;
|
||||||
title.printf("Controller %u", i);
|
title.printf("Controller %u", i);
|
||||||
|
|
@ -76,6 +75,24 @@ tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context)
|
||||||
pid++, Vst::kRootUnitId, shortTitle);
|
pid++, Vst::kRootUnitId, shortTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initial MIDI mapping
|
||||||
|
for (int32 i = 0; i < Vst::kCountCtrlNumber; ++i) {
|
||||||
|
Vst::ParamID id = Vst::kNoParamId;
|
||||||
|
switch (i) {
|
||||||
|
case Vst::kAfterTouch:
|
||||||
|
id = kPidMidiAftertouch;
|
||||||
|
break;
|
||||||
|
case Vst::kPitchBend:
|
||||||
|
id = kPidMidiPitchBend;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (i < 128)
|
||||||
|
id = kPidMidiCC0 + i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
midiMapping_[i] = id;
|
||||||
|
}
|
||||||
|
|
||||||
return kResultTrue;
|
return kResultTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,22 +103,16 @@ tresult PLUGIN_API SfizzVstControllerNoUi::terminate()
|
||||||
|
|
||||||
tresult PLUGIN_API SfizzVstControllerNoUi::getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id)
|
tresult PLUGIN_API SfizzVstControllerNoUi::getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id)
|
||||||
{
|
{
|
||||||
switch (midiControllerNumber) {
|
if (midiControllerNumber < 0 || midiControllerNumber >= Vst::kCountCtrlNumber) {
|
||||||
case Vst::kAfterTouch:
|
id = Vst::kNoParamId;
|
||||||
id = kPidMidiAftertouch;
|
return kResultFalse;
|
||||||
return kResultTrue;
|
|
||||||
|
|
||||||
case Vst::kPitchBend:
|
|
||||||
id = kPidMidiPitchBend;
|
|
||||||
return kResultTrue;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if (midiControllerNumber < 0 || midiControllerNumber >= kNumControllerParams)
|
|
||||||
return kResultFalse;
|
|
||||||
|
|
||||||
id = kPidMidiCC0 + midiControllerNumber;
|
|
||||||
return kResultTrue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = midiMapping_[midiControllerNumber];
|
||||||
|
if (id == Vst::kNoParamId)
|
||||||
|
return kResultFalse;
|
||||||
|
|
||||||
|
return kResultTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
tresult PLUGIN_API SfizzVstControllerNoUi::getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string)
|
tresult PLUGIN_API SfizzVstControllerNoUi::getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string)
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include "SfizzVstUpdates.h"
|
#include "SfizzVstUpdates.h"
|
||||||
#include "public.sdk/source/vst/vsteditcontroller.h"
|
#include "public.sdk/source/vst/vsteditcontroller.h"
|
||||||
#include "public.sdk/source/vst/vstparameters.h"
|
#include "public.sdk/source/vst/vstparameters.h"
|
||||||
|
#include "pluginterfaces/vst/ivstmidicontrollers.h"
|
||||||
#include "vstgui/plugin-bindings/vst3editor.h"
|
#include "vstgui/plugin-bindings/vst3editor.h"
|
||||||
#include <sfizz_message.h>
|
#include <sfizz_message.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
@ -49,6 +50,7 @@ protected:
|
||||||
Steinberg::IPtr<FilePathUpdate> scalaPathUpdate_;
|
Steinberg::IPtr<FilePathUpdate> scalaPathUpdate_;
|
||||||
Steinberg::IPtr<ProcessorStateUpdate> processorStateUpdate_;
|
Steinberg::IPtr<ProcessorStateUpdate> processorStateUpdate_;
|
||||||
Steinberg::IPtr<PlayStateUpdate> playStateUpdate_;
|
Steinberg::IPtr<PlayStateUpdate> playStateUpdate_;
|
||||||
|
Vst::ParamID midiMapping_[Vst::kCountCtrlNumber] {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class SfizzVstController : public SfizzVstControllerNoUi, public VSTGUI::VST3EditorDelegate {
|
class SfizzVstController : public SfizzVstControllerNoUi, public VSTGUI::VST3EditorDelegate {
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,12 @@
|
||||||
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "sfizz/Config.h"
|
||||||
#include "public.sdk/source/vst/vstparameters.h"
|
#include "public.sdk/source/vst/vstparameters.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
using namespace Steinberg;
|
using namespace Steinberg;
|
||||||
|
|
||||||
// number of MIDI CC
|
|
||||||
enum {
|
|
||||||
kNumControllerParams = 128,
|
|
||||||
};
|
|
||||||
|
|
||||||
// parameters
|
// parameters
|
||||||
enum {
|
enum {
|
||||||
kPidVolume,
|
kPidVolume,
|
||||||
|
|
@ -27,7 +23,7 @@ enum {
|
||||||
kPidMidiAftertouch,
|
kPidMidiAftertouch,
|
||||||
kPidMidiPitchBend,
|
kPidMidiPitchBend,
|
||||||
kPidMidiCC0,
|
kPidMidiCC0,
|
||||||
kPidMidiCCLast = kPidMidiCC0 + kNumControllerParams - 1,
|
kPidMidiCCLast = kPidMidiCC0 + sfz::config::numCCs - 1,
|
||||||
/* Reserved */
|
/* Reserved */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue