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

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

#include <gin_audioprocessorplayer.h>

Inherits juce::AudioIODeviceCallback, and juce::MidiInputCallback.

Classes

struct  NumChannels
 

Public Member Functions

 AudioProcessorPlayer (bool doDoublePrecisionProcessing=false)
 
 ~AudioProcessorPlayer () override
 Destructor.
 
virtual void setProcessor (juce::AudioProcessor *processorToPlay)
 Sets the processor that should be played.
 
juce::AudioProcessor * getCurrentProcessor () const noexcept
 Returns the current audio processor that is being played.
 
juce::MidiMessageCollector & 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.
 
void setMidiOutput (juce::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.
 
virtual void preProcessBlock (juce::AudioBuffer< float > &, juce::MidiBuffer &)
 
virtual void postProcessBlock (juce::AudioBuffer< float > &, juce::MidiBuffer &)
 
virtual void preProcessBlock (juce::AudioBuffer< double > &, juce::MidiBuffer &)
 
virtual void postProcessBlock (juce::AudioBuffer< double > &, juce::MidiBuffer &)
 
void audioDeviceIOCallbackWithContext (const float *const *, int, float *const *, int, int, const juce::AudioIODeviceCallbackContext &) override
 
void audioDeviceAboutToStart (juce::AudioIODevice *) override
 
void audioDeviceStopped () override
 
void handleIncomingMidiMessage (juce::MidiInput *, const juce::MidiMessage &) override
 

Protected Member Functions

NumChannels findMostSuitableLayout (const juce::AudioProcessor &) const
 
void resizeChannels ()
 

Protected Attributes

juce::AudioProcessor * processor = nullptr
 
juce::CriticalSection lock
 
double sampleRate = 0
 
int blockSize = 0
 
bool isPrepared = false
 
bool isDoublePrecision = false
 
NumChannels deviceChannels
 
NumChannels defaultProcessorChannels
 
NumChannels actualProcessorChannels
 
std::vector< float * > channels
 
juce::AudioBuffer< floattempBuffer
 
juce::AudioBuffer< doubleconversionBuffer
 
juce::MidiBuffer incomingMidi
 
juce::MidiMessageCollector messageCollector
 
juce::MidiOutput * midiOutput = nullptr
 
uint64_t sampleCount = 0
 
juce::AudioIODevice * currentDevice = nullptr
 
juce::AudioWorkgroup currentWorkgroup
 

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.

This is an improvement on the juce version as it allows pre/post processing the audio and midi data

See also
AudioProcessor, AudioProcessorGraph

Constructor & Destructor Documentation

◆ AudioProcessorPlayer()

AudioProcessorPlayer::AudioProcessorPlayer ( bool  doDoublePrecisionProcessing = false)

◆ ~AudioProcessorPlayer()

AudioProcessorPlayer::~AudioProcessorPlayer ( )
override

Destructor.

Member Function Documentation

◆ setProcessor()

virtual void AudioProcessorPlayer::setProcessor ( juce::AudioProcessor *  processorToPlay)
virtual

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.

◆ getCurrentProcessor()

juce::AudioProcessor * AudioProcessorPlayer::getCurrentProcessor ( ) const
noexcept

Returns the current audio processor that is being played.

References processor.

◆ getMidiMessageCollector()

juce::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.

References messageCollector.

◆ setMidiOutput()

void AudioProcessorPlayer::setMidiOutput ( juce::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.

References isDoublePrecision.

◆ preProcessBlock() [1/2]

virtual void AudioProcessorPlayer::preProcessBlock ( juce::AudioBuffer< float > &  ,
juce::MidiBuffer &   
)
virtual

◆ postProcessBlock() [1/2]

virtual void AudioProcessorPlayer::postProcessBlock ( juce::AudioBuffer< float > &  ,
juce::MidiBuffer &   
)
virtual

◆ preProcessBlock() [2/2]

virtual void AudioProcessorPlayer::preProcessBlock ( juce::AudioBuffer< double > &  ,
juce::MidiBuffer &   
)
virtual

◆ postProcessBlock() [2/2]

virtual void AudioProcessorPlayer::postProcessBlock ( juce::AudioBuffer< double > &  ,
juce::MidiBuffer &   
)
virtual

◆ audioDeviceIOCallbackWithContext()

void AudioProcessorPlayer::audioDeviceIOCallbackWithContext ( const float *const ,
int  ,
float *const ,
int  ,
int  ,
const juce::AudioIODeviceCallbackContext &   
)
override

◆ audioDeviceAboutToStart()

void AudioProcessorPlayer::audioDeviceAboutToStart ( juce::AudioIODevice *  )
override

◆ audioDeviceStopped()

void AudioProcessorPlayer::audioDeviceStopped ( )
override

◆ handleIncomingMidiMessage()

void AudioProcessorPlayer::handleIncomingMidiMessage ( juce::MidiInput *  ,
const juce::MidiMessage &   
)
override

◆ findMostSuitableLayout()

NumChannels AudioProcessorPlayer::findMostSuitableLayout ( const juce::AudioProcessor &  ) const
protected

◆ resizeChannels()

void AudioProcessorPlayer::resizeChannels ( )
protected

Member Data Documentation

◆ processor

juce::AudioProcessor* AudioProcessorPlayer::processor = nullptr
protected

Referenced by getCurrentProcessor().

◆ lock

juce::CriticalSection AudioProcessorPlayer::lock
protected

◆ sampleRate

double AudioProcessorPlayer::sampleRate = 0
protected

◆ blockSize

int AudioProcessorPlayer::blockSize = 0
protected

◆ isPrepared

bool AudioProcessorPlayer::isPrepared = false
protected

◆ isDoublePrecision

bool AudioProcessorPlayer::isDoublePrecision = false
protected

◆ deviceChannels

NumChannels AudioProcessorPlayer::deviceChannels
protected

◆ defaultProcessorChannels

NumChannels AudioProcessorPlayer::defaultProcessorChannels
protected

◆ actualProcessorChannels

NumChannels AudioProcessorPlayer::actualProcessorChannels
protected

◆ channels

std::vector<float*> AudioProcessorPlayer::channels
protected

◆ tempBuffer

juce::AudioBuffer<float> AudioProcessorPlayer::tempBuffer
protected

◆ conversionBuffer

juce::AudioBuffer<double> AudioProcessorPlayer::conversionBuffer
protected

◆ incomingMidi

juce::MidiBuffer AudioProcessorPlayer::incomingMidi
protected

◆ messageCollector

juce::MidiMessageCollector AudioProcessorPlayer::messageCollector
protected

Referenced by getMidiMessageCollector().

◆ midiOutput

juce::MidiOutput* AudioProcessorPlayer::midiOutput = nullptr
protected

◆ sampleCount

uint64_t AudioProcessorPlayer::sampleCount = 0
protected

◆ currentDevice

juce::AudioIODevice* AudioProcessorPlayer::currentDevice = nullptr
protected

◆ currentWorkgroup

juce::AudioWorkgroup AudioProcessorPlayer::currentWorkgroup
protected

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