y@0
|
1 /*
|
y@0
|
2 ==============================================================================
|
y@0
|
3
|
y@0
|
4 This file was auto-generated!
|
y@0
|
5
|
y@0
|
6 It contains the basic startup code for a Juce application.
|
y@0
|
7
|
y@0
|
8 ==============================================================================
|
y@0
|
9 */
|
y@0
|
10
|
y@0
|
11 #ifndef __PLUGINPROCESSOR_H_4693CB6E__
|
y@0
|
12 #define __PLUGINPROCESSOR_H_4693CB6E__
|
y@0
|
13
|
y@0
|
14 #include "../JuceLibraryCode/JuceHeader.h"
|
y@0
|
15 #include <fftw3.h>
|
y@0
|
16 #include <complex>
|
y@0
|
17 //==============================================================================
|
y@0
|
18 /**
|
y@0
|
19 */
|
y@0
|
20 class ADRessAudioProcessor : public AudioProcessor
|
y@0
|
21 {
|
y@0
|
22 public:
|
y@0
|
23 //==============================================================================
|
y@0
|
24 ADRessAudioProcessor();
|
y@0
|
25 ~ADRessAudioProcessor();
|
y@0
|
26
|
y@0
|
27 //==============================================================================
|
y@0
|
28 void prepareToPlay (double sampleRate, int samplesPerBlock);
|
y@0
|
29 void releaseResources();
|
y@0
|
30
|
y@0
|
31
|
y@0
|
32 void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages);
|
y@0
|
33
|
y@0
|
34 //==============================================================================
|
y@0
|
35 AudioProcessorEditor* createEditor();
|
y@0
|
36 bool hasEditor() const;
|
y@0
|
37
|
y@0
|
38 //==============================================================================
|
y@0
|
39 const String getName() const;
|
y@0
|
40
|
y@0
|
41 int getNumParameters();
|
y@0
|
42
|
y@0
|
43 float getParameter (int index);
|
y@0
|
44 void setParameter (int index, float newValue);
|
y@0
|
45
|
y@0
|
46 const String getParameterName (int index);
|
y@0
|
47 const String getParameterText (int index);
|
y@0
|
48
|
y@0
|
49 const String getInputChannelName (int channelIndex) const;
|
y@0
|
50 const String getOutputChannelName (int channelIndex) const;
|
y@0
|
51 bool isInputChannelStereoPair (int index) const;
|
y@0
|
52 bool isOutputChannelStereoPair (int index) const;
|
y@0
|
53
|
y@0
|
54 bool silenceInProducesSilenceOut() const;
|
y@0
|
55 bool acceptsMidi() const;
|
y@0
|
56 bool producesMidi() const;
|
y@0
|
57
|
y@0
|
58 double getTailLengthSeconds() const;
|
y@0
|
59
|
y@0
|
60 //==============================================================================
|
y@0
|
61 int getNumPrograms();
|
y@0
|
62 int getCurrentProgram();
|
y@0
|
63 void setCurrentProgram (int index);
|
y@0
|
64 const String getProgramName (int index);
|
y@0
|
65 void changeProgramName (int index, const String& newName);
|
y@0
|
66
|
y@0
|
67 //==============================================================================
|
y@0
|
68 void getStateInformation (MemoryBlock& destData);
|
y@0
|
69 void setStateInformation (const void* data, int sizeInBytes);
|
y@0
|
70
|
y@0
|
71 //==============================================================================
|
y@0
|
72
|
y@0
|
73 // these are used to persist the UI's size - the values are stored along with the
|
y@0
|
74 // filter's other parameters, and the UI component will update them when it gets
|
y@0
|
75 // resized.
|
y@0
|
76 int lastUIWidth_, lastUIHeight_;
|
y@0
|
77
|
y@0
|
78 enum Parameters
|
y@0
|
79 {
|
y@0
|
80 kFFTSizeParam = 0,
|
y@0
|
81 kHopSizeParam,
|
y@0
|
82 kWindowTypeParam,
|
y@0
|
83 kWidthParam,
|
y@0
|
84 kAzimuthParam,
|
y@0
|
85 kNumParameters
|
y@0
|
86 };
|
y@0
|
87
|
y@0
|
88 enum Window
|
y@0
|
89 {
|
y@0
|
90 kWindowRectangular = 1,
|
y@0
|
91 kWindowBartlett,
|
y@0
|
92 kWindowHann,
|
y@0
|
93 kWindowHamming
|
y@0
|
94 };
|
y@0
|
95
|
y@0
|
96 enum HopSize
|
y@0
|
97 {
|
y@0
|
98 kHopSize1Window = 1,
|
y@0
|
99 kHopSize1_2Window,
|
y@0
|
100 kHopSize1_4Window,
|
y@0
|
101 kHopSize1_8Window
|
y@0
|
102 };
|
y@0
|
103
|
y@0
|
104 // This parameter indicates the FFT size for phase vocoder computation. It is selected
|
y@0
|
105 // by the GUI and may temporarily differ from the actual size used in calculations.
|
y@0
|
106 int fftSelectedSize_;
|
y@0
|
107 int hopSelectedSize_; // Hop size, chosen from one of the options above
|
y@0
|
108 int windowType_; // Type of window used
|
y@0
|
109
|
y@0
|
110 int /*indL_, indR_,*/ width_, azimuth_, beta_;
|
y@0
|
111 int indMinL_,indMinR_,indMaxL_,indMaxR_;
|
y@0
|
112 float invGain_;
|
y@0
|
113
|
y@0
|
114 bool computeR_, computeL_;
|
y@0
|
115 float invBeta_;
|
y@0
|
116 std::complex<double> i1;
|
y@0
|
117
|
y@0
|
118 private:
|
y@0
|
119
|
y@0
|
120 double azr_[2049][11];
|
y@0
|
121 double azl_[2049][11];
|
y@0
|
122 double realR_[2049];
|
y@0
|
123 double imagR_[2049];
|
y@0
|
124 double realL_[2049];
|
y@0
|
125 double imagL_[2049];
|
y@0
|
126
|
y@0
|
127 // Methods to initialise and de-initialise the FFT machinery
|
y@0
|
128 void initFFT(int length);
|
y@0
|
129 void deinitFFT();
|
y@0
|
130
|
y@0
|
131 // Methods to initialise and de-initialise the window
|
y@0
|
132 void initWindow(int length, int windowType);
|
y@0
|
133 void deinitWindow();
|
y@0
|
134
|
y@0
|
135 // Methods to update the buffering for the given hop size and the output scaling
|
y@0
|
136 void updateHopSize();
|
y@0
|
137 void updateScaleFactor();
|
y@0
|
138
|
y@0
|
139 // Whether the FFT has been initialised and is therefore ready to go
|
y@0
|
140 bool fftInitialised_;
|
y@0
|
141
|
y@0
|
142 // Variables for calculating the FFT and IFFT: complex data structures and the
|
y@0
|
143 // "plan" used by the fftw library to calculate the transforms.
|
y@0
|
144 fftw_complex *fftTimeDomain_, *fftFrequencyDomain_;
|
y@0
|
145 fftw_plan fftForwardPlan_, fftBackwardPlan_;
|
y@0
|
146
|
y@0
|
147 // Size of the FFT (generally a power of two) and the hop size (in samples, generally a fraction of FFT size)
|
y@0
|
148 int fftActualTransformSize_;
|
y@0
|
149 int hopActualSize_;
|
y@0
|
150
|
y@0
|
151 // Amount by which to scale_ the inverse FFT to return to original amplitude: depends on the
|
y@0
|
152 // transform size (because of fftw implementation) and the hop size (because of inherent overlap)
|
y@0
|
153 double fftScaleFactor_;
|
y@0
|
154
|
y@0
|
155 // Circular buffer gathers audio samples from the input until enough are available
|
y@0
|
156 // for the FFT calculation
|
y@0
|
157 AudioSampleBuffer inputBuffer_;
|
y@0
|
158 int inputBufferLength_;
|
y@0
|
159 int inputBufferWritePosition_;
|
y@0
|
160
|
y@0
|
161 // Circular buffer that collects output samples from the FFT overlap-add process
|
y@0
|
162 // before they are ready to be sent to the output stream
|
y@0
|
163 AudioSampleBuffer outputBuffer_;
|
y@0
|
164 int outputBufferLength_;
|
y@0
|
165 int outputBufferReadPosition_, outputBufferWritePosition_;
|
y@0
|
166
|
y@0
|
167 // How many samples since the last FFT?
|
y@0
|
168 int samplesSinceLastFFT_;
|
y@0
|
169
|
y@0
|
170 // Stored window function for pre-processing input frames
|
y@0
|
171 double *windowBuffer_;
|
y@0
|
172 int windowBufferLength_;
|
y@0
|
173
|
y@0
|
174 // Whether or not prepareToPlay() has been called, i.e. that resources are in use
|
y@0
|
175 bool preparedToPlay_;
|
y@0
|
176
|
y@0
|
177 // Spin lock that prevents the FFT settings from changing in the middle of the audio
|
y@0
|
178 // thread.
|
y@0
|
179 SpinLock fftSpinLock_;
|
y@0
|
180
|
y@0
|
181 void changeParams();
|
y@0
|
182
|
y@0
|
183 //==============================================================================
|
y@0
|
184 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ADRessAudioProcessor);
|
y@0
|
185 };
|
y@0
|
186
|
y@0
|
187 #endif // __PLUGINPROCESSOR_H_4693CB6E__
|