-
Notifications
You must be signed in to change notification settings - Fork 13
/
blocks_plugin_processor.h
153 lines (126 loc) · 6.96 KB
/
blocks_plugin_processor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Copyright 2013-2019 Matt Tytel
*
* pylon is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* pylon is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with pylon. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <juce_core/juce_core.h>
#include "vital/common/synth_base.h"
#include "vital/value_bridge.h"
#include "MainComponent.h"
#include "vital/common/synth_gui_interface.h"
#include "module_new.h"
#include "connection.h"
#include "model/PresetManager.h"
class ValueBridge;
class PluginProcessor: public SynthBase, public juce::AudioProcessor, public ValueBridge::Listener, public gui::MainComponent::Delegate, public SynthGuiInterface {
public:
static constexpr int kSetProgramWaitMilliseconds = 500;
PluginProcessor();
virtual ~PluginProcessor();
SynthGuiInterface* getGuiInterface() override;
void beginChangeGesture(const std::string& name) override;
void endChangeGesture(const std::string& name) override;
void setValueNotifyHost(const std::string& name, vital::mono_float value) override;
// const juce::CriticalSection& getCriticalSection() override;
void pauseProcessing(bool pause) override;
void prepareToPlay(double sample_rate, int buffer_size) override;
void releaseResources() override;
void processBlock(AudioSampleBuffer&, MidiBuffer&) override;
void handleBlockChanges();
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;
const String getName() const override;
bool supportsMPE() const override { return true; }
const String getInputChannelName(int channel_index) const override;
const String getOutputChannelName(int channel_index) const override;
bool isInputChannelStereoPair(int index) const override;
bool isOutputChannelStereoPair(int index) const override;
bool acceptsMidi() const override;
bool producesMidi() const override;
bool silenceInProducesSilenceOut() const override;
double getTailLengthSeconds() const override;
int getNumPrograms() override { return 1; }
int getCurrentProgram() override { return 0; }
void setCurrentProgram(int index) override { }
const String getProgramName(int index) override;
void changeProgramName(int index, const String& new_name) override { }
void getStateInformation(juce::MemoryBlock& destData) override;
void setStateInformation(const void* data, int size_in_bytes) override;
// juce::AudioProcessorParameter* getBypassParameter() const override { return bypass_parameter_; }
void parameterChanged(std::string name, vital::mono_float value) override;
void removeModulator(int index);
void removeBlock(const Index& index);
// MainComponent::Delegate
// std::shared_ptr<Tab> editorAddedTab(int column) override;
void editorRepositionedTab(int oldColumn, int newColumn) override;
void editorChangedTabLength(int column, int length) override;
juce::Array<int> editorRequestsActiveColumns() override;
std::vector<std::shared_ptr<model::Block>> editorPastedIndices(const std::vector<model::Block> copied_blocks, Index target) override;
void editorRemovedTab(int column) override;
void editorRemovedBlock(Index index) override;
void editorRepositionedBlock(Index from, Index to) override;
void editorAdjustedBlock(Index index, int parameter, float value) override;
void editorAdjustedTab(int column, int parameter, float value) override;
void editorChangedModulationMagnitude(int connectionIndex, float magnitude) override;
void editorParameterGestureChanged(std::string module_name, std::string paramter_name, bool started) override;
void editorChangedModulationPolarity(int index, bool bipolar) override;
void editorDisconnectedModulation(int index) override;
void editorDisconnectedModulation(ID source_id, std::string target_name, std::string parameter) override;
void editorSavedPreset(std::string name) override;
void editorConnectedModulation(int modulatorIndex, std::string target_name, std::string parameter) override;
void editorChangedBlockLength(Index index, int length) override;
void editorAdjustedModulator(std::string parameter_name, int modulator, float value) override;
void editorRemovedModulator(int index) override;
std::optional<Preset> editorNavigatedPreset(bool next) override;
void editorStartedAdjustingColumn(std::string control, int column) override;
void editorEndedAdjustingColumn(std::string control, int column) override;
void editorAdjustedColumn(std::string contorl, int column, float value) override;
void disconnect(std::shared_ptr<model::Connection>& connection);
void editorStartedAdjustingParameter(ID& id, std::string& parameter_name, bool started) override;
void editorAdjustedParameter(ID& id, std::string& parameter_name, float value) override;
std::shared_ptr<model::Block> getBlock2(Index index) override;
// std::shared_ptr<Tab> getTab(int column) override;
std::shared_ptr<model::Block> editorAddedBlock2(std::string code, Index index) override;
std::shared_ptr<model::Module> editorAddedModulator2(std::string code) override;
std::shared_ptr<model::Module> getModulator2(int index) override;
Preset editorChangedPreset(int index) override;
void clear();
Preset getStateRepresentation() override;
std::vector<std::shared_ptr<model::Module>> getModulators2() override;
// juce::Array<std::shared_ptr<Modulation>> getConnectionsOfSource(std::shared_ptr<Module> source) override;
std::vector<std::shared_ptr<model::Connection>> getModulations() override;
std::pair<float, float> editorRequestsModulatorValue(Index moduleIndex, int parameterIndex, int modulatorIndex) override;
std::pair<float, float> editorRequestsModulatorValue(int modulationConnectionIndex) override;
StringArray editorRequestsPresetNames() override;
juce::Array<juce::MPENote> editorRequestsCurrentlyPlayingNotes() override;
const vital::StatusOutput* editorRequestsStatusOutput(std::string name) override;
// *********************************************************
private:
int current_preset_index_ = -1;
bool editor_ready_ = false;
std::atomic<int> block_updates_ = 0;
bool engine_prepared_ = false;
std::optional<Preset> pending_preset_;
ValueBridge* bypass_parameter_;
double last_seconds_time_;
MidiKeyboardState keyboard_state_;
gui::MainComponent* main_component_;
PresetManager preset_manager_;
void loadPreset(Preset preset);
void setValue(std::string module_id, std::string parameter, float value);
std::string getStateString();
juce::AudioPlayHead::CurrentPositionInfo position_info_;
std::map<std::string, ValueBridge*> bridge_lookup_;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginProcessor)
};