33 releaseMasterResources();
42 if (source ==
nullptr)
109 if ((! playing) && masterSource !=
nullptr)
128 while (--n >= 0 && ! stopped)
137 if (sampleRate > 0.0)
143 if (sampleRate > 0.0)
151 if (sampleRate > 0.0)
165 if (positionableSource !=
nullptr)
167 if (sampleRate > 0 && sourceSampleRate > 0)
172 if (resamplerSource !=
nullptr)
181 if (positionableSource !=
nullptr)
183 const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0;
194 if (positionableSource !=
nullptr)
196 const double ratio = (sampleRate > 0 && sourceSampleRate > 0) ? sampleRate / sourceSampleRate : 1.0;
206 return positionableSource !=
nullptr && positionableSource->
isLooping();
221 if (masterSource !=
nullptr)
224 if (resamplerSource !=
nullptr && sourceSampleRate > 0)
230void AudioTransportSource::releaseMasterResources()
234 if (masterSource !=
nullptr)
242 releaseMasterResources();
249 if (masterSource !=
nullptr && ! stopped)
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
void clear() noexcept
Clears all the samples in all channels and marks the buffer as cleared.
void applyGainRamp(int channel, int startSample, int numSamples, Type startGain, Type endGain) noexcept
Applies a range of gains to a region of a channel.
Base class for objects that can produce a continuous stream of audio.
virtual void releaseResources()=0
Allows the source to release anything it no longer needs after playback has stopped.
virtual void prepareToPlay(int samplesPerBlockExpected, double sampleRate)=0
Tells the source to prepare for playing.
virtual void getNextAudioBlock(const AudioSourceChannelInfo &bufferToFill)=0
Called repeatedly to fetch subsequent blocks of audio data.
void stop()
Stops playing.
bool hasStreamFinished() const noexcept
Returns true if the player has stopped because its input stream ran out of data.
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
Implementation of the AudioSource method.
int64 getNextReadPosition() const override
Implements the PositionableAudioSource method.
double getCurrentPosition() const
Returns the position that the next data block will be read from.
void releaseResources() override
Implementation of the AudioSource method.
void getNextAudioBlock(const AudioSourceChannelInfo &) override
Implementation of the AudioSource method.
int64 getTotalLength() const override
Implements the PositionableAudioSource method.
~AudioTransportSource() override
Destructor.
void setPosition(double newPosition)
Changes the current playback position in the source stream.
double getLengthInSeconds() const
Returns the stream's length in seconds.
void setGain(float newGain) noexcept
Changes the gain to apply to the output.
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.
bool isLooping() const override
Implements the PositionableAudioSource method.
AudioTransportSource()
Creates an AudioTransportSource.
void start()
Starts playing (if a source has been selected).
void setNextReadPosition(int64 newPosition) override
Implements the PositionableAudioSource method.
An AudioSource which takes another source as input, and buffers it using a thread.
void sendChangeMessage()
Causes an asynchronous change message to be sent to all the registered listeners.
Automatically locks and unlocks a mutex object.
A type of AudioSource which can be repositioned.
virtual bool isLooping() const =0
Returns true if this source is actually playing in a loop.
virtual int64 getNextReadPosition() const =0
Returns the position from which the next block will be returned.
virtual int64 getTotalLength() const =0
Returns the total length of the stream (in samples).
virtual void setNextReadPosition(int64 newPosition)=0
Tells the stream to move to a new position.
A type of AudioSource that takes an input source and changes its sample rate.
void flushBuffers()
Clears any buffers and filters that the resampler is using.
void setResamplingRatio(double samplesInPerOutputSample)
Changes the resampling ratio.
static void JUCE_CALLTYPE sleep(int milliseconds)
Suspends the execution of the current thread until the specified timeout period has elapsed (note tha...
A thread that keeps a list of clients, and calls each one in turn, giving them all a chance to run so...
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
long long int64
A platform-independent 64-bit integer type.
Used by AudioSource::getNextAudioBlock().
int numSamples
The number of samples in the buffer which the callback is expected to fill with data.
void clearActiveBufferRegion() const
Convenient method to clear the buffer if the source is not producing any data.
AudioBuffer< float > * buffer
The destination buffer to fill with audio data.
int startSample
The first sample in the buffer from which the callback is expected to write data.