Audio Units without 'thng' resource: how to load from file?

It seems that, when looking at getComponentDescFromFile(…) in juce_AudioUnitPluginFormat.mm, newer-style Audio Units that do not have a ‘thng’ resource anymore cannot be loaded by using a file explorer or dragging-and-dropping the .component file onto JUCE’s plugin host. Is there any way to achieve this at all, or is it just not possible to load new AUs directly from file (they work using the “internal” AU scanner, of course).

1 Like

I have now replaced the lines 239-269 in juce_AudioUnitPluginFormat.mm with this:

if (Count1Resources(thngType) > 0)
            {
                for (ResourceIndex i = 1; i <= Count1Resources (thngType); ++i)
                {
                    if (Handle h = Get1IndResource (thngType, i))
                    {
                        HLock (h);
                        const uint32* const types = (const uint32*) *h;
                        
                        if (types[0] == kAudioUnitType_MusicDevice
                            || types[0] == kAudioUnitType_MusicEffect
                            || types[0] == kAudioUnitType_Effect
                            || types[0] == kAudioUnitType_Generator
                            || types[0] == kAudioUnitType_Panner
                            || types[0] == kAudioUnitType_Mixer
                            || types[0] == kAudioUnitType_MIDIProcessor)
                        {
                            desc.componentType = types[0];
                            desc.componentSubType = types[1];
                            desc.componentManufacturer = types[2];
                            
                            if (AudioComponent comp = AudioComponentFindNext (0, &desc))
                                getNameAndManufacturer (comp, name, manufacturer);
                            
                            break;
                        }
                        
                        HUnlock (h);
                        ReleaseResource (h);
                    }
                }
            }
            else
            {
                NSBundle *bundle = [[NSBundle alloc] initWithPath:(NSString*) fileOrIdentifier.toCFString()];
                NSArray *audioComponents = [bundle objectForInfoDictionaryKey:@"AudioComponents"];
                NSDictionary *dict = audioComponents[0];
                String componentManufacturer = nsStringToJuce((NSString*) dict[@"manufacturer"]);
                String componentType = nsStringToJuce((NSString*) [dict valueForKey:@"type"]);
                String componentSubType = nsStringToJuce((NSString*) [dict valueForKey:@"subtype"]);
                desc.componentManufacturer = stringToOSType(componentManufacturer);
                desc.componentType = stringToOSType(componentType);
                desc.componentSubType = stringToOSType(componentSubType);
            }

Seems to work fine…

2 Likes

I also ran into this problem. Could you submit a PR to juce repo?

This sounds relevant:

From https://developer.apple.com/library/archive/technotes/tn2276/_index.html:

“Because audio units no longer use the Component Manager on Mac OS X Lion or newer, AUPlugIn based audio units do not use resource files ( .r files) or the ’ thng ’ resource to define properties such as kComponentType, kComponentSubType, and kComponentManufactureType. These properties are now specified in the project’s Info.plist file for the audio unit. You can continue to include the Component Manager resource file in the project for backwards compatibility with Mac OS X v10.6.x.”