Loading...
Searching...
No Matches
Public Member Functions | List of all members
AudioProcessorPlayer Class Reference

An AudioIODeviceCallback object which streams audio through an AudioProcessor. More...

#include <juce_AudioProcessorPlayer.h>

Inheritance diagram for AudioProcessorPlayer:

Public Member Functions

 AudioProcessorPlayer (bool doDoublePrecisionProcessing=false)
 
 ~AudioProcessorPlayer () override
 Destructor.
 
void setProcessor (AudioProcessor *processorToPlay)
 Sets the processor that should be played.
 
AudioProcessorgetCurrentProcessor () const noexcept
 Returns the current audio processor that is being played.
 
MidiMessageCollectorgetMidiMessageCollector () noexcept
 Returns a midi message collector that you can pass midi messages to if you want them to be injected into the midi stream that is being sent to the processor.
 
void setMidiOutput (MidiOutput *midiOutputToUse)
 Sets the MIDI output that should be used, if required.
 
void setDoublePrecisionProcessing (bool doublePrecision)
 Switch between double and single floating point precisions processing.
 
bool getDoublePrecisionProcessing ()
 Returns true if this player processes internally processes the samples with double floating point precision.
 
void audioDeviceIOCallbackWithContext (const float *const *, int, float *const *, int, int, const AudioIODeviceCallbackContext &) override
 Processes a block of incoming and outgoing audio data.
 
void audioDeviceAboutToStart (AudioIODevice *) override
 Called to indicate that the device is about to start calling back.
 
void audioDeviceStopped () override
 Called to indicate that the device has stopped.
 
void handleIncomingMidiMessage (MidiInput *, const MidiMessage &) override
 Receives an incoming message.
 
- Public Member Functions inherited from AudioIODeviceCallback
virtual ~AudioIODeviceCallback ()=default
 Destructor.
 
virtual void audioDeviceError (const String &errorMessage)
 This can be overridden to be told if the device generates an error while operating.
 
- Public Member Functions inherited from MidiInputCallback
virtual ~MidiInputCallback ()=default
 Destructor.
 
virtual void handlePartialSysexMessage (MidiInput *source, const uint8 *messageData, int numBytesSoFar, double timestamp)
 Notification sent each time a packet of a multi-packet sysex message arrives.
 

Detailed Description

An AudioIODeviceCallback object which streams audio through an AudioProcessor.

To use one of these, just make it the callback used by your AudioIODevice, and give it a processor to use by calling setProcessor().

It's also a MidiInputCallback, so you can connect it to both an audio and midi input to send both streams through the processor. To set a MidiOutput for the processor, use the setMidiOutput() method.

See also
AudioProcessor, AudioProcessorGraph

Constructor & Destructor Documentation

◆ AudioProcessorPlayer()

AudioProcessorPlayer::AudioProcessorPlayer ( bool doDoublePrecisionProcessing = false)

◆ ~AudioProcessorPlayer()

AudioProcessorPlayer::~AudioProcessorPlayer ( )
override

Destructor.

Member Function Documentation

◆ setProcessor()

void AudioProcessorPlayer::setProcessor ( AudioProcessor * processorToPlay)

Sets the processor that should be played.

The processor that is passed in will not be deleted or owned by this object. To stop anything playing, pass a nullptr to this method.

Referenced by StandalonePluginHolder::startPlaying(), and StandalonePluginHolder::stopPlaying().

◆ getCurrentProcessor()

AudioProcessor * AudioProcessorPlayer::getCurrentProcessor ( ) const
noexcept

Returns the current audio processor that is being played.

◆ getMidiMessageCollector()

MidiMessageCollector & AudioProcessorPlayer::getMidiMessageCollector ( )
noexcept

Returns a midi message collector that you can pass midi messages to if you want them to be injected into the midi stream that is being sent to the processor.

Referenced by StandalonePluginHolder::startPlaying().

◆ setMidiOutput()

void AudioProcessorPlayer::setMidiOutput ( MidiOutput * midiOutputToUse)

Sets the MIDI output that should be used, if required.

The MIDI output will not be deleted or owned by this object. If the MIDI output is deleted, pass a nullptr to this method.

◆ setDoublePrecisionProcessing()

void AudioProcessorPlayer::setDoublePrecisionProcessing ( bool doublePrecision)

Switch between double and single floating point precisions processing.

The audio IO callbacks will still operate in single floating point precision, however, all internal processing including the AudioProcessor will be processed in double floating point precision if the AudioProcessor supports it (see AudioProcessor::supportsDoublePrecisionProcessing()). Otherwise, the processing will remain single precision irrespective of the parameter doublePrecision.

◆ getDoublePrecisionProcessing()

bool AudioProcessorPlayer::getDoublePrecisionProcessing ( )

Returns true if this player processes internally processes the samples with double floating point precision.

◆ audioDeviceIOCallbackWithContext()

void AudioProcessorPlayer::audioDeviceIOCallbackWithContext ( const float *const * inputChannelData,
int numInputChannels,
float *const * outputChannelData,
int numOutputChannels,
int numSamples,
const AudioIODeviceCallbackContext & context )
overridevirtual

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.
contextAdditional information that may be passed to the AudioIODeviceCallback.

Reimplemented from AudioIODeviceCallback.

◆ audioDeviceAboutToStart()

void AudioProcessorPlayer::audioDeviceAboutToStart ( AudioIODevice * device)
overridevirtual

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 AudioIODeviceCallback.

◆ audioDeviceStopped()

void AudioProcessorPlayer::audioDeviceStopped ( )
overridevirtual

Called to indicate that the device has stopped.

Implements AudioIODeviceCallback.

◆ handleIncomingMidiMessage()

void AudioProcessorPlayer::handleIncomingMidiMessage ( MidiInput * source,
const MidiMessage & message )
overridevirtual

Receives an incoming message.

A MidiInput object will call this method when a midi event arrives. It'll be called on a high-priority system thread, so avoid doing anything time-consuming in here, and avoid making any UI calls. You might find the MidiBuffer class helpful for queueing incoming messages for use later.

Parameters
sourcethe MidiInput object that generated the message
messagethe incoming message. The message's timestamp is set to a value equivalent to (Time::getMillisecondCounter() / 1000.0) to specify the time when the message arrived

Implements MidiInputCallback.


The documentation for this class was generated from the following file:
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram