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
void setInputChannelMapping(int destChannelIndex, int sourceChannelIndex)
~ChannelRemappingAudioSource() override
bool hasTagName(StringRef possibleTagName) const noexcept
void add(const ElementType &newElement)
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
int getRemappedOutputChannel(int outputChannelIndex) const
ChannelRemappingAudioSource(AudioSource *source, bool deleteSourceWhenDeleted)
void setNumberOfChannelsToProduce(int requiredNumberOfChannels)
int getRemappedInputChannel(int inputChannelIndex) const
ElementType getUnchecked(int index) const
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
void getNextAudioBlock(const AudioSourceChannelInfo &) override
int getNumChannels() const noexcept
void setOutputChannelMapping(int sourceChannelIndex, int destChannelIndex)
void restoreFromXml(const XmlElement &)
int size() const noexcept
AudioBuffer< float > * buffer
void addFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples, Type gainToApplyToSource=Type(1)) noexcept
const String & getStringAttribute(StringRef attributeName) const noexcept
std::unique_ptr< XmlElement > createXml() const
void releaseResources() override
int size() const noexcept
void prepareToPlay(int samplesPerBlockExpected, double sampleRate) override
void copyFrom(int destChannel, int destStartSample, const AudioBuffer &source, int sourceChannel, int sourceStartSample, int numSamples) noexcept
void set(int indexToChange, ParameterType newValue)