From 5d20ec3994a702f7b001baa561e3717307974d8b Mon Sep 17 00:00:00 2001 From: fwcd Date: Fri, 15 Nov 2024 01:01:01 +0100 Subject: [PATCH] AudioUnitBackend: Load music effects too --- .../backends/audiounit/audiounitbackend.mm | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/effects/backends/audiounit/audiounitbackend.mm b/src/effects/backends/audiounit/audiounitbackend.mm index 8e7b839b259..fa58e80f432 100644 --- a/src/effects/backends/audiounit/audiounitbackend.mm +++ b/src/effects/backends/audiounit/audiounitbackend.mm @@ -18,7 +18,7 @@ /// An effects backend for Audio Unit (AU) plugins. macOS-only. class AudioUnitBackend : public EffectsBackend { public: - AudioUnitBackend() : m_componentsById([[NSDictionary alloc] init]) { + AudioUnitBackend() : m_componentsById([[NSMutableDictionary alloc] init]) { loadAudioUnits(); } @@ -59,18 +59,23 @@ bool canInstantiateEffect(const QString& effectId) const override { } private: - NSDictionary* m_componentsById; + NSMutableDictionary* m_componentsById; QHash m_manifestsById; void loadAudioUnits() { qDebug() << "Loading audio units..."; + loadAudioUnitsOfType(kAudioUnitType_Effect); + loadAudioUnitsOfType(kAudioUnitType_MusicEffect); + } + + void loadAudioUnitsOfType(OSType componentType) { // See // https://developer.apple.com/documentation/audiotoolbox/audio_unit_v3_plug-ins/incorporating_audio_effects_and_instruments?language=objc // Create a query for audio components AudioComponentDescription description = { - .componentType = kAudioUnitType_Effect, + .componentType = componentType, .componentSubType = 0, .componentManufacturer = 0, .componentFlags = 0, @@ -85,10 +90,6 @@ void loadAudioUnits() { auto components = [manager componentsMatchingDescription:description]; // Assign ids to the components - NSMutableDictionary* componentsById = - [[NSMutableDictionary alloc] init]; - QHash manifestsById; - for (AVAudioUnitComponent* component in components) { qDebug() << "Found audio unit" << [component name]; @@ -97,13 +98,10 @@ void loadAudioUnits() { [component manufacturerName], [component name], [component versionString]]); - componentsById[effectId.toNSString()] = component; - manifestsById[effectId] = EffectManifestPointer( + m_componentsById[effectId.toNSString()] = component; + m_manifestsById[effectId] = EffectManifestPointer( new AudioUnitManifest(effectId, component)); } - - m_componentsById = componentsById; - m_manifestsById = manifestsById; } };