annotate effects/compressor/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 Compressor: dynamic range compression effect
andrewm@0 10 See textbook Chapter 6: Dynamics Processing
andrewm@0 11
andrewm@0 12 Code by Joshua Reiss, Brecht de Man and Andrew McPherson
andrewm@0 13
andrewm@0 14 ---
andrewm@0 15
andrewm@0 16 This program is free software: you can redistribute it and/or modify
andrewm@0 17 it under the terms of the GNU General Public License as published by
andrewm@0 18 the Free Software Foundation, either version 3 of the License, or
andrewm@0 19 (at your option) any later version.
andrewm@0 20
andrewm@0 21 This program is distributed in the hope that it will be useful,
andrewm@0 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
andrewm@0 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrewm@0 24 GNU General Public License for more details.
andrewm@0 25
andrewm@0 26 You should have received a copy of the GNU General Public License
andrewm@0 27 along with this program. If not, see <http://www.gnu.org/licenses/>.
andrewm@0 28 */
andrewm@0 29
andrewm@0 30 #ifndef __PLUGINPROCESSOR_H_88534BAA__
andrewm@0 31 #define __PLUGINPROCESSOR_H_88534BAA__
andrewm@0 32
andrewm@0 33 #include "../JuceLibraryCode/JuceHeader.h"
andrewm@0 34 #include <math.h>
andrewm@0 35 class CompressorAudioProcessor : public AudioProcessor
andrewm@0 36 {
andrewm@0 37 public:
andrewm@0 38 CompressorAudioProcessor();
andrewm@0 39 ~CompressorAudioProcessor();
andrewm@0 40
andrewm@0 41 int bufferSize;
andrewm@0 42
andrewm@0 43 void prepareToPlay (double sampleRate, int samplesPerBlock);
andrewm@0 44 void releaseResources();
andrewm@0 45 void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages);
andrewm@0 46
andrewm@0 47 void compressor(AudioSampleBuffer &buffer, int m);// compressor functions
andrewm@0 48
andrewm@0 49 template <class T> const T& max ( const T& a, const T& b );
andrewm@0 50
andrewm@0 51 AudioProcessorEditor* createEditor();
andrewm@0 52
andrewm@0 53 bool hasEditor() const;
andrewm@0 54
andrewm@0 55 AudioPlayHead::CurrentPositionInfo lastPosInfo;
andrewm@0 56
andrewm@0 57 int round(float inn);
andrewm@0 58 const String getName() const;
andrewm@0 59
andrewm@0 60 int getNumParameters();
andrewm@0 61
andrewm@0 62 float getParameter (int index);
andrewm@0 63 void setParameter (int index, float newValue);
andrewm@0 64
andrewm@0 65 const String getParameterName (int index);
andrewm@0 66 const String getParameterText (int index);
andrewm@0 67
andrewm@0 68 const String getInputChannelName (int channelIndex) const;
andrewm@0 69 const String getOutputChannelName (int channelIndex) const;
andrewm@0 70 bool isInputChannelStereoPair (int index) const;
andrewm@0 71 bool isOutputChannelStereoPair (int index) const;
andrewm@0 72
andrewm@0 73 bool silenceInProducesSilenceOut() const;
andrewm@0 74 double getTailLengthSeconds() const;
andrewm@0 75 bool acceptsMidi() const;
andrewm@0 76 bool producesMidi() const;
andrewm@0 77
andrewm@0 78 int getNumPrograms();
andrewm@0 79 int getCurrentProgram();
andrewm@0 80 void setCurrentProgram (int index);
andrewm@0 81 const String getProgramName (int index);
andrewm@0 82 void changeProgramName (int index, const String& newName);
andrewm@0 83
andrewm@0 84 //==============================================================================
andrewm@0 85 void getStateInformation (MemoryBlock& destData);
andrewm@0 86 void setStateInformation (const void* data, int sizeInBytes);
andrewm@0 87
andrewm@0 88 float getThreshold();
andrewm@0 89 float getRatio();
andrewm@0 90 float getGain();
andrewm@0 91 float getAttackTime();
andrewm@0 92 float getReleaseTime();
andrewm@0 93 void setThreshold(float T);
andrewm@0 94 void setGain(float G);
andrewm@0 95 void setRatio(float R);
andrewm@0 96 void setAttackTime(float A);
andrewm@0 97 void setReleaseTime(float R);
andrewm@0 98 void resetAll();
andrewm@0 99
andrewm@0 100 // parameters
andrewm@0 101
andrewm@0 102 bool compressorONOFF;
andrewm@0 103 int M;
andrewm@0 104 bool autoTime;
andrewm@0 105
andrewm@0 106 private:
andrewm@0 107 AudioSampleBuffer inputBuffer;
andrewm@0 108
andrewm@0 109 // int bufferSize;
andrewm@0 110 //these are used to persist UI's size- values are stored along with filter's other parameters, and UI component will update them when it gets resized.
andrewm@0 111 int lastUIWidth, lastUIHeight;
andrewm@0 112
andrewm@0 113 HeapBlock <float> x_g, x_l,y_g, y_l,c;// input, output, control
andrewm@0 114 // parameters
andrewm@0 115 float ratio,threshold,makeUpGain,tauAttack,tauRelease,alphaAttack,alphaRelease,yL_prev;
andrewm@0 116 int nhost;
andrewm@0 117 int samplerate;
andrewm@0 118
andrewm@0 119 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CompressorAudioProcessor);
andrewm@0 120 };
andrewm@0 121
andrewm@0 122 #endif // __PLUGINPROCESSOR_H_88534BAA__