20 : position(0), repeat(false), buffer(audio_buffer)
33 int buffer_samples = buffer->getNumSamples();
34 int buffer_channels = buffer->getNumChannels();
36 if (info.numSamples > 0) {
38 int number_to_copy = 0;
41 if (start + info.numSamples <= buffer_samples)
44 number_to_copy = info.numSamples;
46 else if (start > buffer_samples)
51 else if (buffer_samples - start > 0)
54 number_to_copy = buffer_samples - start;
63 if (number_to_copy > 0)
66 for (
int channel = 0; channel < buffer_channels; channel++)
67 info.buffer->copyFrom(channel, info.startSample, *buffer, channel, start, number_to_copy);
70 position += number_to_copy;
86 if (newPosition >= 0 && newPosition < buffer->getNumSamples())
87 position = newPosition;
101 return buffer->getNumSamples();
121 buffer = audio_buffer;
void setNextReadPosition(juce::int64 newPosition)
Set the next read position of this source.
void setLooping(bool shouldLoop)
Set if this audio source should repeat when it reaches the end.
void setBuffer(juce::AudioBuffer< float > *audio_buffer)
Update the internal buffer used by this source.
void prepareToPlay(int, double)
Prepare to play this audio source.
Header file for AudioBufferSource class.
~AudioBufferSource()
Destructor.
juce::int64 getNextReadPosition() const
Get the next read position of this source.
void getNextAudioBlock(const juce::AudioSourceChannelInfo &info)
Get the next block of audio samples.
void releaseResources()
Release all resources.
bool isLooping() const
Determines if this audio source should repeat when it reaches the end.
This namespace is the default namespace for all code in the openshot library.
juce::int64 getTotalLength() const
Get the total length (in samples) of this audio source.