27 : currentSampleRate (0.0), bufferSizeExpected (0)
39 if (input !=
nullptr && ! inputs.contains (input))
46 localRate = currentSampleRate;
47 localBufferSize = bufferSizeExpected;
55 inputsToDelete.
setBit (inputs.size(), deleteWhenRemoved);
64 std::unique_ptr<AudioSource> toDelete;
68 const int index = inputs.indexOf (input);
73 if (inputsToDelete [index])
74 toDelete.reset (input);
77 inputs.remove (index);
91 for (
int i = inputs.size(); --i >= 0;)
92 if (inputsToDelete[i])
93 toDelete.
add (inputs.getUnchecked(i));
98 for (
int i = toDelete.
size(); --i >= 0;)
104 tempBuffer.
setSize (2, samplesPerBlockExpected);
108 currentSampleRate = sampleRate;
109 bufferSizeExpected = samplesPerBlockExpected;
111 for (
int i = inputs.size(); --i >= 0;)
112 inputs.getUnchecked(i)->prepareToPlay (samplesPerBlockExpected, sampleRate);
119 for (
int i = inputs.size(); --i >= 0;)
120 inputs.getUnchecked(i)->releaseResources();
124 currentSampleRate = 0;
125 bufferSizeExpected = 0;
132 if (inputs.size() > 0)
134 inputs.getUnchecked(0)->getNextAudioBlock (info);
136 if (inputs.size() > 1)
143 for (
int i = 1; i < inputs.size(); ++i)
145 inputs.getUnchecked(i)->getNextAudioBlock (info2);
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
Changes the buffer's size or number of channels.
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
int getNumSamples() const noexcept
Returns the number of samples allocated in each of the buffer's channels.
void addFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples, Type gainToApplyToSource=Type(1)) noexcept
Adds samples from another buffer to this one.
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.
void shiftBits(int howManyBitsLeft, int startBit)
Shifts a section of bits left or right.
void setBit(int bitNumber)
Sets a specified bit to 1.
Automatically locks and unlocks a mutex object.
void removeInputSource(AudioSource *input)
Removes an input source.
void getNextAudioBlock(const AudioSourceChannelInfo &) override
Implementation of the AudioSource method.
MixerAudioSource()
Creates a MixerAudioSource.
void removeAllInputs()
Removes all the input sources.
void addInputSource(AudioSource *newInput, bool deleteWhenRemoved)
Adds an input source to the mixer.
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
Implementation of the AudioSource method.
~MixerAudioSource() override
Destructor.
void releaseResources() override
Implementation of the AudioSource method.
An array designed for holding objects.
int size() const noexcept
Returns the number of items currently in the array.
ObjectClass * getUnchecked(int index) const noexcept
Returns a pointer to the object at this index in the array, without checking whether the index is in-...
ObjectClass * add(ObjectClass *newObject)
Appends a new object to the end of the array.
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.