Going from file path to instance of plugin?

Hi

I am new to programming with JUCE and Im looking at Tracktion as a candidate as the main framework for a project. Just to test it out I wanted to do something (presumably) very simple:

  1. Instantiate a VST instrument and a track
  2. Load a midi clip onto that track
  3. Have the Instrument play the midi clip and render the audio output as an .wav file

However I am no where near my goal, stuck at step #1. Specifically I need to go from a file path pointing to the VST instrument to an instance of this instrument (Its a CLI project that takes the file path as a parameter). But honestly I don’t even know where to start as I find the API very confusing. Hoping to get some help from some of the gifted minds in this forum.

My plan was to first create an Edit. And place a Track in that Edit. Then load the Instrument onto the Track from the path. Then load the MidiClip to that Track (also from a path). And then finally Render the whole thing… So far I have only managed to create the Edit and Inserted an AudioTrack onto it… I can also render the whole edit with an audio file loaded onto the audio track (just to mock the plugin)… But I don’t know how to put the instrument in there and play a midi clip. I thought there would be some kind of Plugin Class with a “load_plugin_from_path(string pathToVst)” method. But it seems like the road is a bit tricky’er.

I already build the example projects and their code and I looked through this fora. The closest thing I could find was this thread: AudioProcessorGraph stops working after loading plugin instance in host but the authors code is from 2018 and maybe the API changed a bit since, but I cannot get that working either.

If someone could assist in figuring out
a) What track class to load a plugin onto (given I also need to play midi later on…)
b) What plugin class to use and how to initialise it

I think Tracktion looks awesome and really like to learn this better so hoping someone can pitch in with some thoughts of this.

Thanks!

I guess, the link you’ve shared got nothing to do with tracktion engine. For loading a plugin to a track, try something like

track->pluginList.insertPlugin(yourPlugin, index, nullptr);

Hmmm alright that could be a way of inserting my instrument plugin to the track. Thanks for the reply! However right now actually don’t even have my plugin instantiated yet. Any ideas on how I actually obtain “yourPlugin” from the file path to the plugin .vst file? I have been browsing this for long: TracktionEngine: Class List but I am just not getting anywhere… Any pointers in the right direction would be sincerely appreciated.

Tracktion comes with several demo projects in the “examples” folder. For example, the MidiRecordingDemo will show you how to use plugins.

You first have the system scan for plugins, which creates the plugin list. Then you have plugins that can be inserted to tracks. All of that code is in the demo.

Juce can be a bit confusing when it comes to plugins/descriptions/formats and so on. I tried to poke a minimal example for this. Not sure, if there are any errors in this, but it seems to work.

    //this can cache all your plugins.
    auto& knownPluginList = engine.getPluginManager().knownPluginList;

    //the plugin needs to be exists
    juce::File pluginFile("~/.vst3/TAL-NoiseMaker.vst3");

    //these will be filled by the next function, so we get the pluginDescription
    static juce::OwnedArray<juce::PluginDescription> pluginDescriptions;
    static juce::VST3PluginFormat vst3PluginFormat;

    //now you can add your plugin to the knownPluginList
    knownPluginList.scanAndAddFile(juce::String(pluginFile.getFullPathName()), true, pluginDescriptions, vst3PluginFormat);

    //get the plugin
    auto plug = edit->getPluginCache().createNewPlugin(te::ExternalPlugin::xmlTypeName, *pluginDescriptions.getLast());

    //add it to the track
    track->pluginList.insertPlugin(plug, track->pluginList.size() + 1, nullptr);

Hope that helps.

1 Like