OpenShot Library | libopenshot-audio
0.2.0
|
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 removeInputSource(AudioSource *input)
Removes an input source.
void clearActiveBufferRegion() const
Convenient method to clear the buffer if the source is not producing any data.
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
Implementation of the AudioSource method.
Base class for objects that can produce a continuous stream of audio.
int size() const noexcept
Returns the number of items currently in the array.
An array designed for holding objects.
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
Changes the buffer's size or number of channels.
void addInputSource(AudioSource *newInput, bool deleteWhenRemoved)
Adds an input source to the mixer.
void getNextAudioBlock(const AudioSourceChannelInfo &) override
Implementation of the AudioSource method.
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.
virtual void prepareToPlay(int samplesPerBlockExpected, double sampleRate)=0
Tells the source to prepare for playing.
~MixerAudioSource() override
Destructor.
int startSample
The first sample in the buffer from which the callback is expected to write data.
int numSamples
The number of samples in the buffer which the callback is expected to fill with data.
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
AudioBuffer< float > * buffer
The destination buffer to fill with audio data.
Used by AudioSource::getNextAudioBlock().
ObjectClass * getUnchecked(const int index) const noexcept
Returns a pointer to the object at this index in the array, without checking whether the index is in-...
Automatically locks and unlocks a mutex object.
void setBit(int bitNumber)
Sets a specified bit to 1.
ObjectClass * add(ObjectClass *newObject) noexcept
Appends a new object to the end of the array.
virtual void releaseResources()=0
Allows the source to release anything it no longer needs after playback has stopped.
void releaseResources() override
Implementation of the AudioSource method.
int getNumSamples() const noexcept
Returns the number of samples allocated in each of the buffer's channels.
void shiftBits(int howManyBitsLeft, int startBit)
Shifts a section of bits left or right.
MixerAudioSource()
Creates a MixerAudioSource.
void removeAllInputs()
Removes all the input sources.