Browse Source

AUv3 Client: Correctly set default channel layout for buses with more than two channels

v7.0.9
reuk 2 years ago
parent
commit
3b8792d5c5
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 33 additions and 8 deletions
  1. +33
    -8
      modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm

+ 33
- 8
modules/juce_audio_plugin_client/AU/juce_AUv3_Wrapper.mm View File

@@ -1064,18 +1064,43 @@ private:
for (int i = 0; i < numWrapperBuses; ++i)
{
std::unique_ptr<AUAudioUnitBus, NSObjectDeleter> audioUnitBus;
using AVAudioFormatPtr = std::unique_ptr<AVAudioFormat, NSObjectDeleter>;
const auto audioFormat = [&]() -> AVAudioFormatPtr
{
const auto channels = numProcessorBuses <= i ? 2 : processor.getChannelCountOfBus (isInput, i);
std::unique_ptr<AVAudioFormat, NSObjectDeleter> defaultFormat ([[AVAudioFormat alloc] initStandardFormatWithSampleRate: kDefaultSampleRate
channels: static_cast<AVAudioChannelCount> (channels)]);
const auto tag = i < numProcessorBuses ? CoreAudioLayouts::toCoreAudio (processor.getChannelLayoutOfBus (isInput, i))
: kAudioChannelLayoutTag_Stereo;
const std::unique_ptr<AVAudioChannelLayout, NSObjectDeleter> layout { [[AVAudioChannelLayout alloc] initWithLayoutTag: tag] };
audioUnitBus.reset ([[AUAudioUnitBus alloc] initWithFormat: defaultFormat.get()
error: nullptr]);
}
if (auto format = AVAudioFormatPtr { [[AVAudioFormat alloc] initStandardFormatWithSampleRate: kDefaultSampleRate
channelLayout: layout.get()] })
return format;
const auto channels = i < numProcessorBuses ? processor.getChannelCountOfBus (isInput, i)
: 2;
// According to the docs, this will fail if the number of channels is greater than 2.
if (auto format = AVAudioFormatPtr { [[AVAudioFormat alloc] initStandardFormatWithSampleRate: kDefaultSampleRate
channels: static_cast<AVAudioChannelCount> (channels)] })
return format;
jassertfalse;
return nullptr;
}();
using AUAudioUnitBusPtr = std::unique_ptr<AUAudioUnitBus, NSObjectDeleter>;
const auto audioUnitBus = [&]() -> AUAudioUnitBusPtr
{
if (audioFormat != nullptr)
return AUAudioUnitBusPtr { [[AUAudioUnitBus alloc] initWithFormat: audioFormat.get() error: nullptr] };
jassertfalse;
return nullptr;
}();
[array.get() addObject: audioUnitBus.get()];
if (audioUnitBus != nullptr)
[array.get() addObject: audioUnitBus.get()];
}
(isInput ? inputBusses : outputBusses).reset ([[AUAudioUnitBusArray alloc] initWithAudioUnit: au


Loading…
Cancel
Save