33 releaseMasterResources();
42 if (source ==
nullptr)
101 inputStreamEOF =
false;
111 if ((! playing) && masterSource !=
nullptr)
117 inputStreamEOF =
false;
134 while (--
n >= 0 && ! stopped)
143 if (sampleRate > 0.0)
149 if (sampleRate > 0.0)
157 if (sampleRate > 0.0)
165 if (positionableSource !=
nullptr)
167 if (sampleRate > 0 && sourceSampleRate > 0)
172 if (resamplerSource !=
nullptr)
175 inputStreamEOF =
false;
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)
227 inputStreamEOF =
false;
231void AudioTransportSource::releaseMasterResources()
235 if (masterSource !=
nullptr)
243 releaseMasterResources();
250 if (masterSource !=
nullptr && ! stopped)
257 for (
int i =
info.buffer->getNumChannels(); --i >= 0;)
258 info.buffer->applyGainRamp (i,
info.startSample, jmin (256,
info.numSamples), 1.0f, 0.0f);
260 if (
info.numSamples > 256)
268 inputStreamEOF =
true;
274 for (
int i =
info.buffer->getNumChannels(); --i >= 0;)
275 info.buffer->applyGainRamp (i,
info.startSample,
info.numSamples, lastGain, gain);
279 info.clearActiveBufferRegion();
Holds a resizable array of primitive or copy-by-value objects.
void clear()
Removes all elements from the array.
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.
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 This is a time in seconds.
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.
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...
Used by AudioSource::getNextAudioBlock().