Mercurial > hg > audio_effects_textbook_code
comparison effects/pingpongdelay/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 Ping-Pong Delay: stereo delay alternating between channels | |
10 See textbook Chapter 2: Delay Line Effects | |
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 #include "../JuceLibraryCode/JuceHeader.h" | |
34 | |
35 | |
36 //============================================================================== | |
37 /** | |
38 */ | |
39 class PingPongDelayAudioProcessor : public AudioProcessor | |
40 { | |
41 public: | |
42 //============================================================================== | |
43 PingPongDelayAudioProcessor(); | |
44 ~PingPongDelayAudioProcessor(); | |
45 | |
46 //============================================================================== | |
47 void prepareToPlay (double sampleRate, int samplesPerBlock); | |
48 void releaseResources(); | |
49 void reset(); | |
50 void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages); | |
51 | |
52 | |
53 //============================================================================== | |
54 AudioProcessorEditor* createEditor(); | |
55 bool hasEditor() const; | |
56 | |
57 //============================================================================== | |
58 const String getName() const; | |
59 | |
60 int getNumParameters(); | |
61 | |
62 float getParameter (int index); | |
63 void setParameter (int index, float newValue); | |
64 | |
65 const String getParameterName (int index); | |
66 const String getParameterText (int index); | |
67 | |
68 const String getInputChannelName (int channelIndex) const; | |
69 const String getOutputChannelName (int channelIndex) const; | |
70 bool isInputChannelStereoPair (int index) const; | |
71 bool isOutputChannelStereoPair (int index) const; | |
72 | |
73 bool silenceInProducesSilenceOut() const; | |
74 double getTailLengthSeconds() const; | |
75 bool acceptsMidi() const; | |
76 bool producesMidi() const; | |
77 | |
78 //============================================================================== | |
79 int getNumPrograms(); | |
80 int getCurrentProgram(); | |
81 void setCurrentProgram (int index); | |
82 const String getProgramName (int index); | |
83 void changeProgramName (int index, const String& newName); | |
84 | |
85 //============================================================================== | |
86 void getStateInformation (MemoryBlock& destData); | |
87 void setStateInformation (const void* data, int sizeInBytes); | |
88 | |
89 //============================================================================== | |
90 | |
91 // these are used to persist the UI's size - the values are stored along with the | |
92 // filter's other parameters, and the UI component will update them when it gets | |
93 // resized. | |
94 int lastUIWidth_, lastUIHeight_; | |
95 | |
96 enum Parameters | |
97 { | |
98 kDelayLengthLeftParam = 0, | |
99 kDelayLengthRightParam, | |
100 kWetMixParam, | |
101 kFeedbackParam, | |
102 kReverseChannelsParam, | |
103 kNumParameters | |
104 }; | |
105 | |
106 // Adjustable parameters: | |
107 float delayLengthLeft_; // Length of left->right delay line in seconds | |
108 float delayLengthRight_; // Length of right->left delay line in seconds | |
109 float wetMix_; // Mix level of delayed signal (0-1) | |
110 float feedback_; // Feedback level (0-just less than 1) | |
111 bool reverseChannels_; // Whether to reverse the outputs from the delays | |
112 | |
113 private: | |
114 // Circular buffer variables for implementing delay | |
115 AudioSampleBuffer delayBuffer_; | |
116 int delayBufferLength_; | |
117 int delayReadPositionLeft_, delayReadPositionRight_; | |
118 int delayWritePosition_; | |
119 | |
120 //============================================================================== | |
121 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (PingPongDelayAudioProcessor); | |
122 }; | |
123 | |
124 #endif // __PLUGINPROCESSOR_H_4693CB6E__ |