27 const bool deleteSourceWhenDeleted)
28 : source (source_, deleteSourceWhenDeleted),
29 requiredNumberOfChannels (2)
31 remappedInfo.
buffer = &buffer;
41 requiredNumberOfChannels = requiredNumberOfChannels_;
48 remappedInputs.
clear();
49 remappedOutputs.
clear();
56 while (remappedInputs.
size() < destIndex)
57 remappedInputs.
add (-1);
59 remappedInputs.
set (destIndex, sourceIndex);
66 while (remappedOutputs.
size() < sourceIndex)
67 remappedOutputs.
add (-1);
69 remappedOutputs.
set (sourceIndex, destIndex);
76 if (inputChannelIndex >= 0 && inputChannelIndex < remappedInputs.
size())
86 if (outputChannelIndex >= 0 && outputChannelIndex < remappedOutputs.
size())
87 return remappedOutputs .getUnchecked (outputChannelIndex);
95 source->prepareToPlay (samplesPerBlockExpected, sampleRate);
100 source->releaseResources();
107 buffer.
setSize (requiredNumberOfChannels, bufferToFill.
numSamples,
false,
false,
true);
115 if (remappedChan >= 0 && remappedChan < numChans)
130 source->getNextAudioBlock (remappedInfo);
134 for (
int i = 0; i < requiredNumberOfChannels; ++i)
138 if (remappedChan >= 0 && remappedChan < numChans)
150 auto e = std::make_unique<XmlElement> (
"MAPPINGS");
155 for (
int i = 0; i < remappedInputs.
size(); ++i)
158 for (
int i = 0; i < remappedOutputs.
size(); ++i)
161 e->setAttribute (
"inputs", ins.trimEnd());
162 e->setAttribute (
"outputs", outs.trimEnd());
179 for (
int i = 0; i < ins.
size(); ++i)
180 remappedInputs.
add (ins[i].getIntValue());
182 for (
int i = 0; i < outs.
size(); ++i)
183 remappedOutputs.
add (outs[i].getIntValue());
void clearActiveBufferRegion() const
Convenient method to clear the buffer if the source is not producing any data.
void setInputChannelMapping(int destChannelIndex, int sourceChannelIndex)
Creates an input channel mapping.
~ChannelRemappingAudioSource() override
Destructor.
bool hasTagName(StringRef possibleTagName) const noexcept
Tests whether this element has a particular tag name.
int numSamples
The number of samples in the buffer which the callback is expected to fill with data.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
Changes the buffer's size or number of channels.
Used to build a tree of elements representing an XML document.
int getRemappedOutputChannel(int outputChannelIndex) const
Returns the output channel to which channel outputChannelIndex of our input audio source will be sent...
ChannelRemappingAudioSource(AudioSource *source, bool deleteSourceWhenDeleted)
Creates a remapping source that will pass on audio from the given input.
A special array for holding a list of strings.
void setNumberOfChannelsToProduce(int requiredNumberOfChannels)
Specifies a number of channels that this audio source must produce from its getNextAudioBlock() callb...
int getRemappedInputChannel(int inputChannelIndex) const
Returns the channel from our input that will be sent to channel inputChannelIndex of our input audio ...
ElementType getUnchecked(int index) const
Returns one of the elements in the array, without checking the index passed in.
Base class for objects that can produce a continuous stream of audio.
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Breaks up a string into tokens and adds them to this array.
void getNextAudioBlock(const AudioSourceChannelInfo &) override
Called repeatedly to fetch subsequent blocks of audio data.
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
void clearAllMappings()
Clears any mapped channels.
void setOutputChannelMapping(int sourceChannelIndex, int destChannelIndex)
Creates an output channel mapping.
void restoreFromXml(const XmlElement &)
Restores the mappings from an XML object created by createXML().
int startSample
The first sample in the buffer from which the callback is expected to write data. ...
void clear()
Removes all elements from the array.
int size() const noexcept
Returns the current number of elements in the array.
AudioBuffer< float > * buffer
The destination buffer to fill with audio data.
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.
const String & getStringAttribute(StringRef attributeName) const noexcept
Returns the value of a named attribute.
std::unique_ptr< XmlElement > createXml() const
Returns an XML object to encapsulate the state of the mappings.
void releaseResources() override
Allows the source to release anything it no longer needs after playback has stopped.
int size() const noexcept
Returns the number of strings in the array.
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
Tells the source to prepare for playing.
void copyFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples) noexcept
Copies samples from another buffer to this one.
Used by AudioSource::getNextAudioBlock().
Automatically locks and unlocks a mutex object.
void set(int indexToChange, ParameterType newValue)
Replaces an element with a new value.
void clear() noexcept
Clears all the samples in all channels.