gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit a1894788b663972e8371d896045ee305e29a2c58
parent 9df89f0e66cc93cd160779c14e3e85bfeacb54a9
Author: Tal Aviram <me@talaviram.com>
Date:   Sat, 31 Jul 2021 20:03:29 +0300

controller - add Virus::Parameter class, designed to control and manage param.

Diffstat:
Msource/jucePlugin/CMakeLists.txt | 2++
Msource/jucePlugin/VirusController.h | 3+++
Asource/jucePlugin/VirusParameter.cpp | 18++++++++++++++++++
Asource/jucePlugin/VirusParameter.h | 63+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 86 insertions(+), 0 deletions(-)

diff --git a/source/jucePlugin/CMakeLists.txt b/source/jucePlugin/CMakeLists.txt @@ -32,9 +32,11 @@ PRIVATE PluginEditor.cpp PluginProcessor.cpp VirusController.cpp + VirusParameter.cpp PluginEditor.h PluginProcessor.h VirusController.h + VirusParameter.h version.h ) diff --git a/source/jucePlugin/VirusController.h b/source/jucePlugin/VirusController.h @@ -2,6 +2,8 @@ #include <juce_audio_processors/juce_audio_processors.h> #include "../synthLib/plugin.h" +#include "VirusParameter.h" + class AudioPluginAudioProcessor; namespace Virus @@ -10,6 +12,7 @@ namespace Virus class Controller { public: + friend Parameter; static constexpr auto kNameLength = 10; Controller(AudioPluginAudioProcessor &, unsigned char deviceId = 0x00); diff --git a/source/jucePlugin/VirusParameter.cpp b/source/jucePlugin/VirusParameter.cpp @@ -0,0 +1,18 @@ +#include "VirusParameter.h" + +#include "VirusController.h" + +namespace Virus +{ + Parameter::Parameter(Controller &ctrl, const Description desc, const uint8_t partNum) : + m_ctrl(ctrl), m_desc(desc), m_partNum(partNum) + { + m_value.addListener(this); + } + + void Parameter::valueChanged(juce::Value &) + { + const uint8_t value = static_cast<int>(m_value.getValue()); + m_ctrl.sendSysEx(m_ctrl.constructMessage({static_cast<uint8_t>(m_desc.page), m_partNum, m_desc.index, value})); + } +} // namespace Virus diff --git a/source/jucePlugin/VirusParameter.h b/source/jucePlugin/VirusParameter.h @@ -0,0 +1,63 @@ +#pragma once + +#include <juce_audio_processors/juce_audio_processors.h> + +namespace Virus +{ + + class Controller; + + class Parameter : private juce::Value::Listener + { + public: + enum Class + { + UNDEFINED = 0x0, + GLOBAL = 0x1, + PERFORMANCE_CONTROLLER = 0x2, + SOUNDBANK_A = 0x4, + SOUNDBANK_B = 0x8, + MULTI_OR_SINGLE = 0x10, + MULTI_PARAM = 0x20, + NON_PART_SENSITIVE = 0x40, + BANK_PROGRAM_CHANGE_PARAM_BANK_SELECT = 0x80, + VIRUS_C = 0x100, + }; + + enum Page + { + A = 0x70, + B = 0x71, + C = 0x72 + }; + + struct Description + { + Page page; + int classFlags; + uint8_t index; + juce::String name; + juce::Range<int> range; + std::function<juce::String(float, Description ctx)> valueToTextFunction; + std::function<float(const juce::String &, Description ctx)> textToValueFunction; + bool isPublic; + bool isDiscrete; + bool isBool; + }; + + Parameter(Controller &, const Description desc, uint8_t partNum = 0x40); + + juce::Value &getValueObject() { return m_value; }; + const juce::Value &getValueObject() const { return m_value; }; + + const Description getDescription() const { return m_desc; }; + + private: + void valueChanged(juce::Value &) override; + + Controller &m_ctrl; + Description m_desc; + uint8_t m_paramNum, m_partNum; + juce::Value m_value; + }; +} // namespace Virus