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

Wrapper class to continuously stream audio from an audio source to an AudioIODevice. More...

#include <juce_AudioSourcePlayer.h>

Inheritance diagram for AudioSourcePlayer:

Public Member Functions

 AudioSourcePlayer ()
 Creates an empty AudioSourcePlayer.
 
 ~AudioSourcePlayer () override
 Destructor.
 
void setSource (AudioSource *newSource)
 Changes the current audio source to play from.
 
AudioSourcegetCurrentSource () const noexcept
 Returns the source that's playing.
 
void setGain (float newGain) noexcept
 Sets a gain to apply to the audio data.
 
float getGain () const noexcept
 Returns the current gain.
 
void audioDeviceIOCallbackWithContext (const float *const *inputChannelData, int totalNumInputChannels, float *const *outputChannelData, int totalNumOutputChannels, int numSamples, const AudioIODeviceCallbackContext &context) override
 Implementation of the AudioIODeviceCallbackWithContext method.
 
void audioDeviceAboutToStart (AudioIODevice *device) override
 Implementation of the AudioIODeviceCallback method.
 
void audioDeviceStopped () override
 Implementation of the AudioIODeviceCallback method.
 
void prepareToPlay (double sampleRate, int blockSize)
 An alternative method for initialising the source without an AudioIODevice.
 
- 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.
 

Detailed Description

Wrapper class to continuously stream audio from an audio source to an AudioIODevice.

This object acts as an AudioIODeviceCallback, so can be attached to an output device, and will stream audio from an AudioSource.

Constructor & Destructor Documentation

◆ AudioSourcePlayer()

AudioSourcePlayer::AudioSourcePlayer ( )

Creates an empty AudioSourcePlayer.

◆ ~AudioSourcePlayer()

AudioSourcePlayer::~AudioSourcePlayer ( )
override

Destructor.

Make sure this object isn't still being used by an AudioIODevice before deleting it!

Member Function Documentation

◆ setSource()

void AudioSourcePlayer::setSource ( AudioSource * newSource)

Changes the current audio source to play from.

If the source passed in is already being used, this method will do nothing. If the source is not null, its prepareToPlay() method will be called before it starts being used for playback.

If there's another source currently playing, its releaseResources() method will be called after it has been swapped for the new one.

Parameters
newSourcethe new source to use - this will NOT be deleted by this object when no longer needed, so it's the caller's responsibility to manage it.

◆ getCurrentSource()

AudioSource * AudioSourcePlayer::getCurrentSource ( ) const
noexcept

Returns the source that's playing.

May return nullptr if there's no source.

◆ setGain()

void AudioSourcePlayer::setGain ( float newGain)
noexcept

Sets a gain to apply to the audio data.

See also
getGain

◆ getGain()

float AudioSourcePlayer::getGain ( ) const
noexcept

Returns the current gain.

See also
setGain

◆ audioDeviceIOCallbackWithContext()

void AudioSourcePlayer::audioDeviceIOCallbackWithContext ( const float *const * inputChannelData,
int totalNumInputChannels,
float *const * outputChannelData,
int totalNumOutputChannels,
int numSamples,
const AudioIODeviceCallbackContext & context )
overridevirtual

Implementation of the AudioIODeviceCallbackWithContext method.

Reimplemented from AudioIODeviceCallback.

◆ audioDeviceAboutToStart()

void AudioSourcePlayer::audioDeviceAboutToStart ( AudioIODevice * device)
overridevirtual

Implementation of the AudioIODeviceCallback method.

Implements AudioIODeviceCallback.

◆ audioDeviceStopped()

void AudioSourcePlayer::audioDeviceStopped ( )
overridevirtual

Implementation of the AudioIODeviceCallback method.

Implements AudioIODeviceCallback.

◆ prepareToPlay()

void AudioSourcePlayer::prepareToPlay ( double sampleRate,
int blockSize )

An alternative method for initialising the source without an AudioIODevice.


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