commit 898e58d71a59d7384286d1954d0bc8673f767667
parent a6336fe60305c539670b520a7b973135715595b6
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Sat, 1 Jun 2024 16:02:25 +0200
move timers to process midi messages to base class
Diffstat:
8 files changed, 21 insertions(+), 63 deletions(-)
diff --git a/source/jucePluginLib/controller.cpp b/source/jucePluginLib/controller.cpp
@@ -28,10 +28,13 @@ namespace pluginLib
"Encountered errors while parsing parameter descriptions:\n\n" + m_descriptions.getErrors(),
nullptr, juce::ModalCallbackFunction::create([](int){}));
}
+
+ startTimer(50);
}
Controller::~Controller()
{
+ stopTimer();
m_softKnobs.clear();
}
@@ -234,7 +237,16 @@ namespace pluginLib
return true;
}
-
+
+ void Controller::timerCallback()
+ {
+ std::vector<synthLib::SMidiEvent> events;
+ getPluginMidiOut(events);
+
+ for (const auto& e : events)
+ parseMidiMessage(e);
+ }
+
bool Controller::sendSysEx(const std::string& _packetName) const
{
const std::map<pluginLib::MidiDataType, uint8_t> params;
diff --git a/source/jucePluginLib/controller.h b/source/jucePluginLib/controller.h
@@ -22,13 +22,13 @@ namespace pluginLib
class Processor;
using SysEx = std::vector<uint8_t>;
- class Controller
+ class Controller : juce::Timer
{
public:
static constexpr uint32_t InvalidParameterIndex = 0xffffffff;
explicit Controller(Processor& _processor, const std::string& _parameterDescJson);
- virtual ~Controller();
+ ~Controller() override;
virtual void sendParameterChange(const Parameter& _parameter, uint8_t _value) = 0;
@@ -127,6 +127,8 @@ namespace pluginLib
using ParameterList = std::vector<Parameter*>;
+ void timerCallback() override;
+
private:
Processor& m_processor;
ParameterDescriptions m_descriptions;
diff --git a/source/mqJucePlugin/mqController.cpp b/source/mqJucePlugin/mqController.cpp
@@ -50,8 +50,6 @@ Controller::Controller(AudioPluginAudioProcessor& p, unsigned char _deviceId) :
sendSysEx(RequestGlobal);
// sendGlobalParameterChange(mqLib::GlobalParameter::SingleMultiMode, 1);
- startTimer(50);
-
onPlayModeChanged.addListener(0, [this](bool multiMode)
{
requestAllPatches();
@@ -113,18 +111,6 @@ std::string Controller::loadParameterDescriptions()
return {};
}
-void Controller::timerCallback()
-{
- std::vector<synthLib::SMidiEvent> events;
- getPluginMidiOut(events);
-
- for (const auto& e : events)
- {
- if(!e.sysex.empty())
- parseSysexMessage(e.sysex, e.source);
- }
-}
-
void Controller::onStateLoaded()
{
}
diff --git a/source/mqJucePlugin/mqController.h b/source/mqJucePlugin/mqController.h
@@ -12,7 +12,7 @@ namespace mqJucePlugin
class AudioPluginAudioProcessor;
-class Controller : public pluginLib::Controller, juce::Timer
+class Controller : public pluginLib::Controller
{
public:
enum MidiPacketType
@@ -83,7 +83,6 @@ private:
static std::string loadParameterDescriptions();
- void timerCallback() override;
void onStateLoaded() override;
void applyPatchParameters(const pluginLib::MidiPacket::ParamValues& _params, uint8_t _part) const;
diff --git a/source/virusJucePlugin/VirusController.cpp b/source/virusJucePlugin/VirusController.cpp
@@ -79,14 +79,9 @@ namespace Virus
requestRomBanks();
};
}
-
- startTimer(5);
}
- Controller::~Controller()
- {
- stopTimer();
- }
+ Controller::~Controller() = default;
bool Controller::parseSysexMessage(const pluginLib::SysEx& _msg, synthLib::MidiEventSource)
{
@@ -656,25 +651,6 @@ namespace Virus
return pluginLib::Controller::sendSysEx(midiPacketName(_type), _params);
}
- void Controller::timerCallback()
- {
- std::vector<synthLib::SMidiEvent> virusOut;
- getPluginMidiOut(virusOut);
-
- for (const auto& msg : virusOut)
- {
- if (msg.sysex.empty())
- {
- // no sysex
- parseControllerDump(msg);
- }
- else
- {
- parseSysexMessage(msg.sysex, msg.source);
- }
- }
- }
-
void Controller::sendParameterChange(const pluginLib::Parameter& _parameter, uint8_t _value)
{
const auto& desc = _parameter.getDescription();
diff --git a/source/virusJucePlugin/VirusController.h b/source/virusJucePlugin/VirusController.h
@@ -13,7 +13,7 @@ class VirusProcessor;
namespace Virus
{
- class Controller : public pluginLib::Controller, juce::Timer
+ class Controller : public pluginLib::Controller
{
public:
struct Patch
@@ -160,8 +160,6 @@ namespace Virus
private:
std::string loadParameterDescriptions(virusLib::DeviceModel _model, const VirusProcessor& _processor);
- void timerCallback() override;
-
Singles m_singles;
SinglePatch m_singleEditBuffer; // single mode
std::array<SinglePatch, 16> m_singleEditBuffers; // multi mode
diff --git a/source/xtJucePlugin/xtController.cpp b/source/xtJucePlugin/xtController.cpp
@@ -66,8 +66,6 @@ Controller::Controller(AudioPluginAudioProcessor& p, unsigned char _deviceId) :
sendSysEx(RequestMode);
requestMulti(xt::LocationH::MultiDumpMultiEditBuffer, 0);
- startTimer(50);
-
onPlayModeChanged.addListener([this](bool multiMode)
{
requestAllPatches();
@@ -156,18 +154,6 @@ std::string Controller::loadParameterDescriptions()
return {};
}
-void Controller::timerCallback()
-{
- std::vector<synthLib::SMidiEvent> events;
- getPluginMidiOut(events);
-
- for (const auto& e : events)
- {
- if(!e.sysex.empty())
- parseSysexMessage(e.sysex, e.source);
- }
-}
-
void Controller::onStateLoaded()
{
}
diff --git a/source/xtJucePlugin/xtController.h b/source/xtJucePlugin/xtController.h
@@ -17,7 +17,7 @@ namespace xt
class AudioPluginAudioProcessor;
-class Controller : public pluginLib::Controller, juce::Timer
+class Controller : public pluginLib::Controller
{
public:
enum MidiPacketType
@@ -88,7 +88,6 @@ private:
static std::string loadParameterDescriptions();
- void timerCallback() override;
void onStateLoaded() override;
uint8_t getPartCount() override;