openshot-audio  0.1.7
juce_AudioProcessor.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_AUDIOPROCESSOR_H_INCLUDED
26 #define JUCE_AUDIOPROCESSOR_H_INCLUDED
27 
28 
29 //==============================================================================
44 {
45 protected:
46  //==============================================================================
49 
50 public:
52  virtual ~AudioProcessor();
53 
54  //==============================================================================
56  virtual const String getName() const = 0;
57 
58  //==============================================================================
69  virtual void prepareToPlay (double sampleRate,
70  int estimatedSamplesPerBlock) = 0;
71 
75  virtual void releaseResources() = 0;
76 
125  virtual void processBlock (AudioSampleBuffer& buffer,
126  MidiBuffer& midiMessages) = 0;
127 
136  virtual void processBlockBypassed (AudioSampleBuffer& buffer,
137  MidiBuffer& midiMessages);
138 
139  //==============================================================================
155  AudioPlayHead* getPlayHead() const noexcept { return playHead; }
156 
157 
158  //==============================================================================
164  double getSampleRate() const noexcept { return sampleRate; }
165 
175  int getBlockSize() const noexcept { return blockSize; }
176 
177  //==============================================================================
187  int getNumInputChannels() const noexcept { return numInputChannels; }
188 
198  int getNumOutputChannels() const noexcept { return numOutputChannels; }
199 
205  const String& getInputSpeakerArrangement() const noexcept { return inputSpeakerArrangement; }
206 
212  const String& getOutputSpeakerArrangement() const noexcept { return outputSpeakerArrangement; }
213 
214  //==============================================================================
220  virtual const String getInputChannelName (int channelIndex) const = 0;
221 
227  virtual const String getOutputChannelName (int channelIndex) const = 0;
228 
230  virtual bool isInputChannelStereoPair (int index) const = 0;
231 
233  virtual bool isOutputChannelStereoPair (int index) const = 0;
234 
241  int getLatencySamples() const noexcept { return latencySamples; }
242 
248  void setLatencySamples (int newLatency);
249 
251  virtual bool silenceInProducesSilenceOut() const = 0;
252 
254  virtual double getTailLengthSeconds() const = 0;
255 
257  virtual bool acceptsMidi() const = 0;
258 
260  virtual bool producesMidi() const = 0;
261 
262  //==============================================================================
275 
304  void suspendProcessing (bool shouldBeSuspended);
305 
309  bool isSuspended() const noexcept { return suspended; }
310 
316  virtual void reset();
317 
318  //==============================================================================
329  bool isNonRealtime() const noexcept { return nonRealtime; }
330 
334  virtual void setNonRealtime (bool isNonRealtime) noexcept;
335 
336  //==============================================================================
364  virtual AudioProcessorEditor* createEditor() = 0;
365 
369  virtual bool hasEditor() const = 0;
370 
371  //==============================================================================
376 
380  AudioProcessorEditor* createEditorIfNeeded();
381 
382  //==============================================================================
389  virtual int getNumParameters();
390 
396  virtual const String getParameterName (int parameterIndex);
397 
409  virtual float getParameter (int parameterIndex);
410 
421  virtual String getParameterName (int parameterIndex, int maximumStringLength);
422 
427  virtual const String getParameterText (int parameterIndex);
428 
439  virtual String getParameterText (int parameterIndex, int maximumStringLength);
440 
450  virtual int getParameterNumSteps (int parameterIndex);
451 
458  static int getDefaultNumParameterSteps() noexcept;
459 
467  virtual float getParameterDefaultValue (int parameterIndex);
468 
475  virtual String getParameterLabel (int index) const;
476 
483  virtual bool isParameterOrientationInverted (int index) const;
484 
501  virtual void setParameter (int parameterIndex, float newValue);
502 
516  void setParameterNotifyingHost (int parameterIndex, float newValue);
517 
524  virtual bool isParameterAutomatable (int parameterIndex) const;
525 
534  virtual bool isMetaParameter (int parameterIndex) const;
535 
547  void beginParameterChangeGesture (int parameterIndex);
548 
559  void endParameterChangeGesture (int parameterIndex);
560 
566  void updateHostDisplay();
567 
568  //==============================================================================
573  void addParameter (AudioProcessorParameter*);
574 
576  const OwnedArray<AudioProcessorParameter>& getParameters() const noexcept;
577 
578  //==============================================================================
586  virtual int getNumPrograms() = 0;
587 
589  virtual int getCurrentProgram() = 0;
590 
592  virtual void setCurrentProgram (int index) = 0;
593 
595  virtual const String getProgramName (int index) = 0;
596 
598  virtual void changeProgramName (int index, const String& newName) = 0;
599 
600  //==============================================================================
613  virtual void getStateInformation (juce::MemoryBlock& destData) = 0;
614 
626  virtual void getCurrentProgramStateInformation (juce::MemoryBlock& destData);
627 
638  virtual void setStateInformation (const void* data, int sizeInBytes) = 0;
639 
649  virtual void setCurrentProgramStateInformation (const void* data, int sizeInBytes);
650 
652  virtual void numChannelsChanged();
653 
654  //==============================================================================
656  virtual void addListener (AudioProcessorListener* newListener);
657 
659  virtual void removeListener (AudioProcessorListener* listenerToRemove);
660 
661  //==============================================================================
666  virtual void setPlayHead (AudioPlayHead* newPlayHead);
667 
668  //==============================================================================
670  void setPlayConfigDetails (int numIns, int numOuts, double sampleRate, int blockSize) noexcept;
671 
672  //==============================================================================
674  void editorBeingDeleted (AudioProcessorEditor*) noexcept;
675 
677  void setSpeakerArrangement (const String& inputs, const String& outputs);
678 
681  {
682  wrapperType_Undefined = 0,
688  wrapperType_Standalone
689  };
690 
695 
696  //==============================================================================
705  static void copyXmlToBinary (const XmlElement& xml,
706  juce::MemoryBlock& destData);
707 
713  static XmlElement* getXmlFromBinary (const void* data, int sizeInBytes);
714 
716  static void JUCE_CALLTYPE setTypeOfNextNewPlugin (WrapperType);
717 
718 protected:
721 
723  void sendParamChangeMessageToListeners (int parameterIndex, float newValue);
724 
725 private:
728  double sampleRate;
729  int blockSize, numInputChannels, numOutputChannels, latencySamples;
730  bool suspended, nonRealtime;
731  CriticalSection callbackLock, listenerLock;
732  String inputSpeakerArrangement, outputSpeakerArrangement;
733 
734  OwnedArray<AudioProcessorParameter> managedParameters;
735  AudioProcessorParameter* getParamChecked (int) const noexcept;
736 
737  #if JUCE_DEBUG && ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
738  BigInteger changingParams;
739  #endif
740 
741  AudioProcessorListener* getListenerLocked (int) const noexcept;
742 
744 };
745 
746 
747 #endif // JUCE_AUDIOPROCESSOR_H_INCLUDED
Definition: juce_AudioSampleBuffer.h:34
WrapperType wrapperType
Definition: juce_AudioProcessor.h:694
CriticalSection callbackLock
Definition: juce_mac_CoreMidi.cpp:258
Definition: juce_BigInteger.h:43
Definition: juce_AudioProcessor.h:687
AudioPlayHead * playHead
Definition: juce_AudioProcessor.h:720
#define noexcept
Definition: juce_CompilerSupport.h:141
double getSampleRate() const noexcept
Definition: juce_AudioProcessor.h:164
Definition: juce_AudioProcessorEditor.h:38
const String & getOutputSpeakerArrangement() const noexcept
Definition: juce_AudioProcessor.h:212
Definition: juce_MemoryBlock.h:38
int getNumInputChannels() const noexcept
Definition: juce_AudioProcessor.h:187
#define JUCE_CALLTYPE
Definition: juce_PlatformDefs.h:50
Definition: juce_String.h:43
Definition: juce_AudioProcessor.h:683
#define JUCE_API
Definition: juce_StandardHeader.h:139
#define const
JOCTET * buffer
Definition: juce_JPEGLoader.cpp:302
Definition: juce_CriticalSection.h:47
int getNumOutputChannels() const noexcept
Definition: juce_AudioProcessor.h:198
Definition: juce_AudioPlayHead.h:39
Definition: juce_XmlElement.h:142
Definition: juce_AudioProcessor.h:686
WrapperType
Definition: juce_AudioProcessor.h:680
AudioPlayHead * getPlayHead() const noexcept
Definition: juce_AudioProcessor.h:155
bool isSuspended() const noexcept
Definition: juce_AudioProcessor.h:309
int getLatencySamples() const noexcept
Definition: juce_AudioProcessor.h:241
const CriticalSection & getCallbackLock() const noexcept
Definition: juce_AudioProcessor.h:274
Definition: juce_AudioProcessor.h:685
int getBlockSize() const noexcept
Definition: juce_AudioProcessor.h:175
Definition: juce_OwnedArray.h:55
Definition: juce_AudioProcessorListener.h:37
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
Definition: juce_PlatformDefs.h:198
Definition: juce_AudioProcessor.h:43
bool isNonRealtime() const noexcept
Definition: juce_AudioProcessor.h:329
JSAMPIMAGE data
Definition: jpeglib.h:945
Definition: juce_MidiBuffer.h:43
Definition: juce_core.h:39
Definition: juce_AudioProcessor.h:684
const String & getInputSpeakerArrangement() const noexcept
Definition: juce_AudioProcessor.h:205
Definition: juce_AudioProcessorParameter.h:35
AudioProcessorEditor * getActiveEditor() const noexcept
Definition: juce_AudioProcessor.h:375