SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PluginProcessor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef PLUGINPROCESSOR_H_INCLUDED
21 #define PLUGINPROCESSOR_H_INCLUDED
22 
23 #include "../JuceLibraryCode/JuceHeader.h"
24 #include "Source.h"
25 #include "JuceConnectionTimer.h"
26 #include "SourceController.h"
27 #include "VSReceiver.h"
28 #include "XmlFactory.h"
29 
30 
31 #define NUMSTEPS(min, max, prec) ( (int) (((max)-(min))/(prec)) + 1)
32 
33 
34 //==============================================================================
42 class SpaopAudioProcessor : public AudioProcessor,
44 {
45 public:
46  //==============================================================================
49 
52 
53  //==============================================================================
54  // vvvvv Methods inherited from juce::AudioProcessor:
55 
57  void prepareToPlay (double sampleRate, int samplesPerBlock);
58 
60  void releaseResources();
61 
63  void processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages);
64 
65  //==============================================================================
66 
68  AudioProcessorEditor* createEditor();
69 
71  bool hasEditor() const;
72 
73  //==============================================================================
75  const String getName() const;
76 
82  int getNumParameters();
83 
90  float getParameter (int index);
91 
97  void setParameter (int index, float newValue);
98 
106  float getParameterByText(int parameterIndex, const String& parameterText);
107 
114  const String getParameterName (int index);
115 
122  const String getParameterText (int index);
123 
131  const String getParameterTextByValue (int index, float value);
132 
133  int getParameterNumSteps(int index);
134 
140  float getParameterDefaultValue (int index);
141 
143  const String getInputChannelName (int channelIndex) const;
144 
146  const String getOutputChannelName (int channelIndex) const;
147 
149  bool isInputChannelStereoPair (int index) const;
150 
152  bool isOutputChannelStereoPair (int index) const;
153 
155  bool acceptsMidi() const;
156 
158  bool producesMidi() const;
159 
161  bool silenceInProducesSilenceOut() const;
162 
164  double getTailLengthSeconds() const;
165 
166  //==============================================================================
167 
172  int getNumPrograms();
173 
178  int getCurrentProgram();
179 
184  void setCurrentProgram (int index);
185 
190  const String getProgramName (int index);
191 
196  void changeProgramName (int index, const String& newName);
197 
198  //==============================================================================
199 
206  void getStateInformation (MemoryBlock& destData);
207 
214  void setStateInformation (const void* data, int sizeInBytes);
215 
216  // ^^^^^ juce::AudioProcessor methods end here.
217  //==============================================================================
218  //==============================================================================
219  // vvvvv Non-juce::AudioProcessor methods:
220 
233  void setCoordinates(float normalizedX, float normalizedY);
234 
247  void setCoordinatesNotifyingHost(float normalizedX, float normalizedY);
248 
253  void timerCallback();
254 
261 
268  float getZoomFactor() const;
269 
276  void setZoomFactor(float zoomFactor);
277 
284  bool showOtherSources() const;
285 
292  void setShowOtherSources(bool showOtherSources);
293 
300  bool showNames() const;
301 
308  void setShowNames(bool showNames);
309 
320  bool setCWonderAddress(const std::string &ip, const std::string &port);
321 
322 private:
323  //==============================================================================
324  ScopedPointer<wonder::SourceController> sourceController_;
325 
326  // GUI parameters that need to be stored:
327  float zoomFactor_;
328  bool showOtherSources_;
329  bool showNames_;
330 
331  //==============================================================================
332  //vvvvv Implementing SourceControl::Listener
333 
334  void incomingParameterChange (wonder::Source::AutomatedParameters index,
335  float newValue);
336 
337  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpaopAudioProcessor)
338 };
339 
340 #endif // PLUGINPROCESSOR_H_INCLUDED
void setShowOtherSources(bool showOtherSources)
Set the GUI's showOtherSources parameter (As this parameters shall be restorable via getStateInformat...
Definition: PluginProcessor.cpp:340
const String getName() const
Definition: PluginProcessor.cpp:41
bool acceptsMidi() const
Definition: PluginProcessor.cpp:131
int getNumParameters()
Returns the number of automatable parameters of this plugin.
Definition: PluginProcessor.cpp:46
bool showOtherSources() const
Returns true if the GUI shall show all active sources.
Definition: PluginProcessor.cpp:335
int getNumPrograms()
Returns 0.
Definition: PluginProcessor.cpp:159
void setZoomFactor(float zoomFactor)
Sets the zoom factor for the GUI.
Definition: PluginProcessor.cpp:330
void getStateInformation(MemoryBlock &destData)
Stores the current state of the plugin (including the state of the source controlled by this plugin) ...
Definition: PluginProcessor.cpp:221
void timerCallback()
Callback from the timer.
const String getParameterName(int index)
Forwards the call to the wonder::Source::getParameterName method of the source controlled by this plu...
Definition: PluginProcessor.cpp:68
float getParameter(int index)
Forwards the call to the wonder::Source::getParameter method of the source controlled by this plugin...
Definition: PluginProcessor.cpp:51
const String getProgramName(int index)
Returns an empty juce::String.
Definition: PluginProcessor.cpp:173
~SpaopAudioProcessor()
Destructor.
Definition: PluginProcessor.cpp:36
bool setCWonderAddress(const std::string &ip, const std::string &port)
Sets the address where outgoing OSC messages will be sent in "linked to WONDER" mode will be sent (i...
Definition: PluginProcessor.cpp:355
void setShowNames(bool showNames)
Set the GUI's showNames parameter (As this parameters shall be restorable via getStateInformation and...
Definition: PluginProcessor.cpp:350
const String getParameterText(int index)
Forwards the call to the wonder::Source::getParameterText method of the source controlled by this plu...
Definition: PluginProcessor.cpp:73
void changeProgramName(int index, const String &newName)
Does nothing.
Definition: PluginProcessor.cpp:178
bool isInputChannelStereoPair(int index) const
Definition: PluginProcessor.cpp:121
void setCoordinatesNotifyingHost(float normalizedX, float normalizedY)
Sets the coordinates, notifying both the host and the OSC-messaging.
Definition: PluginProcessor.cpp:307
wonder::SourceController * getSourceController() const
Returns a pointer to the wonder::SourceController object that contains the main logic and the communi...
Definition: PluginProcessor.cpp:314
const String getOutputChannelName(int channelIndex) const
Definition: PluginProcessor.cpp:116
float getZoomFactor() const
Returns the zoom factor for the GUI.
Definition: PluginProcessor.cpp:325
void setCoordinates(float normalizedX, float normalizedY)
Sets the coordinates, sending the corresponding OSC-message.
Definition: PluginProcessor.cpp:302
bool producesMidi() const
Definition: PluginProcessor.cpp:140
int getCurrentProgram()
Returns 0.
Definition: PluginProcessor.cpp:164
SpaopAudioProcessor()
Constructor.
Definition: PluginProcessor.cpp:25
void releaseResources()
Definition: PluginProcessor.cpp:189
double getTailLengthSeconds() const
Definition: PluginProcessor.cpp:154
AutomatedParameters
Parameters that can be automated by the host must be accessed using this enum.
Definition: Source.h:81
void setParameter(int index, float newValue)
Forwards the call to the wonder::SourceController::setParameterAndSendChange.
Definition: PluginProcessor.cpp:56
const String getParameterTextByValue(int index, float value)
Forwards the call to the wonder::Source::getParameterTextByValue method of the source controlled by t...
Definition: PluginProcessor.cpp:78
void processBlock(AudioSampleBuffer &buffer, MidiBuffer &midiMessages)
Definition: PluginProcessor.cpp:195
float getParameterDefaultValue(int index)
Forwards the call to wonder::Source::getParameterDefaultValue.
Definition: PluginProcessor.cpp:83
float getParameterByText(int parameterIndex, const String &parameterText)
Forwards the call to the wonder::Source::getParameterByText method of the source controlled by this p...
Definition: PluginProcessor.cpp:61
int getParameterNumSteps(int index)
Definition: PluginProcessor.cpp:88
bool silenceInProducesSilenceOut() const
Definition: PluginProcessor.cpp:149
An interface for a listener that listens to various callbacks triggered by incoming messages or conne...
Definition: SourceController.h:51
void setStateInformation(const void *data, int sizeInBytes)
Retores the a state of the plugin (including the state of the source controlled by this plugin) from ...
Definition: PluginProcessor.cpp:250
The SPAOP-plugin's processor class.
Definition: PluginProcessor.h:42
void prepareToPlay(double sampleRate, int samplesPerBlock)
Definition: PluginProcessor.cpp:183
void setCurrentProgram(int index)
Does nothing.
Definition: PluginProcessor.cpp:169
const String getInputChannelName(int channelIndex) const
Definition: PluginProcessor.cpp:111
bool hasEditor() const
Definition: PluginProcessor.cpp:210
AudioProcessorEditor * createEditor()
Definition: PluginProcessor.cpp:215
bool showNames() const
Returns true if the GUI shall the sources' names.
Definition: PluginProcessor.cpp:345
The main communication node that keeps track of all virtual sources and enables the host DAW to contr...
Definition: SourceController.h:42
bool isOutputChannelStereoPair(int index) const
Definition: PluginProcessor.cpp:126