annotate effects/reverb/Source/PluginProcessor.h @ 1:04e171d2a747 tip

JUCE 4 compatible. Standardised paths on Mac: modules '../../juce/modules'; VST folder '~/SDKs/vstsdk2.4' (JUCE default). Replaced deprecated 'getSampleData(channel)'; getToggleState(...); setToggleState(...); setSelectedId(...). Removed unused variables. Ignore JUCE code and build files.
author Brecht De Man <b.deman@qmul.ac.uk>
date Sun, 22 Nov 2015 15:23:40 +0000
parents e32fe563e124
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 This code accompanies the textbook:
andrewm@0 3
andrewm@0 4 Digital Audio Effects: Theory, Implementation and Application
andrewm@0 5 Joshua D. Reiss and Andrew P. McPherson
andrewm@0 6
andrewm@0 7 ---
andrewm@0 8
andrewm@0 9 Reverb: algorithmic reverb effect based on MVerb
andrewm@0 10 See textbook Chapter 11: Reverberation
andrewm@0 11
andrewm@0 12 Original code by Martin Eastwood: MVerb (see MVerb.h)
andrewm@0 13 Adapted for JUCE by Brecht De Man
andrewm@0 14
andrewm@0 15 When using this code (or a modified version thereof) please cite:
andrewm@0 16
andrewm@0 17 R. Stables, S. Enderby, B. De Man, G. Fazekas, J. D. Reiss, "SAFE:
andrewm@0 18 A System for the Extraction and Retrieval of Semantic Audio
andrewm@0 19 Descriptors," 15th International Society for Music Information
andrewm@0 20 Retrieval Conference (ISMIR 2014), 2014.
andrewm@0 21
andrewm@0 22 ---
andrewm@0 23
andrewm@0 24 This program is free software: you can redistribute it and/or modify
andrewm@0 25 it under the terms of the GNU General Public License as published by
andrewm@0 26 the Free Software Foundation, either version 3 of the License, or
andrewm@0 27 (at your option) any later version.
andrewm@0 28
andrewm@0 29 This program is distributed in the hope that it will be useful,
andrewm@0 30 but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0 32 GNU General Public License for more details.
andrewm@0 33
andrewm@0 34 You should have received a copy of the GNU General Public License
andrewm@0 35 along with this program. If not, see <http://www.gnu.org/licenses/>.
andrewm@0 36 */
andrewm@0 37
andrewm@0 38
andrewm@0 39 #ifndef __PLUGINPROCESSOR_H_88534BAA__
andrewm@0 40 #define __PLUGINPROCESSOR_H_88534BAA__
andrewm@0 41
andrewm@0 42 #include "../JuceLibraryCode/JuceHeader.h"
andrewm@0 43 #include "MVerb.h"
andrewm@0 44 #include <math.h>
andrewm@0 45
andrewm@0 46 class ReverbAudioProcessor : public AudioProcessor
andrewm@0 47 {
andrewm@0 48 public:
andrewm@0 49 ReverbAudioProcessor();
andrewm@0 50 ~ReverbAudioProcessor();
andrewm@0 51
andrewm@0 52 //==============================================================================
andrewm@0 53 // V S T M E T H O D S
andrewm@0 54
andrewm@0 55 void prepareToPlay (double sampleRate, int samplesPerBlock);
andrewm@0 56 void releaseResources();
andrewm@0 57 void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages);
andrewm@0 58 void updateParameters(int index);
andrewm@0 59 AudioProcessorEditor* createEditor();
andrewm@0 60 bool silenceInProducesSilenceOut() const;
andrewm@0 61 virtual double getTailLengthSeconds() const {return 0;};
andrewm@0 62 bool hasEditor() const;
andrewm@0 63 const String getName() const;
andrewm@0 64 int getNumParameters();
andrewm@0 65 float getParameter (int index);
andrewm@0 66 void setParameter (int index, float newValue);
andrewm@0 67 const String getParameterName (int index);
andrewm@0 68 const String getParameterText (int index);
andrewm@0 69 const String getInputChannelName (int channelIndex) const;
andrewm@0 70 const String getOutputChannelName (int channelIndex) const;
andrewm@0 71 bool isInputChannelStereoPair (int index) const;
andrewm@0 72 bool isOutputChannelStereoPair (int index) const;
andrewm@0 73 bool acceptsMidi() const;
andrewm@0 74 bool producesMidi() const;
andrewm@0 75 int getNumPrograms();
andrewm@0 76 int getCurrentProgram();
andrewm@0 77 void setCurrentProgram (int index);
andrewm@0 78 const String getProgramName (int index);
andrewm@0 79 void changeProgramName (int index, const String& newName);
andrewm@0 80 void getStateInformation (MemoryBlock& destData);
andrewm@0 81 void setStateInformation (const void* data, int sizeInBytes);
andrewm@0 82
andrewm@0 83
andrewm@0 84 //==============================================================================
andrewm@0 85 // O U R M E T H O D S
andrewm@0 86
andrewm@0 87 void Reset();
andrewm@0 88
andrewm@0 89 private:
andrewm@0 90
andrewm@0 91 // Accessors and mutators
andrewm@0 92 inline float GetDensity();
andrewm@0 93 inline void SetDensity(float density);
andrewm@0 94 inline float GetDecay();
andrewm@0 95 inline void SetDecay(float decay);
andrewm@0 96 inline float GetSize();
andrewm@0 97 inline void SetSize(float size);
andrewm@0 98 inline float GetDamp();
andrewm@0 99 inline void SetDamp(float damp);
andrewm@0 100 inline float GetBandwidth();
andrewm@0 101 inline void SetBandwidth(float bandwith);
andrewm@0 102 inline float GetPredelay();
andrewm@0 103 inline void SetPredelay(float predelay);
andrewm@0 104 inline float GetGain();
andrewm@0 105 inline void SetGain(float gain);
andrewm@0 106 inline float GetMix();
andrewm@0 107 inline void SetMix(float mix);
andrewm@0 108 inline float GetLateEarly();
andrewm@0 109 inline void SetLateEarly(float lateEarly);
andrewm@0 110
andrewm@0 111 int _numChannels;
andrewm@0 112 int _numSamples;
andrewm@0 113 int _sampleRate;
andrewm@0 114
andrewm@0 115 // parameters
andrewm@0 116 float _density;
andrewm@0 117 float _decay;
andrewm@0 118 float _size;
andrewm@0 119 float _damp;
andrewm@0 120 float _bandwidth;
andrewm@0 121 float _predelay;
andrewm@0 122 float _gain;
andrewm@0 123 float _mix;
andrewm@0 124 float _lateEarly;
andrewm@0 125
andrewm@0 126 MVerb<float> _mverb;
andrewm@0 127
andrewm@0 128
andrewm@0 129 bool _isFirstFrame;
andrewm@0 130
andrewm@0 131 // Buffers
andrewm@0 132 AudioSampleBuffer tempInput, tempOutput;
andrewm@0 133
andrewm@0 134 int _lastUIWidth, _lastUIHeight;
andrewm@0 135
andrewm@0 136 friend class ReverbAudioProcessorEditor;
andrewm@0 137
andrewm@0 138 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ReverbAudioProcessor);
andrewm@0 139 };
andrewm@0 140
andrewm@0 141 //=============================================================================
andrewm@0 142 // I N L I N E F U N C T I O N S C O D E S E C T I O N
andrewm@0 143
andrewm@0 144 //-----------------------------------------------------------------------------
andrewm@0 145 //
andrewm@0 146 inline float
andrewm@0 147 ReverbAudioProcessor::GetDensity()
andrewm@0 148 {
andrewm@0 149 return _density;
andrewm@0 150 }
andrewm@0 151
andrewm@0 152
andrewm@0 153 //-----------------------------------------------------------------------------
andrewm@0 154 //
andrewm@0 155 inline void
andrewm@0 156 ReverbAudioProcessor::SetDensity(float density)
andrewm@0 157 {
andrewm@0 158 _density = density;
andrewm@0 159 }
andrewm@0 160
andrewm@0 161
andrewm@0 162 //-----------------------------------------------------------------------------
andrewm@0 163 //
andrewm@0 164 inline float
andrewm@0 165 ReverbAudioProcessor::GetDecay()
andrewm@0 166 {
andrewm@0 167 return _decay;
andrewm@0 168 }
andrewm@0 169
andrewm@0 170
andrewm@0 171 //-----------------------------------------------------------------------------
andrewm@0 172 //
andrewm@0 173 inline void
andrewm@0 174 ReverbAudioProcessor::SetDecay(float decay)
andrewm@0 175 {
andrewm@0 176 _decay = decay;
andrewm@0 177 }
andrewm@0 178
andrewm@0 179 //-----------------------------------------------------------------------------
andrewm@0 180 //
andrewm@0 181 inline float
andrewm@0 182 ReverbAudioProcessor::GetSize()
andrewm@0 183 {
andrewm@0 184 return _size;
andrewm@0 185 }
andrewm@0 186
andrewm@0 187
andrewm@0 188 //-----------------------------------------------------------------------------
andrewm@0 189 //
andrewm@0 190 inline void
andrewm@0 191 ReverbAudioProcessor::SetSize(float size)
andrewm@0 192 {
andrewm@0 193 _size = size;
andrewm@0 194 }
andrewm@0 195
andrewm@0 196 //-----------------------------------------------------------------------------
andrewm@0 197 //
andrewm@0 198 inline float
andrewm@0 199 ReverbAudioProcessor::GetDamp()
andrewm@0 200 {
andrewm@0 201 return _damp;
andrewm@0 202 }
andrewm@0 203
andrewm@0 204
andrewm@0 205 //-----------------------------------------------------------------------------
andrewm@0 206 //
andrewm@0 207 inline void
andrewm@0 208 ReverbAudioProcessor::SetDamp(float damp)
andrewm@0 209 {
andrewm@0 210 _damp = damp;
andrewm@0 211 }
andrewm@0 212
andrewm@0 213 //-----------------------------------------------------------------------------
andrewm@0 214 //
andrewm@0 215 inline float
andrewm@0 216 ReverbAudioProcessor::GetBandwidth()
andrewm@0 217 {
andrewm@0 218 return _bandwidth;
andrewm@0 219 }
andrewm@0 220
andrewm@0 221
andrewm@0 222 //-----------------------------------------------------------------------------
andrewm@0 223 //
andrewm@0 224 inline void
andrewm@0 225 ReverbAudioProcessor::SetBandwidth(float bandwidth)
andrewm@0 226 {
andrewm@0 227 _bandwidth = bandwidth;
andrewm@0 228 }
andrewm@0 229
andrewm@0 230 //-----------------------------------------------------------------------------
andrewm@0 231 //
andrewm@0 232 inline float
andrewm@0 233 ReverbAudioProcessor::GetPredelay()
andrewm@0 234 {
andrewm@0 235 return _predelay;
andrewm@0 236 }
andrewm@0 237
andrewm@0 238
andrewm@0 239 //-----------------------------------------------------------------------------
andrewm@0 240 //
andrewm@0 241 inline void
andrewm@0 242 ReverbAudioProcessor::SetPredelay(float predelay)
andrewm@0 243 {
andrewm@0 244 _predelay = predelay;
andrewm@0 245 }
andrewm@0 246
andrewm@0 247 //-----------------------------------------------------------------------------
andrewm@0 248 //
andrewm@0 249 inline float
andrewm@0 250 ReverbAudioProcessor::GetGain()
andrewm@0 251 {
andrewm@0 252 return _gain;
andrewm@0 253 }
andrewm@0 254
andrewm@0 255
andrewm@0 256 //-----------------------------------------------------------------------------
andrewm@0 257 //
andrewm@0 258 inline void
andrewm@0 259 ReverbAudioProcessor::SetGain(float gain)
andrewm@0 260 {
andrewm@0 261 _gain = gain;
andrewm@0 262 }
andrewm@0 263
andrewm@0 264 //-----------------------------------------------------------------------------
andrewm@0 265 //
andrewm@0 266 inline float
andrewm@0 267 ReverbAudioProcessor::GetMix()
andrewm@0 268 {
andrewm@0 269 return _mix;
andrewm@0 270 }
andrewm@0 271
andrewm@0 272
andrewm@0 273 //-----------------------------------------------------------------------------
andrewm@0 274 //
andrewm@0 275 inline void
andrewm@0 276 ReverbAudioProcessor::SetMix(float mix)
andrewm@0 277 {
andrewm@0 278 _mix = mix;
andrewm@0 279 }
andrewm@0 280
andrewm@0 281 //-----------------------------------------------------------------------------
andrewm@0 282 //
andrewm@0 283 inline float
andrewm@0 284 ReverbAudioProcessor::GetLateEarly()
andrewm@0 285 {
andrewm@0 286 return _lateEarly;
andrewm@0 287 }
andrewm@0 288
andrewm@0 289
andrewm@0 290 //-----------------------------------------------------------------------------
andrewm@0 291 //
andrewm@0 292 inline void
andrewm@0 293 ReverbAudioProcessor::SetLateEarly(float lateEarly)
andrewm@0 294 {
andrewm@0 295 _lateEarly = lateEarly;
andrewm@0 296 }
andrewm@0 297 #endif // __PLUGINPROCESSOR_H_88534BAA__