JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::StandalonePluginHolder Class Reference

An object that creates and plays a standalone instance of an AudioProcessor. More...

#include <juce_StandaloneFilterWindow.h>

Inheritance diagram for juce::StandalonePluginHolder:
Collaboration diagram for juce::StandalonePluginHolder:

Classes

class  CallbackMaxSizeEnforcer
 
struct  PluginInOuts
 Structure used for the number of inputs and outputs. More...
 
class  SettingsComponent
 

Public Member Functions

 StandalonePluginHolder (PropertySet *settingsToUse, bool takeOwnershipOfSettings=true, const String &preferredDefaultDeviceName=String(), const AudioDeviceManager::AudioDeviceSetup *preferredSetupOptions=nullptr, const Array< PluginInOuts > &channels=Array< PluginInOuts >(), bool shouldAutoOpenMidiDevices=true)
 Creates an instance of the default plugin. More...
 
 ~StandalonePluginHolder () override
 
void askUserToLoadState (const String &fileSuffix=String())
 Pops up a dialog letting the user re-load the processor's state from a file. More...
 
void askUserToSaveState (const String &fileSuffix=String())
 Pops up a dialog letting the user save the processor's state to a file. More...
 
virtual void createPlugin ()
 
virtual void deletePlugin ()
 
Image getIAAHostIcon (int size)
 
File getLastFile () const
 
ValuegetMuteInputValue ()
 
int getNumInputChannels () const
 
int getNumOutputChannels () const
 
bool getProcessorHasPotentialFeedbackLoop () const
 
void init (bool enableAudioInput, const String &preferredDefaultDeviceName)
 
bool isInterAppAudioConnected ()
 
void reloadAudioDeviceState (bool enableAudioInput, const String &preferredDefaultDeviceName, const AudioDeviceManager::AudioDeviceSetup *preferredSetupOptions)
 
void reloadPluginState ()
 
void saveAudioDeviceState ()
 
void savePluginState ()
 
void setLastFile (const FileChooser &fc)
 
void showAudioSettingsDialog ()
 Shows an audio properties dialog box modally. More...
 
void startPlaying ()
 
void stopPlaying ()
 
void switchToHostApplication ()
 
void valueChanged (Value &value) override
 Called when a Value object is changed. More...
 

Static Public Member Functions

static String getFilePatterns (const String &fileSuffix)
 
static StandalonePluginHoldergetInstance ()
 

Public Attributes

bool autoOpenMidiDevices
 
Array< PluginInOutschannelConfiguration
 
AudioDeviceManager deviceManager
 
AudioBuffer< floatemptyBuffer
 
Array< MidiDeviceInfolastMidiDevices
 
std::atomic< boolmuteInput { true }
 
std::unique_ptr< AudioDeviceManager::AudioDeviceSetupoptions
 
AudioProcessorPlayer player
 
std::unique_ptr< AudioProcessorprocessor
 
bool processorHasPotentialFeedbackLoop = true
 
OptionalScopedPointer< PropertySetsettings
 
Value shouldMuteInput
 
std::unique_ptr< FileChooserstateFileChooser
 

Private Member Functions

void audioDeviceAboutToStart (AudioIODevice *device) override
 Called to indicate that the device is about to start calling back. More...
 
virtual void audioDeviceError (const String &errorMessage)
 This can be overridden to be told if the device generates an error while operating. More...
 
void audioDeviceIOCallback (const float **inputChannelData, int numInputChannels, float **outputChannelData, int numOutputChannels, int numSamples) override
 Processes a block of incoming and outgoing audio data. More...
 
void audioDeviceStopped () override
 Called to indicate that the device has stopped. More...
 
int getTimerInterval () const noexcept
 Returns the timer's interval. More...
 
bool isTimerRunning () const noexcept
 Returns true if the timer is currently running. More...
 
void setupAudioDevices (bool enableAudioInput, const String &preferredDefaultDeviceName, const AudioDeviceManager::AudioDeviceSetup *preferredSetupOptions)
 
void shutDownAudioDevices ()
 
void startTimer (int intervalInMilliseconds) noexcept
 Starts the timer and sets the length of interval required. More...
 
void startTimerHz (int timerFrequencyHz) noexcept
 Starts the timer with an interval specified in Hertz. More...
 
void stopTimer () noexcept
 Stops the timer. More...
 
void timerCallback () override
 The user-defined callback routine that actually gets called periodically. More...
 

Static Private Member Functions

static void callAfterDelay (int milliseconds, std::function< void()> functionToCall)
 Invokes a lambda after a given number of milliseconds. More...
 
static void callPendingTimersSynchronously ()
 For internal use only: invokes any timers that need callbacks. More...
 

Private Attributes

CallbackMaxSizeEnforcer maxSizeEnforcer { *this }
 
size_t positionInQueue = (size_t) -1
 
int timerPeriodMs = 0
 

Detailed Description

An object that creates and plays a standalone instance of an AudioProcessor.

The object will create your processor using the same createPluginFilter() function that the other plugin wrappers use, and will run it through the computer's audio/MIDI devices using AudioDeviceManager and AudioProcessorPlayer.

@tags{Audio}

Constructor & Destructor Documentation

◆ StandalonePluginHolder()

juce::StandalonePluginHolder::StandalonePluginHolder ( PropertySet settingsToUse,
bool  takeOwnershipOfSettings = true,
const String preferredDefaultDeviceName = String(),
const AudioDeviceManager::AudioDeviceSetup preferredSetupOptions = nullptr,
const Array< PluginInOuts > &  channels = Array<PluginInOuts>(),
bool  shouldAutoOpenMidiDevices = true 
)
inline

Creates an instance of the default plugin.

The settings object can be a PropertySet that the class should use to store its settings - the takeOwnershipOfSettings indicates whether this object will delete the settings automatically when no longer needed. The settings can also be nullptr.

A default device name can be passed in.

Preferably a complete setup options object can be used, which takes precedence over the preferredDefaultDeviceName and allows you to select the input & output device names, sample rate, buffer size etc.

In all instances, the settingsToUse will take precedence over the "preferred" options if not null.

References juce::Value::addListener(), channelConfiguration, createPlugin(), init(), juce::RuntimePermissions::isGranted(), isInterAppAudioConnected(), juce::RuntimePermissions::isRequired(), options, processor, juce::RuntimePermissions::recordAudio, juce::RuntimePermissions::request(), and shouldMuteInput.

◆ ~StandalonePluginHolder()

juce::StandalonePluginHolder::~StandalonePluginHolder ( )
inlineoverride

Member Function Documentation

◆ askUserToLoadState()

◆ askUserToSaveState()

◆ audioDeviceAboutToStart()

void juce::StandalonePluginHolder::audioDeviceAboutToStart ( AudioIODevice device)
inlineoverrideprivatevirtual

Called to indicate that the device is about to start calling back.

This will be called just before the audio callbacks begin, either when this callback has just been added to an audio device, or after the device has been restarted because of a sample-rate or block-size change.

You can use this opportunity to find out the sample rate and block size that the device is going to use by calling the AudioIODevice::getCurrentSampleRate() and AudioIODevice::getCurrentBufferSizeSamples() on the supplied pointer.

Parameters
devicethe audio IO device that will be used to drive the callback. Note that if you're going to store this this pointer, it is only valid until the next time that audioDeviceStopped is called.

Implements juce::AudioIODeviceCallback.

References juce::AudioProcessorPlayer::audioDeviceAboutToStart(), juce::AudioBuffer< Type >::clear(), juce::BigInteger::countNumberOfSetBits(), deviceManager, emptyBuffer, juce::AudioIODevice::getActiveInputChannels(), juce::AudioIODevice::getCurrentBufferSizeSamples(), juce::AudioDeviceManager::getDefaultMidiOutput(), player, juce::AudioProcessorPlayer::setMidiOutput(), and juce::AudioBuffer< Type >::setSize().

◆ audioDeviceError()

virtual void juce::AudioIODeviceCallback::audioDeviceError ( const String errorMessage)
virtualinherited

This can be overridden to be told if the device generates an error while operating.

Be aware that this could be called by any thread! And not all devices perform this callback.

Reimplemented in juce::SoundPlayer.

◆ audioDeviceIOCallback()

void juce::StandalonePluginHolder::audioDeviceIOCallback ( const float **  inputChannelData,
int  numInputChannels,
float **  outputChannelData,
int  numOutputChannels,
int  numSamples 
)
inlineoverrideprivatevirtual

Processes a block of incoming and outgoing audio data.

The subclass's implementation should use the incoming audio for whatever purposes it needs to, and must fill all the output channels with the next block of output data before returning.

The channel data is arranged with the same array indices as the channel name array returned by AudioIODevice::getOutputChannelNames(), but those channels that aren't specified in AudioIODevice::open() will have a null pointer for their associated channel, so remember to check for this.

Parameters
inputChannelDataa set of arrays containing the audio data for each incoming channel - this data is valid until the function returns. There will be one channel of data for each input channel that was enabled when the audio device was opened (see AudioIODevice::open())
numInputChannelsthe number of pointers to channel data in the inputChannelData array.
outputChannelDataa set of arrays which need to be filled with the data that should be sent to each outgoing channel of the device. There will be one channel of data for each output channel that was enabled when the audio device was opened (see AudioIODevice::open()) The initial contents of the array is undefined, so the callback function must fill all the channels with zeros if its output is silence. Failing to do this could cause quite an unpleasant noise!
numOutputChannelsthe number of pointers to channel data in the outputChannelData array.
numSamplesthe number of samples in each channel of the input and output arrays. The number of samples will depend on the audio device's buffer size and will usually remain constant, although this isn't guaranteed. For example, on Android, on devices which support it, Android will chop up your audio processing into several smaller callbacks to ensure higher audio performance. So make sure your code can cope with reasonable changes in the buffer size from one callback to the next.

Implements juce::AudioIODeviceCallback.

References juce::AudioProcessorPlayer::audioDeviceIOCallback(), juce::AudioBuffer< Type >::clear(), emptyBuffer, juce::AudioBuffer< Type >::getArrayOfReadPointers(), muteInput, and player.

◆ audioDeviceStopped()

void juce::StandalonePluginHolder::audioDeviceStopped ( )
inlineoverrideprivatevirtual

◆ callAfterDelay()

static void juce::Timer::callAfterDelay ( int  milliseconds,
std::function< void()>  functionToCall 
)
staticinherited

Invokes a lambda after a given number of milliseconds.

◆ callPendingTimersSynchronously()

static void juce::Timer::callPendingTimersSynchronously ( )
staticinherited

For internal use only: invokes any timers that need callbacks.

Don't call this unless you really know what you're doing!

◆ createPlugin()

◆ deletePlugin()

virtual void juce::StandalonePluginHolder::deletePlugin ( )
inlinevirtual

References processor, and stopPlaying().

Referenced by ~StandalonePluginHolder().

◆ getFilePatterns()

static String juce::StandalonePluginHolder::getFilePatterns ( const String fileSuffix)
inlinestatic

◆ getIAAHostIcon()

Image juce::StandalonePluginHolder::getIAAHostIcon ( int  size)
inline

◆ getInstance()

◆ getLastFile()

File juce::StandalonePluginHolder::getLastFile ( ) const
inline

◆ getMuteInputValue()

Value& juce::StandalonePluginHolder::getMuteInputValue ( )
inline

References shouldMuteInput.

◆ getNumInputChannels()

int juce::StandalonePluginHolder::getNumInputChannels ( ) const
inline

◆ getNumOutputChannels()

int juce::StandalonePluginHolder::getNumOutputChannels ( ) const
inline

◆ getProcessorHasPotentialFeedbackLoop()

◆ getTimerInterval()

int juce::Timer::getTimerInterval ( ) const
inlinenoexceptinherited

Returns the timer's interval.

Returns
the timer's interval in milliseconds if it's running, or 0 if it's not.

Referenced by juce::CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize().

◆ init()

void juce::StandalonePluginHolder::init ( bool  enableAudioInput,
const String preferredDefaultDeviceName 
)
inline

◆ isInterAppAudioConnected()

bool juce::StandalonePluginHolder::isInterAppAudioConnected ( )
inline

◆ isTimerRunning()

bool juce::Timer::isTimerRunning ( ) const
inlinenoexceptinherited

Returns true if the timer is currently running.

◆ reloadAudioDeviceState()

void juce::StandalonePluginHolder::reloadAudioDeviceState ( bool  enableAudioInput,
const String preferredDefaultDeviceName,
const AudioDeviceManager::AudioDeviceSetup preferredSetupOptions 
)
inline

◆ reloadPluginState()

void juce::StandalonePluginHolder::reloadPluginState ( )
inline

References juce::gl::data, processor, and settings.

Referenced by init().

◆ saveAudioDeviceState()

void juce::StandalonePluginHolder::saveAudioDeviceState ( )
inline

◆ savePluginState()

void juce::StandalonePluginHolder::savePluginState ( )
inline

References juce::gl::data, processor, and settings.

◆ setLastFile()

void juce::StandalonePluginHolder::setLastFile ( const FileChooser fc)
inline

◆ setupAudioDevices()

void juce::StandalonePluginHolder::setupAudioDevices ( bool  enableAudioInput,
const String preferredDefaultDeviceName,
const AudioDeviceManager::AudioDeviceSetup preferredSetupOptions 
)
inlineprivate

◆ showAudioSettingsDialog()

◆ shutDownAudioDevices()

◆ startPlaying()

◆ startTimer()

void juce::Timer::startTimer ( int  intervalInMilliseconds)
noexceptinherited

Starts the timer and sets the length of interval required.

If the timer is already started, this will reset it, so the time between calling this method and the next timer callback will not be less than the interval length passed in.

Parameters
intervalInMillisecondsthe interval to use (any value less than 1 will be rounded up to 1)

Referenced by init(), juce::CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize(), and juce::DeviceChangeDetector::triggerAsyncDeviceChangeCallback().

◆ startTimerHz()

void juce::Timer::startTimerHz ( int  timerFrequencyHz)
noexceptinherited

Starts the timer with an interval specified in Hertz.

This is effectively the same as calling startTimer (1000 / timerFrequencyHz).

Referenced by juce::AnimatedPosition< Behaviour >::endDrag(), juce::AnimatedPosition< Behaviour >::nudge(), and juce::AnimatedPosition< Behaviour >::timerCallback().

◆ stopPlaying()

void juce::StandalonePluginHolder::stopPlaying ( )
inline

◆ stopTimer()

void juce::Timer::stopTimer ( )
noexceptinherited

Stops the timer.

No more timer callbacks will be triggered after this method returns.

Note that if you call this from a background thread while the message-thread is already in the middle of your callback, then this method will cancel any future timer callbacks, but it will return without waiting for the current one to finish. The current callback will continue, possibly still running some of your timer code after this method has returned.

Referenced by juce::AnimatedPosition< Behaviour >::beginDrag(), juce::CarbonViewWrapperComponent::setOurSizeToEmbeddedViewSize(), juce::AnimatedPosition< Behaviour >::setPosition(), juce::DeviceChangeDetector::timerCallback(), juce::AnimatedPosition< Behaviour >::timerCallback(), and ~StandalonePluginHolder().

◆ switchToHostApplication()

void juce::StandalonePluginHolder::switchToHostApplication ( )
inline

◆ timerCallback()

void juce::StandalonePluginHolder::timerCallback ( )
inlineoverrideprivatevirtual

The user-defined callback routine that actually gets called periodically.

It's perfectly ok to call startTimer() or stopTimer() from within this callback to change the subsequent intervals.

Implements juce::Timer.

References deviceManager, juce::MidiInput::getAvailableDevices(), lastMidiDevices, and juce::AudioDeviceManager::setMidiInputDeviceEnabled().

◆ valueChanged()

void juce::StandalonePluginHolder::valueChanged ( Value value)
inlineoverridevirtual

Called when a Value object is changed.

Note that the Value object passed as a parameter may not be exactly the same object that you registered the listener with - it might be a copy that refers to the same underlying ValueSource. To find out, you can call Value::refersToSameSourceAs().

Implements juce::Value::Listener.

References muteInput, and juce::gl::value.

Member Data Documentation

◆ autoOpenMidiDevices

bool juce::StandalonePluginHolder::autoOpenMidiDevices

Referenced by init().

◆ channelConfiguration

Array<PluginInOuts> juce::StandalonePluginHolder::channelConfiguration

◆ deviceManager

◆ emptyBuffer

AudioBuffer<float> juce::StandalonePluginHolder::emptyBuffer

◆ lastMidiDevices

Array<MidiDeviceInfo> juce::StandalonePluginHolder::lastMidiDevices

Referenced by timerCallback().

◆ maxSizeEnforcer

CallbackMaxSizeEnforcer juce::StandalonePluginHolder::maxSizeEnforcer { *this }
private

◆ muteInput

std::atomic<bool> juce::StandalonePluginHolder::muteInput { true }

◆ options

std::unique_ptr<AudioDeviceManager::AudioDeviceSetup> juce::StandalonePluginHolder::options

Referenced by init(), and StandalonePluginHolder().

◆ player

◆ positionInQueue

size_t juce::Timer::positionInQueue = (size_t) -1
privateinherited

◆ processor

◆ processorHasPotentialFeedbackLoop

bool juce::StandalonePluginHolder::processorHasPotentialFeedbackLoop = true

◆ settings

◆ shouldMuteInput

◆ stateFileChooser

std::unique_ptr<FileChooser> juce::StandalonePluginHolder::stateFileChooser

◆ timerPeriodMs

int juce::Timer::timerPeriodMs = 0
privateinherited

The documentation for this class was generated from the following file: