[go: up one dir, main page]

Menu

[r31]: / Source / PluginProcessor.h  Maximize  Restore  History

Download this file

198 lines (150 with data), 6.8 kB

  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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**************************************************************************
Copyright (C) 2019 Arnaud Champenois arthelion@free.fr
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
#include <vector>
#include "Synth.h"
#include "SynthVoice.h"
class MolossI;
class PitchParameters;
class VCOParameters;
class LFOParameters;
class TVFParameters;
class TVAParameters;
class TimeVariantParameters;
class SynthParameters;
// #define LOG_FILE
//==============================================================================
/*!
* MolossI audio processor
* This is the plugin top level interface. It relies on a Synth for the sound
* generation. It takes care of presets management, and makes the link between
* the Synth and the parameters that are edited or automated.
*/
class MolossI : public AudioProcessor
{
public:
//==============================================================================
MolossI();
~MolossI();
//==============================================================================
void prepareToPlay (double sampleRate, int samplesPerBlock) override;
void releaseResources() override;
#ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported (const BusesLayout& layouts) const override;
#endif
void processBlock (AudioBuffer<float>&, MidiBuffer&) override;
//==============================================================================
AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;
//==============================================================================
const String getName() const override;
bool acceptsMidi() const override;
bool producesMidi() const override;
bool isMidiEffect() const override;
double getTailLengthSeconds() const override;
//==============================================================================
int getNumPrograms() override;
int getCurrentProgram() override;
void setCurrentProgram (int index) override;
const String getProgramName (int index) override;
void changeProgramName (int index, const String& newName) override;
//==============================================================================
void getStateInformation (MemoryBlock& destData) override;
/*!
* Write state information into buffer
* \param destData Buffer to write to
* \param addPathNode Add a node with current sound file path
*/
void getStateInformation(MemoryBlock& destData, bool addPathNode);
void setStateInformation(const void* data, int sizeInBytes) override;
/*!
* Read state information from buffer
*
* \param data Buffer
* \param sizeInBytes Buffer size
* \param readPathNode Read current sound file path from info or ignore it
*/
void setStateInformation(const void* data, int sizeInBytes, bool readPathNode);
/*!
* Get synth voices (as polyphony count)
*
* \return The SynthVoices array.
*/
const std::vector<SynthVoice*>& getVoices() const { return mVoices; }
/*!
* Get the underlying synth
*
* \return The synth
*/
Synth &getSynth() { return *mSynth; }
VCOParameters* getVCOParameters(int vco) const { return mVCOParametersArray[vco].get(); }
TVFParameters* getTVFParameters(int vco) const { return mTVFParametersArray[vco].get(); }
TVAParameters* getTVAParameters(int vco) const { return mTVAParametersArray[vco].get(); }
PitchParameters* getPitchParameters(int vco) const { return mPitchParametersArray[vco].get(); }
SynthParameters*getSynthParameters() const { return mSynthParameters.get(); }
AudioProcessorValueTreeState& getTreeState() { return *mAudioTreeState; }
void addTreeStateParameter(RangedAudioParameter*param) {
mAudioTreeState->createAndAddParameter(std::unique_ptr <RangedAudioParameter>(param));
}
//==============================================================================
// Preset management section
void loadFromFile();
void saveToFile();
void saveToCurrentFile();
void resetSound();
void resetVoice(int voiceNumber);
String getCurrentFile();
Array<String> getLoadedFilenames();
bool hasCurrentFile() const {
return mCurrentFile.getFullPathName().isNotEmpty();
}
void parameterChanged() { mParameterChanged = true; updateCurrentFileState(); }
void parameterUnchanged() { mParameterChanged = false; updateCurrentFileState(); }
void updateActivityGUI();
void updateCurrentFileState();
void updateCurrentFiles();
void setTempo(double tempo);
//==============================================================================
// Copy/Paste parameters section
void clearCopiedParameter();
void paste(Moloss1Parameters*parameters,String prefix = String(),String filter = String()) {
parameters->readParameterValues(mCopiedParameters,prefix,filter);
}
void copy(Moloss1Parameters*parameters, String prefix = String()) {
parameters->getParameterValues(mCopiedParameters, prefix);
}
private:
void reloadCurrentFilesList();
//==============================================================================
std::unique_ptr<AudioProcessorValueTreeState> mAudioTreeState;
std::vector<SynthVoice*> mVoices;
std::vector<std::unique_ptr<PitchParameters>> mPitchParametersArray;
std::vector<std::unique_ptr<VCOParameters>> mVCOParametersArray;
std::vector<std::unique_ptr<TVFParameters>> mTVFParametersArray;
std::vector<std::unique_ptr<TVAParameters>> mTVAParametersArray;
std::unique_ptr<SynthParameters> mSynthParameters;
std::vector<LFOParameters*> mLFOParametersArray;
std::vector<TimeVariantParameters*> mADSRParametersArray;
std::unique_ptr <Synth> mSynth;
// Presets management
Array<File> mCurrentFilesList;
File mCurrentFile;
int mCurrentProgram = 0;
std::map <String, float> mCopiedParameters;
bool mParameterChanged = false;
double mTempo = 0.0;
MolossLogger ml;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MolossI)
};