mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-04 03:40:07 +00:00
AU: Tidy up ChannelRemapper
This commit is contained in:
parent
2073e46e79
commit
43280c3f7f
3 changed files with 15 additions and 22 deletions
|
|
@ -131,8 +131,7 @@ public:
|
|||
: AudioProcessorHolder (activePlugins.size() + activeUIs.size() == 0),
|
||||
MusicDeviceBase (component,
|
||||
(UInt32) AudioUnitHelpers::getBusCountForWrapper (*juceFilter, true),
|
||||
(UInt32) AudioUnitHelpers::getBusCountForWrapper (*juceFilter, false)),
|
||||
mapper (*juceFilter)
|
||||
(UInt32) AudioUnitHelpers::getBusCountForWrapper (*juceFilter, false))
|
||||
{
|
||||
inParameterChangedCallback = false;
|
||||
|
||||
|
|
@ -208,7 +207,7 @@ public:
|
|||
if ((err = MusicDeviceBase::Initialize()) != noErr)
|
||||
return err;
|
||||
|
||||
mapper.alloc();
|
||||
mapper.alloc (*juceFilter);
|
||||
pulledSucceeded.calloc (static_cast<size_t> (AudioUnitHelpers::getBusCountForWrapper (*juceFilter, true)));
|
||||
|
||||
prepareToPlay();
|
||||
|
|
|
|||
|
|
@ -421,16 +421,14 @@ public:
|
|||
AudioComponentInstantiationOptions options,
|
||||
NSError** error)
|
||||
: JuceAudioUnitv3Base (descr, options, error),
|
||||
processorHolder (processor),
|
||||
mapper (*processorHolder->get())
|
||||
processorHolder (processor)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
JuceAudioUnitv3 (AUAudioUnit* audioUnit, AudioComponentDescription, AudioComponentInstantiationOptions, NSError**)
|
||||
: JuceAudioUnitv3Base (audioUnit),
|
||||
processorHolder (new AudioProcessorHolder (createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnitv3))),
|
||||
mapper (*processorHolder->get())
|
||||
processorHolder (new AudioProcessorHolder (createPluginFilterOfType (AudioProcessor::wrapperType_AudioUnitv3)))
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
|
@ -844,7 +842,7 @@ public:
|
|||
allocateBusBuffer (true);
|
||||
allocateBusBuffer (false);
|
||||
|
||||
mapper.alloc();
|
||||
mapper.alloc (processor);
|
||||
|
||||
audioBuffer.prepare (AudioUnitHelpers::getBusesLayout (&processor), static_cast<int> (maxFrames));
|
||||
|
||||
|
|
|
|||
|
|
@ -38,22 +38,19 @@ struct AudioUnitHelpers
|
|||
class ChannelRemapper
|
||||
{
|
||||
public:
|
||||
ChannelRemapper (AudioProcessor& p) : processor (p), inputLayoutMap (nullptr), outputLayoutMap (nullptr) {}
|
||||
~ChannelRemapper() {}
|
||||
|
||||
void alloc()
|
||||
void alloc (AudioProcessor& processor)
|
||||
{
|
||||
const int numInputBuses = AudioUnitHelpers::getBusCount (processor, true);
|
||||
const int numOutputBuses = AudioUnitHelpers::getBusCount (processor, false);
|
||||
|
||||
initializeChannelMapArray (true, numInputBuses);
|
||||
initializeChannelMapArray (false, numOutputBuses);
|
||||
initializeChannelMapArray (processor, true, numInputBuses);
|
||||
initializeChannelMapArray (processor, false, numOutputBuses);
|
||||
|
||||
for (int busIdx = 0; busIdx < numInputBuses; ++busIdx)
|
||||
fillLayoutChannelMaps (true, busIdx);
|
||||
fillLayoutChannelMaps (processor, true, busIdx);
|
||||
|
||||
for (int busIdx = 0; busIdx < numOutputBuses; ++busIdx)
|
||||
fillLayoutChannelMaps (false, busIdx);
|
||||
fillLayoutChannelMaps (processor, false, busIdx);
|
||||
}
|
||||
|
||||
void release()
|
||||
|
|
@ -69,14 +66,13 @@ struct AudioUnitHelpers
|
|||
|
||||
private:
|
||||
//==============================================================================
|
||||
AudioProcessor& processor;
|
||||
HeapBlock<int*> inputLayoutMapPtrStorage, outputLayoutMapPtrStorage;
|
||||
HeapBlock<int> inputLayoutMapStorage, outputLayoutMapStorage;
|
||||
int** inputLayoutMap;
|
||||
int** outputLayoutMap;
|
||||
int** inputLayoutMap = nullptr;
|
||||
int** outputLayoutMap = nullptr;
|
||||
|
||||
//==============================================================================
|
||||
void initializeChannelMapArray (bool isInput, const int numBuses)
|
||||
void initializeChannelMapArray (AudioProcessor& processor, bool isInput, const int numBuses)
|
||||
{
|
||||
HeapBlock<int*>& layoutMapPtrStorage = isInput ? inputLayoutMapPtrStorage : outputLayoutMapPtrStorage;
|
||||
HeapBlock<int>& layoutMapStorage = isInput ? inputLayoutMapStorage : outputLayoutMapStorage;
|
||||
|
|
@ -88,7 +84,7 @@ struct AudioUnitHelpers
|
|||
layoutMapPtrStorage.calloc (static_cast<size_t> (numBuses));
|
||||
layoutMapStorage.calloc (static_cast<size_t> (isInput ? totalInChannels : totalOutChannels));
|
||||
|
||||
layoutMap = layoutMapPtrStorage. get();
|
||||
layoutMap = layoutMapPtrStorage.get();
|
||||
|
||||
int ch = 0;
|
||||
for (int busIdx = 0; busIdx < numBuses; ++busIdx)
|
||||
|
|
@ -98,7 +94,7 @@ struct AudioUnitHelpers
|
|||
}
|
||||
}
|
||||
|
||||
void fillLayoutChannelMaps (bool isInput, int busNr)
|
||||
void fillLayoutChannelMaps (AudioProcessor& processor, bool isInput, int busNr)
|
||||
{
|
||||
int* layoutMap = (isInput ? inputLayoutMap : outputLayoutMap)[busNr];
|
||||
auto channelFormat = processor.getChannelLayoutOfBus (isInput, busNr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue