71 :
AudioProcessor (busesPropertiesFromLayoutArray (layoutListToArray (channelLayoutList)))
77 enum ProcessingPrecision
89 using ChangeDetails = AudioProcessorListener::ChangeDetails;
93 virtual ~AudioProcessor();
106 virtual StringArray getAlternateDisplayNames()
const;
128 int maximumExpectedSamplesPerBlock) = 0;
315 template <
typename This>
316 static auto& getBuses (This& t,
bool isInput) {
return isInput ? t.inputBuses : t.outputBuses; }
325 auto& getBuses (
bool isInput)
const {
return getBuses (*
this, isInput); }
326 auto& getBuses (
bool isInput) {
return getBuses (*
this, isInput); }
331 auto& bus = getBuses (isInput);
332 return isPositiveAndBelow (busIndex, bus.size()) ? bus.getReference (busIndex).size() : 0;
338 return getBuses (isInput).getReference (busIndex);
344 return getBuses (isInput)[busIndex];
359 bool operator== (
const BusesLayout& other)
const noexcept {
return inputBuses == other.inputBuses && outputBuses == other.outputBuses; }
360 bool operator!= (
const BusesLayout& other)
const noexcept {
return inputBuses != other.inputBuses || outputBuses != other.outputBuses; }
374 bool isInput()
const noexcept;
377 int getBusIndex()
const noexcept;
380 bool isMain() const noexcept {
return getBusIndex() == 0; }
423 bool setNumberOfChannels (
int channels);
440 bool isNumberOfChannelsSupported (
int channels)
const;
448 int getMaxSupportedChannels (
int limit = AudioChannelSet::maxChannelsOfNamedLayout)
const;
462 bool isEnabled() const noexcept {
return ! layout.isDisabled(); }
466 bool enable (
bool shouldEnable =
true);
476 int getChannelIndexInProcessBlockBuffer (
int channelIndex)
const noexcept;
483 template <
typename FloatType>
486 auto di = getDirectionAndIndex();
487 return owner.getBusBuffer (processBlockBuffer, di.isInput, di.index);
494 struct BusDirectionAndIndex
500 BusDirectionAndIndex getDirectionAndIndex() const noexcept;
501 void updateChannelCount() noexcept;
506 bool enabledByDefault;
507 int cachedChannelCount;
514 int getBusCount (
bool isInput) const noexcept {
return (isInput ? inputBuses : outputBuses).size(); }
519 Bus*
getBus (
bool isInput,
int busIndex)
noexcept {
return getBusImpl (*
this, isInput, busIndex); }
524 const Bus*
getBus (
bool isInput,
int busIndex)
const noexcept {
return getBusImpl (*
this, isInput, busIndex); }
537 virtual bool canAddBus (
bool isInput)
const;
550 virtual bool canRemoveBus (
bool isInput)
const;
566 bool addBus (
bool isInput);
584 bool removeBus (
bool isInput);
594 bool setBusesLayout (
const BusesLayout&);
603 bool setBusesLayoutWithoutEnabling (
const BusesLayout&);
606 BusesLayout getBusesLayout()
const;
613 AudioChannelSet getChannelLayoutOfBus (
bool isInput,
int busIndex)
const noexcept;
620 bool setChannelLayoutOfBus (
bool isInput,
int busIndex,
const AudioChannelSet& layout);
628 if (
auto* bus = getBus (isInput, busIndex))
629 return bus->getNumberOfChannels();
635 bool enableAllBuses();
638 bool disableNonMainBuses();
645 int getChannelIndexInProcessBlockBuffer (
bool isInput,
int busIndex,
int channelIndex)
const noexcept;
653 int getOffsetInBusBufferForAbsoluteChannelIndex (
bool isInput,
int absoluteChannelIndex,
int& busIndex)
const noexcept;
659 template <
typename FloatType>
662 auto busNumChannels = getChannelCountOfBus (isInput, busIndex);
663 auto channelOffset = getChannelIndexInProcessBlockBuffer (isInput, busIndex, 0);
673 bool checkBusesLayoutSupported (
const BusesLayout&)
const;
684 virtual bool supportsDoublePrecisionProcessing()
const;
710 void setProcessingPrecision (ProcessingPrecision newPrecision)
noexcept;
780 return containsLayout (layouts, layoutListToArray (channelLayoutList));
783 template <
size_t numLayouts>
784 static bool containsLayout (
const BusesLayout& layouts,
const short (&channelLayoutList) [numLayouts][2])
786 return containsLayout (layouts, layoutListToArray (channelLayoutList));
800 template <
size_t numLayouts>
802 const short (&channelLayoutList) [numLayouts][2])
804 return getNextBestLayoutInList (layouts, layoutListToArray (channelLayoutList));
841 void setLatencySamples (
int newLatency);
900 void suspendProcessing (
bool shouldBeSuspended);
912 virtual void reset();
954 return isNonRealtime() ? Realtime::no : Realtime::yes;
960 virtual void setNonRealtime (
bool isNonRealtime)
noexcept;
1020 static
int getDefaultNumParameterSteps() noexcept;
1065 virtual
void refreshParameterList();
1078 virtual
int getNumPrograms() = 0;
1081 virtual
int getCurrentProgram() = 0;
1084 virtual
void setCurrentProgram (
int index) = 0;
1087 virtual const
String getProgramName (
int index) = 0;
1090 virtual
void changeProgramName (
int index, const
String& newName) = 0;
1118 virtual
void getCurrentProgramStateInformation (
juce::
MemoryBlock& destData);
1130 virtual
void setStateInformation (const
void* data,
int sizeInBytes) = 0;
1141 virtual
void setCurrentProgramStateInformation (const
void* data,
int sizeInBytes);
1144 virtual
void numChannelsChanged();
1147 virtual
void numBusesChanged();
1150 virtual
void processorLayoutsChanged();
1170 void setPlayConfigDetails (
int numIns,
int numOuts,
double sampleRate,
int blockSize);
1178 void setRateAndBufferSizeDetails (
double sampleRate,
int blockSize) noexcept;
1188 virtual
void audioWorkgroupContextChanged ([[maybe_unused]] const
AudioWorkgroup& workgroup) {}
1223 enum class Type :
int
1239 String xMeterID, yMeterID;
1242 virtual CurveData getResponseCurve (CurveData::Type )
const {
return {}; }
1246 void editorBeingDeleted (AudioProcessorEditor*)
noexcept;
1251 wrapperType_Undefined = 0,
1254 wrapperType_AudioUnit,
1255 wrapperType_AudioUnitv3,
1257 wrapperType_Standalone,
1295 virtual void updateTrackProperties (
const TrackProperties& properties);
1306 static void copyXmlToBinary (
const XmlElement& xml,
1369 virtual bool applyBusLayouts (
const BusesLayout& layouts);
1394 void addBus (
bool isInput,
const String& name,
const AudioChannelSet& defaultLayout,
bool isActivatedByDefault =
true);
1424 virtual bool canApplyBusCountChange (
bool isInput,
bool isAddingBuses,
1432 void sendParamChangeMessageToListeners (
int parameterIndex,
float newValue);
1438 [[deprecated]]
virtual int getNumParameters();
1439 [[deprecated]]
virtual const String getParameterName (
int parameterIndex);
1440 [[deprecated]]
virtual String getParameterID (
int index);
1441 [[deprecated]]
virtual float getParameter (
int parameterIndex);
1442 [[deprecated]]
virtual String getParameterName (
int parameterIndex,
int maximumStringLength);
1443 [[deprecated]]
virtual const String getParameterText (
int parameterIndex);
1444 [[deprecated]]
virtual String getParameterText (
int parameterIndex,
int maximumStringLength);
1445 [[deprecated]]
virtual int getParameterNumSteps (
int parameterIndex);
1446 [[deprecated]]
virtual bool isParameterDiscrete (
int parameterIndex)
const;
1447 [[deprecated]]
virtual float getParameterDefaultValue (
int parameterIndex);
1448 [[deprecated]]
virtual String getParameterLabel (
int index)
const;
1449 [[deprecated]]
virtual bool isParameterOrientationInverted (
int index)
const;
1450 [[deprecated]]
virtual void setParameter (
int parameterIndex,
float newValue);
1451 [[deprecated]]
virtual bool isParameterAutomatable (
int parameterIndex)
const;
1452 [[deprecated]]
virtual bool isMetaParameter (
int parameterIndex)
const;
1454 [[deprecated]]
void beginParameterChangeGesture (
int parameterIndex);
1455 [[deprecated]]
void endParameterChangeGesture (
int parameterIndex);
1456 [[deprecated]]
void setParameterNotifyingHost (
int parameterIndex,
float newValue);
1460 [[deprecated]]
int getNumInputChannels() const noexcept {
return getTotalNumInputChannels(); }
1461 [[deprecated]]
int getNumOutputChannels() const noexcept {
return getTotalNumOutputChannels(); }
1462 [[deprecated]]
const String getInputSpeakerArrangement() const noexcept {
return cachedInputSpeakerArrString; }
1463 [[deprecated]]
const String getOutputSpeakerArrangement() const noexcept {
return cachedOutputSpeakerArrString; }
1464 [[deprecated]]
virtual const String getInputChannelName (
int channelIndex)
const;
1465 [[deprecated]]
virtual const String getOutputChannelName (
int channelIndex)
const;
1466 [[deprecated]]
virtual bool isInputChannelStereoPair (
int index)
const;
1467 [[deprecated]]
virtual bool isOutputChannelStereoPair (
int index)
const;
1472 struct InOutChannelPair
1474 InOutChannelPair() =
default;
1476 InOutChannelPair (int16 inCh, int16 outCh) noexcept : inChannels (inCh), outChannels (outCh) {}
1477 InOutChannelPair (
const int16 (&config)[2]) noexcept : inChannels (config[0]), outChannels (config[1]) {}
1479 bool operator== (
const InOutChannelPair& other)
const noexcept
1481 return other.inChannels == inChannels && other.outChannels == outChannels;
1484 int16 inChannels = 0, outChannels = 0;
1487 template <
size_t numLayouts>
1488 static Array<InOutChannelPair> layoutListToArray (
const short (&configuration) [numLayouts][2])
1490 Array<InOutChannelPair> layouts;
1492 for (
size_t i = 0; i < numLayouts; ++i)
1493 layouts.add (InOutChannelPair (configuration[(
int) i]));
1498 static Array<InOutChannelPair> layoutListToArray (
const std::initializer_list<
const short[2]>& configuration)
1500 Array<InOutChannelPair> layouts;
1502 for (
auto&& i : configuration)
1503 layouts.add (InOutChannelPair (i));
1508 template <
typename This>
1509 static auto getBusImpl (This& t,
bool isInput,
int busIndex) ->
decltype (t.getBus (isInput, busIndex))
1511 return (isInput ? t.inputBuses : t.outputBuses)[busIndex];
1515 static BusesProperties busesPropertiesFromLayoutArray (
const Array<InOutChannelPair>&);
1517 BusesLayout getNextBestLayoutInList (
const BusesLayout&,
const Array<InOutChannelPair>&)
const;
1518 static bool containsLayout (
const BusesLayout&,
const Array<InOutChannelPair>&);
1521 void createBus (
bool isInput,
const BusProperties&);
1524 Array<AudioProcessorListener*> listeners;
1525 Component::SafePointer<AudioProcessorEditor> activeEditor;
1526 double currentSampleRate = 0;
1527 int blockSize = 0, latencySamples = 0;
1528 bool suspended =
false;
1530 ProcessingPrecision processingPrecision = singlePrecision;
1531 CriticalSection callbackLock, listenerLock, activeEditorLock;
1534 mutable OwnedArray<Bus> inputBuses, outputBuses;
1536 String cachedInputSpeakerArrString, cachedOutputSpeakerArrString;
1537 int cachedTotalIns = 0, cachedTotalOuts = 0;
1539 AudioProcessorParameterGroup parameterTree;
1540 Array<AudioProcessorParameter*> flatParameterList;
1542 AudioProcessorParameter* getParamChecked (
int)
const;
1545 #if ! JUCE_DISABLE_AUDIOPROCESSOR_BEGIN_END_GESTURE_CHECKING
1546 BigInteger changingParams;
1549 bool textRecursionCheck =
false;
1551 #if ! JUCE_DISABLE_CAUTIOUS_PARAMETER_ID_CHECKING
1556 void checkForDuplicateTrimmedParamID (AudioProcessorParameter*);
1557 void validateParameter (AudioProcessorParameter*);
1558 void checkForDuplicateParamID (AudioProcessorParameter*);
1559 void checkForDuplicateGroupIDs (
const AudioProcessorParameterGroup&);
1561 AudioProcessorListener* getListenerLocked (
int)
const noexcept;
1562 void updateSpeakerFormatStrings();
1563 void audioIOChanged (
bool busNumberChanged,
bool channelNumChanged);
1564 void getNextBestLayout (
const BusesLayout&, BusesLayout&)
const;
1566 template <
typename floatType>
1567 void processBypassed (AudioBuffer<floatType>&, MidiBuffer&);
1569 friend class AudioProcessorParameter;
1570 friend class LADSPAPluginInstance;
1572 [[deprecated (
"This method is no longer used - you can delete it from your AudioProcessor classes.")]]
1573 virtual bool silenceInProducesSilenceOut()
const {
return false; }
Holds a resizable array of primitive or copy-by-value objects.
A multi-channel buffer containing floating point audio samples.
int getNumSamples() const noexcept
Returns the number of samples allocated in each of the buffer's channels.
Type *const * getArrayOfWritePointers() noexcept
Returns an array of pointers to the channels in the buffer.
Represents a set of audio channel types.
A subclass of AudioPlayHead can supply information about the position and status of a moving play hea...
Base class for the component that acts as the GUI for an AudioProcessor.
Base class for listeners that want to know about changes to an AudioProcessor.
A class encapsulating a group of AudioProcessorParameters and nested AudioProcessorParameterGroups.
An abstract base class for parameter objects that can be added to an AudioProcessor.
Describes the layout and properties of an audio bus.
const AudioChannelSet & getCurrentLayout() const noexcept
The bus's current layout.
const AudioChannelSet & getDefaultLayout() const noexcept
Get the default layout of this bus.
int getNumberOfChannels() const noexcept
Return the number of channels of the current bus.
const String & getName() const noexcept
The bus's name.
bool isEnabledByDefault() const noexcept
Returns if this bus is enabled by default.
AudioBuffer< FloatType > getBusBuffer(AudioBuffer< FloatType > &processBlockBuffer) const
Returns an AudioBuffer containing a set of channel pointers for a specific bus.
bool isMain() const noexcept
Returns true if the current bus is the main input or output bus.
bool isEnabled() const noexcept
Returns true if the current bus is enabled.
const AudioChannelSet & getLastEnabledLayout() const noexcept
Return the bus's last active channel layout.
Base class for audio processing classes or plugins.
virtual bool canApplyBusesLayout(const BusesLayout &layouts) const
Callback to check if a certain bus layout can now be applied.
int getTotalNumInputChannels() const noexcept
Returns the total number of input channels.
bool isNonRealtime() const noexcept
Returns true if the processor is being run in an offline mode for rendering.
virtual AAXClientExtensions & getAAXClientExtensions()
Returns a reference to an object that implements AAX specific information regarding this AudioProcess...
virtual bool acceptsMidi() const =0
Returns true if the processor wants MIDI messages.
WrapperType
Flags to indicate the type of plugin context in which a processor is being used.
Bus * getBus(bool isInput, int busIndex) noexcept
Returns the audio bus with a given index and direction.
bool isUsingDoublePrecision() const noexcept
Returns true if the current precision is set to doublePrecision.
const WrapperType wrapperType
When loaded by a plugin wrapper, this flag will be set to indicate the type of plugin within which th...
int getLatencySamples() const noexcept
This returns the number of samples delay that the processor imposes on the audio passing through it.
virtual void memoryWarningReceived()
Called by the host to indicate that you should reduce your memory footprint.
ProcessingPrecision getProcessingPrecision() const noexcept
Returns the precision-mode of the processor.
AudioChannelSet defaultLayout
The default layout of the bus.
virtual void prepareToPlay(double sampleRate, int maximumExpectedSamplesPerBlock)=0
Called before playback starts, to let the processor prepare itself.
virtual AudioProcessorParameter * getBypassParameter() const
Returns the parameter that controls the AudioProcessor's bypass state.
virtual AudioProcessorEditor * createEditor()=0
Creates the processor's GUI.
AudioProcessor(const std::initializer_list< const short[2]> &channelLayoutList)
Constructor for AudioProcessors which use layout maps If your AudioProcessor uses layout maps then us...
BusesLayout getNextBestLayoutInLayoutList(const BusesLayout &layouts, const short(&channelLayoutList)[numLayouts][2])
Returns the next best layout which is contained in a channel layout map.
Realtime isRealtime() const noexcept
Returns no if the processor is being run in an offline mode for rendering.
virtual void processBlock(AudioBuffer< float > &buffer, MidiBuffer &midiMessages)=0
Renders the next block.
bool isActivatedByDefault
Is this bus activated by default?
const CriticalSection & getCallbackLock() const noexcept
This returns a critical section that will automatically be locked while the host is calling the proce...
virtual const String getName() const =0
Returns the name of this processor.
bool isSuspended() const noexcept
Returns true if processing is currently suspended.
int getChannelCountOfBus(bool isInput, int busIndex) const noexcept
Provides the number of channels of the bus with a given index and direction.
virtual bool hasEditor() const =0
Your processor subclass must override this and return true if it can create an editor component.
static bool containsLayout(const BusesLayout &layouts, const std::initializer_list< const short[2]> &channelLayoutList)
Returns true if the channel layout map contains a certain layout.
virtual bool supportsMPE() const
Returns true if the processor supports MPE.
virtual double getTailLengthSeconds() const =0
Returns the length of the processor's tail, in seconds.
virtual bool isBusesLayoutSupported(const BusesLayout &) const
Callback to query if the AudioProcessor supports a specific layout.
double getSampleRate() const noexcept
Returns the current sample rate.
String busName
The name of the bus.
int getTotalNumOutputChannels() const noexcept
Returns the total number of output channels.
virtual bool producesMidi() const =0
Returns true if the processor produces MIDI messages.
AudioPlayHead * getPlayHead() const noexcept
Returns the current AudioPlayHead object that should be used to find out the state and position of th...
virtual bool isMidiEffect() const
Returns true if this is a MIDI effect plug-in and does no audio processing.
int getMainBusNumInputChannels() const noexcept
Returns the number of input channels on the main bus.
int getMainBusNumOutputChannels() const noexcept
Returns the number of output channels on the main bus.
int getBlockSize() const noexcept
Returns the current typical block size that is being used.
AudioBuffer< FloatType > getBusBuffer(AudioBuffer< FloatType > &processBlockBuffer, bool isInput, int busIndex) const
Returns an AudioBuffer containing a set of channel pointers for a specific bus.
const Bus * getBus(bool isInput, int busIndex) const noexcept
Returns the audio bus with a given index and direction.
virtual void releaseResources()=0
Called after playback has stopped, to let the object free up any resources it no longer needs.
Structure used for AudioProcessor Callbacks.
A struct containing information about the DAW track inside which your AudioProcessor is loaded.
A handle to an audio workgroup, which is a collection of realtime threads working together to produce...
Represents a colour, also including a transparency value.
A class to hold a resizable block of raw data.
Holds a sequence of time-stamped midi events.
A general-purpose range object, that simply represents any linear range with a start and end point.
A special array for holding a list of strings.
Used to build a tree of elements representing an XML document.
bool isPositiveAndBelow(Type1 valueToTest, Type2 upperLimit) noexcept
Returns true if a value is at least zero, and also below a specified upper limit.
An interface to allow an AudioProcessor to implement extended AAX-specific functionality.
Provides details about aspects of an AudioProcessor which have changed.
Represents the bus layout state of a plug-in.
int getMainInputChannels() const noexcept
Get the number of input channels on the main bus.
AudioChannelSet getMainInputChannelSet() const noexcept
Get the input channel layout on the main bus.
AudioChannelSet getMainOutputChannelSet() const noexcept
Get the output channel layout on the main bus.
Array< AudioChannelSet > outputBuses
An array containing the list of output buses that this processor supports.
AudioChannelSet getChannelSet(bool isInput, int busIndex) const noexcept
Get the channel set of a particular bus.
int getMainOutputChannels() const noexcept
Get the number of output channels on the main bus.
int getNumChannels(bool isInput, int busIndex) const noexcept
Get the number of channels of a particular bus.
Array< AudioChannelSet > inputBuses
An array containing the list of input buses that this processor supports.
AudioChannelSet & getChannelSet(bool isInput, int busIndex) noexcept
Get the channel set of a particular bus.
Structure used for AudioProcessor Callbacks.
Array< BusProperties > outputLayouts
The layouts of the output buses.
Array< BusProperties > inputLayouts
The layouts of the input buses.
Some plug-ins support sharing response curve data with the host so that it can display this curve on ...
An interface to allow an AudioProcessor to implement extended VST2-specific functionality.
An interface to allow an AudioProcessor to implement extended VST3-specific functionality.