Mercurial > hg > audio_effects_textbook_code
comparison effects/tremolo/Source/PluginProcessor.h @ 0:e32fe563e124
First commit
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Fri, 10 Oct 2014 15:41:23 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e32fe563e124 |
---|---|
1 /* | |
2 This code accompanies the textbook: | |
3 | |
4 Digital Audio Effects: Theory, Implementation and Application | |
5 Joshua D. Reiss and Andrew P. McPherson | |
6 | |
7 --- | |
8 | |
9 Tremolo: amplitude modulation using a low-frequency oscillator | |
10 See textbook Chapter 5: Amplitude Modulation | |
11 | |
12 Code by Andrew McPherson, Brecht De Man and Joshua Reiss | |
13 | |
14 --- | |
15 | |
16 This program is free software: you can redistribute it and/or modify | |
17 it under the terms of the GNU General Public License as published by | |
18 the Free Software Foundation, either version 3 of the License, or | |
19 (at your option) any later version. | |
20 | |
21 This program is distributed in the hope that it will be useful, | |
22 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 GNU General Public License for more details. | |
25 | |
26 You should have received a copy of the GNU General Public License | |
27 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
28 */ | |
29 | |
30 #ifndef __PLUGINPROCESSOR_H_4693CB6E__ | |
31 #define __PLUGINPROCESSOR_H_4693CB6E__ | |
32 | |
33 #define _USE_MATH_DEFINES | |
34 #include "../JuceLibraryCode/JuceHeader.h" | |
35 | |
36 | |
37 //============================================================================== | |
38 /** | |
39 */ | |
40 class TremoloAudioProcessor : public AudioProcessor | |
41 { | |
42 public: | |
43 //============================================================================== | |
44 TremoloAudioProcessor(); | |
45 ~TremoloAudioProcessor(); | |
46 | |
47 //============================================================================== | |
48 void prepareToPlay (double sampleRate, int samplesPerBlock); | |
49 void releaseResources(); | |
50 void reset(); | |
51 void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); | |
52 | |
53 | |
54 //============================================================================== | |
55 AudioProcessorEditor* createEditor(); | |
56 bool hasEditor() const; | |
57 | |
58 //============================================================================== | |
59 const String getName() const; | |
60 | |
61 int getNumParameters(); | |
62 | |
63 float getParameter (int index); | |
64 void setParameter (int index, float newValue); | |
65 | |
66 const String getParameterName (int index); | |
67 const String getParameterText (int index); | |
68 | |
69 const String getInputChannelName (int channelIndex) const; | |
70 const String getOutputChannelName (int channelIndex) const; | |
71 bool isInputChannelStereoPair (int index) const; | |
72 bool isOutputChannelStereoPair (int index) const; | |
73 | |
74 bool silenceInProducesSilenceOut() const; | |
75 double getTailLengthSeconds() const; | |
76 bool acceptsMidi() const; | |
77 bool producesMidi() const; | |
78 | |
79 //============================================================================== | |
80 int getNumPrograms(); | |
81 int getCurrentProgram(); | |
82 void setCurrentProgram (int index); | |
83 const String getProgramName (int index); | |
84 void changeProgramName (int index, const String& newName); | |
85 | |
86 //============================================================================== | |
87 void getStateInformation (MemoryBlock& destData); | |
88 void setStateInformation (const void* data, int sizeInBytes); | |
89 | |
90 //============================================================================== | |
91 | |
92 // these are used to persist the UI's size - the values are stored along with the | |
93 // filter's other parameters, and the UI component will update them when it gets | |
94 // resized. | |
95 int lastUIWidth_, lastUIHeight_; | |
96 | |
97 enum Parameters | |
98 { | |
99 kFrequencyParam, | |
100 kDepthParam, | |
101 kWaveformParam, | |
102 kNumParameters | |
103 }; | |
104 | |
105 enum Waveforms | |
106 { | |
107 kWaveformSine = 1, | |
108 kWaveformTriangle, | |
109 kWaveformSquare, | |
110 kWaveformSquareSlopedEdges, | |
111 kNumWaveforms | |
112 }; | |
113 | |
114 // Adjustable parameters: | |
115 float frequency_; // LFO frequency (Hz) | |
116 float depth_; // Depth of effect (0-1) | |
117 int waveform_; // What shape should be used for the LFO | |
118 | |
119 private: | |
120 float lfo(float phase, int waveform); | |
121 | |
122 float lfoPhase_; // Phase of the low-frequency oscillator | |
123 double inverseSampleRate_; // It's more efficient to multiply than divide, so | |
124 // cache the inverse of the sample rate | |
125 | |
126 //============================================================================== | |
127 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TremoloAudioProcessor); | |
128 }; | |
129 | |
130 #endif // __PLUGINPROCESSOR_H_4693CB6E__ |