46template <
typename MonoProcessorType,
typename StateType>
51 ProcessorDuplicator (
typename StateType::Ptr stateToUse) : state (std::move (stateToUse)) {}
60 processors.
add (
new MonoProcessorType (state));
65 for (
auto* p : processors)
66 p->prepare (monoSpec);
69 void reset()
noexcept {
for (
auto* p : processors) p->reset(); }
71 template<
typename ProcessContext>
72 void process (
const ProcessContext& context)
noexcept
74 jassert ((
int) context.getInputBlock().getNumChannels() <= processors.
size());
75 jassert ((
int) context.getOutputBlock().getNumChannels() <= processors.
size());
77 auto numChannels =
static_cast<size_t> (jmin (context.getInputBlock().getNumChannels(),
78 context.getOutputBlock().getNumChannels()));
80 for (
size_t chan = 0; chan < numChannels; ++chan)
81 processors[(
int) chan]->process (MonoProcessContext<ProcessContext> (context, chan));
84 typename StateType::Ptr state;
87 template <
typename ProcessContext>
88 struct MonoProcessContext :
public ProcessContext
90 MonoProcessContext (
const ProcessContext& multiChannelContext,
size_t channelToUse)
91 : ProcessContext (multiChannelContext), channel (channelToUse)
96 typename ProcessContext::ConstAudioBlockType getInputBlock()
const noexcept {
return ProcessContext::getInputBlock() .getSingleChannelBlock (channel); }
97 typename ProcessContext::AudioBlockType getOutputBlock()
const noexcept {
return ProcessContext::getOutputBlock().getSingleChannelBlock (channel); }
int size() const noexcept
Returns the number of items currently in the array.
ObjectClass * add(ObjectClass *newObject)
Appends a new object to the end of the array.
void removeRange(int startIndex, int numberToRemove, bool deleteObjects=true)
Removes a range of objects from the array.
uint32 numChannels
The number of channels that the process() method will be expected to handle.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
Converts a mono processor class into a multi-channel version by duplicating it and applying multichan...