Loading...
Searching...
No Matches
juce::AudioTransportSource Class Reference

`#include <juce_AudioTransportSource.h>`

Inheritance diagram for juce::AudioTransportSource:

## Public Member Functions

| AudioTransportSource ()
| ~AudioTransportSource () override
void | setSource (PositionableAudioSource *newSource, int readAheadBufferSize=0, TimeSliceThread *readAheadThread=nullptr, double sourceSampleRateToCorrectFor=0.0, int maxNumChannels=2)
void | setPosition (double newPosition)
double | getCurrentPosition () const
double | getLengthInSeconds () const
bool | hasStreamFinished () const noexcept
void | start ()
void | stop ()
bool | isPlaying () const noexcept
void | setGain (float newGain) noexcept
float | getGain () const noexcept
void | prepareToPlay (int samplesPerBlockExpected, double sampleRate) override
void | releaseResources () override
void | getNextAudioBlock (const AudioSourceChannelInfo &) override
void | setNextReadPosition (int64 newPosition) override
int64 | getNextReadPosition () const override
int64 | getTotalLength () const override
bool | isLooping () const override
Public Member Functions inherited from juce::PositionableAudioSource
| ~PositionableAudioSource () override=default
virtual void | setLooping (bool shouldLoop)
Public Member Functions inherited from juce::AudioSource
virtual | ~AudioSource ()=default
Public Member Functions inherited from juce::ChangeBroadcaster
| ChangeBroadcaster () noexcept
virtual | ~ChangeBroadcaster ()
void | addChangeListener (ChangeListener *listener)
void | removeChangeListener (ChangeListener *listener)
void | removeAllChangeListeners ()
void | sendChangeMessage ()
void | sendSynchronousChangeMessage ()
void | dispatchPendingMessages ()

## Additional Inherited Members

Protected Member Functions inherited from juce::PositionableAudioSource
| PositionableAudioSource ()=default
Protected Member Functions inherited from juce::AudioSource
| AudioSource ()=default

## Detailed Description

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.

See also
  AudioSource, AudioSourcePlayer

Definition at line 41 of file juce_AudioTransportSource.h.

## Constructor & Destructor Documentation

## AudioTransportSource()

juce::AudioTransportSource::AudioTransportSource | ( |  | ) |

Creates an AudioTransportSource. After creating one of these, use the setSource() method to select an input source.

Definition at line 26 of file juce_AudioTransportSource.cpp.

## ~AudioTransportSource()

juce::AudioTransportSource::~AudioTransportSource | ( |  | ) |

override

Destructor.

Definition at line 30 of file juce_AudioTransportSource.cpp.

## Member Function Documentation

## getCurrentPosition()

double juce::AudioTransportSource::getCurrentPosition | ( |  | ) | const

Returns the position that the next data block will be read from. This is a time in seconds.

Definition at line 141 of file juce_AudioTransportSource.cpp.

## getGain()

float juce::AudioTransportSource::getGain | ( |  | ) | const

inline noexcept

Returns the current gain setting.

See also
  setGain

Definition at line 135 of file juce_AudioTransportSource.h.

## getLengthInSeconds()

double juce::AudioTransportSource::getLengthInSeconds | ( |  | ) | const

Returns the stream's length in seconds.

Definition at line 149 of file juce_AudioTransportSource.cpp.

## getNextAudioBlock()

void juce::AudioTransportSource::getNextAudioBlock | ( | const AudioSourceChannelInfo & | info | ) |

override virtual

Implementation of the AudioSource method.

Implements juce::AudioSource.

Definition at line 245 of file juce_AudioTransportSource.cpp.

## getNextReadPosition()

int64 juce::AudioTransportSource::getNextReadPosition | ( |  | ) | const

override virtual

Implements the PositionableAudioSource method.

Implements juce::PositionableAudioSource.

Definition at line 177 of file juce_AudioTransportSource.cpp.

Referenced by getCurrentPosition().

## getTotalLength()

int64 juce::AudioTransportSource::getTotalLength | ( |  | ) | const

override virtual

Implements the PositionableAudioSource method.

Implements juce::PositionableAudioSource.

Definition at line 190 of file juce_AudioTransportSource.cpp.

Referenced by getLengthInSeconds().

## hasStreamFinished()

bool juce::AudioTransportSource::hasStreamFinished | ( |  | ) | const

noexcept

Returns true if the player has stopped because its input stream ran out of data.

Definition at line 157 of file juce_AudioTransportSource.cpp.

Referenced by getNextAudioBlock().

## isLooping()

bool juce::AudioTransportSource::isLooping | ( |  | ) | const

override virtual

Implements the PositionableAudioSource method.

Implements juce::PositionableAudioSource.

Definition at line 203 of file juce_AudioTransportSource.cpp.

## isPlaying()

bool juce::AudioTransportSource::isPlaying | ( |  | ) | const

inline noexcept

Returns true if it's currently playing.

Definition at line 123 of file juce_AudioTransportSource.h.

## prepareToPlay()

void juce::AudioTransportSource::prepareToPlay | ( | int | samplesPerBlockExpected,
|  | double | sampleRate )

override virtual

Implementation of the AudioSource method.

Implements juce::AudioSource.

Definition at line 214 of file juce_AudioTransportSource.cpp.

## releaseResources()

void juce::AudioTransportSource::releaseResources | ( |  | ) |

override virtual

Implementation of the AudioSource method.

Implements juce::AudioSource.

Definition at line 240 of file juce_AudioTransportSource.cpp.

## setGain()

void juce::AudioTransportSource::setGain | ( | float | newGain | ) |

noexcept

Changes the gain to apply to the output.

Parameters

  newGain | a factor by which to multiply the outgoing samples, so 1.0 = 0dB, 0.5 = -6dB, 2.0 = 6dB, etc.

Definition at line 209 of file juce_AudioTransportSource.cpp.

## setNextReadPosition()

void juce::AudioTransportSource::setNextReadPosition | ( | int64 | newPosition | ) |

override virtual

Implements the PositionableAudioSource method.

Implements juce::PositionableAudioSource.

Definition at line 163 of file juce_AudioTransportSource.cpp.

Referenced by setPosition().

## setPosition()

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

Parameters

  newPosition | the new playback position in seconds

See also
  getCurrentPosition

Definition at line 135 of file juce_AudioTransportSource.cpp.

## setSource()

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

Parameters

  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

Definition at line 36 of file juce_AudioTransportSource.cpp.

Referenced by setSource(), and ~AudioTransportSource().

## start()

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

Definition at line 107 of file juce_AudioTransportSource.cpp.

## stop()

void juce::AudioTransportSource::stop | ( |  | ) |

Stops playing.

If it's actually playing, this will send a message to any ChangeListeners that are registered with this object.

Definition at line 121 of file juce_AudioTransportSource.cpp.

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

- juce_AudioTransportSource.h
- juce_AudioTransportSource.cpp