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


#1

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).


#2

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…