JUCE
|
An AudioSource that takes a PositionableAudioSource and allows it to be played, stopped, started, etc. More...
Public Member Functions | |
AudioTransportSource () | |
Creates an AudioTransportSource. More... | |
~AudioTransportSource () override | |
Destructor. More... | |
void | setSource (PositionableAudioSource *newSource, int readAheadBufferSize=0, TimeSliceThread *readAheadThread=nullptr, double sourceSampleRateToCorrectFor=0.0, int maxNumChannels=2) |
Sets the reader that is being used as the input source. More... | |
void | setPosition (double newPosition) |
Changes the current playback position in the source stream. More... | |
double | getCurrentPosition () const |
Returns the position that the next data block will be read from This is a time in seconds. More... | |
double | getLengthInSeconds () const |
Returns the stream's length in seconds. More... | |
bool | hasStreamFinished () const noexcept |
Returns true if the player has stopped because its input stream ran out of data. More... | |
void | start () |
Starts playing (if a source has been selected). More... | |
void | stop () |
Stops playing. More... | |
bool | isPlaying () const noexcept |
Returns true if it's currently playing. More... | |
void | setGain (float newGain) noexcept |
Changes the gain to apply to the output. More... | |
float | getGain () const noexcept |
Returns the current gain setting. More... | |
void | prepareToPlay (int samplesPerBlockExpected, double sampleRate) override |
Implementation of the AudioSource method. More... | |
void | releaseResources () override |
Implementation of the AudioSource method. More... | |
void | getNextAudioBlock (const AudioSourceChannelInfo &) override |
Implementation of the AudioSource method. More... | |
void | setNextReadPosition (int64 newPosition) override |
Implements the PositionableAudioSource method. More... | |
int64 | getNextReadPosition () const override |
Implements the PositionableAudioSource method. More... | |
int64 | getTotalLength () const override |
Implements the PositionableAudioSource method. More... | |
bool | isLooping () const override |
Implements the PositionableAudioSource method. More... | |
Public Member Functions inherited from PositionableAudioSource | |
~PositionableAudioSource () override=default | |
Destructor. More... | |
virtual void | setLooping (bool shouldLoop) |
Tells the source whether you'd like it to play in a loop. More... | |
Public Member Functions inherited from AudioSource | |
virtual | ~AudioSource ()=default |
Destructor. More... | |
Public Member Functions inherited from ChangeBroadcaster | |
ChangeBroadcaster () noexcept | |
Creates an ChangeBroadcaster. More... | |
virtual | ~ChangeBroadcaster () |
Destructor. More... | |
void | addChangeListener (ChangeListener *listener) |
Registers a listener to receive change callbacks from this broadcaster. More... | |
void | removeChangeListener (ChangeListener *listener) |
Unregisters a listener from the list. More... | |
void | removeAllChangeListeners () |
Removes all listeners from the list. More... | |
void | sendChangeMessage () |
Causes an asynchronous change message to be sent to all the registered listeners. More... | |
void | sendSynchronousChangeMessage () |
Sends a synchronous change message to all the registered listeners. More... | |
void | dispatchPendingMessages () |
If a change message has been sent but not yet dispatched, this will call sendSynchronousChangeMessage() to make the callback immediately. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from PositionableAudioSource | |
PositionableAudioSource ()=default | |
Creates the PositionableAudioSource. More... | |
Protected Member Functions inherited from AudioSource | |
AudioSource ()=default | |
Creates an AudioSource. More... | |
An AudioSource that takes a PositionableAudioSource and allows it to be played, stopped, started, etc.
This can also be told use a buffer and background thread to read ahead, and if can correct for different sample-rates.
You may want to use one of these along with an AudioSourcePlayer and AudioIODevice to control playback of an audio file.
AudioTransportSource::AudioTransportSource | ( | ) |
Creates an AudioTransportSource.
After creating one of these, use the setSource() method to select an input source.
|
override |
Destructor.
void AudioTransportSource::setSource | ( | PositionableAudioSource * | newSource, |
int | readAheadBufferSize = 0 , |
||
TimeSliceThread * | readAheadThread = nullptr , |
||
double | sourceSampleRateToCorrectFor = 0.0 , |
||
int | maxNumChannels = 2 |
||
) |
Sets the reader that is being used as the input source.
This will stop playback, reset the position to 0 and change to the new reader.
The source passed in will not be deleted by this object, so must be managed by the caller.
newSource | the new input source to use. This may be a nullptr |
readAheadBufferSize | a size of buffer to use for reading ahead. If this is zero, no reading ahead will be done; if it's greater than zero, a BufferingAudioSource will be used to do the reading-ahead. If you set a non-zero value here, you'll also need to set the readAheadThread parameter. |
readAheadThread | if you set readAheadBufferSize to a non-zero value, then you'll also need to supply this TimeSliceThread object for the background reader to use. The thread object must not be deleted while the AudioTransport source is still using it. |
sourceSampleRateToCorrectFor | if this is non-zero, it specifies the sample rate of the source, and playback will be sample-rate adjusted to maintain playback at the correct pitch. If this is 0, no sample-rate adjustment will be performed |
maxNumChannels | the maximum number of channels that may need to be played |
void AudioTransportSource::setPosition | ( | double | newPosition | ) |
Changes the current playback position in the source stream.
The next time the getNextAudioBlock() method is called, this is the time from which it'll read data.
newPosition | the new playback position in seconds |
double AudioTransportSource::getCurrentPosition | ( | ) | const |
Returns the position that the next data block will be read from This is a time in seconds.
double AudioTransportSource::getLengthInSeconds | ( | ) | const |
Returns the stream's length in seconds.
|
noexcept |
Returns true if the player has stopped because its input stream ran out of data.
void AudioTransportSource::start | ( | ) |
Starts playing (if a source has been selected).
If it starts playing, this will send a message to any ChangeListeners that are registered with this object.
void AudioTransportSource::stop | ( | ) |
Stops playing.
If it's actually playing, this will send a message to any ChangeListeners that are registered with this object.
|
noexcept |
Returns true if it's currently playing.
|
noexcept |
Changes the gain to apply to the output.
newGain | a factor by which to multiply the outgoing samples, so 1.0 = 0dB, 0.5 = -6dB, 2.0 = 6dB, etc. |
|
noexcept |
Returns the current gain setting.
References AudioSource::getNextAudioBlock(), PositionableAudioSource::getNextReadPosition(), PositionableAudioSource::getTotalLength(), PositionableAudioSource::isLooping(), JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR, AudioSource::prepareToPlay(), AudioSource::releaseResources(), and PositionableAudioSource::setNextReadPosition().
|
overridevirtual |
Implementation of the AudioSource method.
Implements AudioSource.
|
overridevirtual |
Implementation of the AudioSource method.
Implements AudioSource.
|
overridevirtual |
Implementation of the AudioSource method.
Implements AudioSource.
|
overridevirtual |
Implements the PositionableAudioSource method.
Implements PositionableAudioSource.
|
overridevirtual |
Implements the PositionableAudioSource method.
Implements PositionableAudioSource.
|
overridevirtual |
Implements the PositionableAudioSource method.
Implements PositionableAudioSource.
|
overridevirtual |
Implements the PositionableAudioSource method.
Implements PositionableAudioSource.