# getAudioPluginInstance returns nullptr

**URL:** <https://forum.juce.com/t/getaudioplugininstance-returns-nullptr/64795>\
**Category:** Tracktion Engine\
**Created:** [January 4, 2025, 2:17pm UTC](https://forum.juce.com/t/getaudioplugininstance-returns-nullptr/64795 "2025-01-04T14:17:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![f2ldaletnany](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@f2ldaletnany](https://forum.juce.com/u/f2ldaletnany)\
**Post date:** [January 4, 2025, 2:17pm UTC](https://forum.juce.com/t/getaudioplugininstance-returns-nullptr/64795/1 "2025-01-04T14:17:20Z")

</div>

Hey,

I have an application consisting of a window with a button. This button opens up a filechooser window. When a file is chosen, it gets stored in a te::ExternalPlugin variable. This all works fine, however when i run getAudioPluginInstance(), nullptr is returned.

Why is this? Am i doing something wrong when setting up pluginDescription?

```auto
loadedPlugin->getName()

```

and

```auto
pluginDescription.pluginFormatName

```

both work correctly.

this is the relevant code:

```auto
juce::PluginDescription pluginDescription;
pluginDescription.fileOrIdentifier = selectedFile.getFullPathName();
pluginDescription.name = selectedFile.getFileNameWithoutExtension();
juce::String fileExtension = selectedFile.getFileExtension(); 
juce::String cleanedExtension = fileExtension.substring(1);   
pluginDescription.pluginFormatName = cleanedExtension;
auto pluginTree = tracktion_engine::ExternalPlugin::create(engine, pluginDescription);

if(pluginTree.isValid())
{
    tracktion_engine::PluginCreationInfo info{
                *edit, pluginTree, true
    };
    loadedPlugin = std::make_unique<tracktion_engine::ExternalPlugin>(info);
}

if (loadedPlugin)
{
    juce::Logger::writeToLog("Plugin loaded successfully: " + loadedPlugin->getName());
    juce::Logger::writeToLog("Plugin Format: " + pluginDescription.pluginFormatName);

    juce::AudioPluginInstance* audioProcessor = loadedPlugin->getAudioPluginInstance();
    
    //this is where the problem is
    if (audioProcessor != nullptr)
    {
        if (auto* editor = audioProcessor->createEditorIfNeeded())
        {
            pluginEditor.reset(editor);
            addAndMakeVisible(pluginEditor.get());
            resized();
        }
        else
        {
            juce::Logger::writeToLog("Failed to create plugin GUI.");
        }
    }
    else 
    {
        juce::Logger::writeToLog("Failed to get audioProcessor: ");
    }
}

```

this is all of the source code  
[Main.cpp](https://forum.juce.com/uploads/short-url/hsCW4FWxfRsKhF7rdir9SysAQSJ.cpp) (2.3 KB)  
[MainComponent.cpp](https://forum.juce.com/uploads/short-url/lFTKKm3cS7TB7RkRtlTCy7LsPOV.cpp) (6.1 KB)  
[MainComponent.h](https://forum.juce.com/uploads/short-url/8pdjB4ZUOYNKVCViljcc2meQDdd.h) (1.1 KB)

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [January 8, 2025, 12:11pm UTC](https://forum.juce.com/t/getaudioplugininstance-returns-nullptr/64795/2 "2025-01-08T12:11:10Z")

</div>

You’d normally create the plugin via the Edit’s PluginCache:

```auto
auto plugin = edit.getPluginCache().createNewPlugin (ExternalPlugin::xmlTypeName, pluginDescription)

```

But that’s separate to your issue.  
Where are you getting your `juce::PluginDescription` from?  
That usually comes from `juce::KnownPluginList`, there’s an instance in `Engine::getPluginManager()` you can use but you’ll have to do a plugin scan first or juce won’t know how to load the plugin.
