LMMS
Loading...
Searching...
No Matches
juce::AudioSourcePlayer Class Reference

#include <juce_AudioSourcePlayer.h>

Inheritance diagram for juce::AudioSourcePlayer:
juce::AudioIODeviceCallback

Public Member Functions

 AudioSourcePlayer ()
 ~AudioSourcePlayer () override
void setSource (AudioSource *newSource)
AudioSourcegetCurrentSource () const noexcept
void setGain (float newGain) noexcept
float getGain () const noexcept
void audioDeviceIOCallback (const float **inputChannelData, int totalNumInputChannels, float **outputChannelData, int totalNumOutputChannels, int numSamples) override
void audioDeviceAboutToStart (AudioIODevice *device) override
void audioDeviceStopped () override
void prepareToPlay (double sampleRate, int blockSize)
Public Member Functions inherited from juce::AudioIODeviceCallback
virtual ~AudioIODeviceCallback ()=default
virtual void audioDeviceIOCallbackWithContext (const float **inputChannelData, int numInputChannels, float **outputChannelData, int numOutputChannels, int numSamples, const AudioIODeviceCallbackContext &context)
virtual void audioDeviceError (const String &errorMessage)

Private Attributes

CriticalSection readLock
AudioSourcesource = nullptr
double sampleRate = 0
int bufferSize = 0
float * channels [128]
float * outputChans [128]
const float * inputChans [128]
AudioBuffer< float > tempBuffer
float lastGain = 1.0f
std::atomic< float > gain { 1.0f }

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.

@tags{Audio}

Constructor & Destructor Documentation

◆ AudioSourcePlayer()

juce::AudioSourcePlayer::AudioSourcePlayer ( )

Creates an empty AudioSourcePlayer.

◆ ~AudioSourcePlayer()

juce::AudioSourcePlayer::~AudioSourcePlayer ( )
override

Destructor.

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

Member Function Documentation

◆ audioDeviceAboutToStart()

void juce::AudioSourcePlayer::audioDeviceAboutToStart ( AudioIODevice * device)
overridevirtual

Implementation of the AudioIODeviceCallback method.

Implements juce::AudioIODeviceCallback.

◆ audioDeviceIOCallback()

void juce::AudioSourcePlayer::audioDeviceIOCallback ( const float ** inputChannelData,
int totalNumInputChannels,
float ** outputChannelData,
int totalNumOutputChannels,
int numSamples )
overridevirtual

Implementation of the AudioIODeviceCallback method.

Reimplemented from juce::AudioIODeviceCallback.

◆ audioDeviceStopped()

void juce::AudioSourcePlayer::audioDeviceStopped ( )
overridevirtual

Implementation of the AudioIODeviceCallback method.

Implements juce::AudioIODeviceCallback.

◆ getCurrentSource()

AudioSource * juce::AudioSourcePlayer::getCurrentSource ( ) const
inlinenoexcept

Returns the source that's playing. May return nullptr if there's no source.

◆ getGain()

float juce::AudioSourcePlayer::getGain ( ) const
inlinenoexcept

Returns the current gain.

See also
setGain

◆ prepareToPlay()

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

An alternative method for initialising the source without an AudioIODevice.

◆ setGain()

void juce::AudioSourcePlayer::setGain ( float newGain)
noexcept

Sets a gain to apply to the audio data.

See also
getGain

◆ setSource()

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

Member Data Documentation

◆ bufferSize

int juce::AudioSourcePlayer::bufferSize = 0
private

◆ channels

float* juce::AudioSourcePlayer::channels[128]
private

◆ gain

std::atomic<float> juce::AudioSourcePlayer::gain { 1.0f }
private

◆ inputChans

const float* juce::AudioSourcePlayer::inputChans[128]
private

◆ lastGain

float juce::AudioSourcePlayer::lastGain = 1.0f
private

◆ outputChans

float* juce::AudioSourcePlayer::outputChans[128]
private

◆ readLock

CriticalSection juce::AudioSourcePlayer::readLock
private

◆ sampleRate

double juce::AudioSourcePlayer::sampleRate = 0
private

◆ source

AudioSource* juce::AudioSourcePlayer::source = nullptr
private

◆ tempBuffer

AudioBuffer<float> juce::AudioSourcePlayer::tempBuffer
private

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