Best practice to create a new internal plugin

I want to create a class that has access to an audio buffer and can modify the values inside it, and I want to use this on the master output of my Tracktion Engine app (It needs to support having multiple instances though). I have done some research and it seems like te::plugin is the answer to my question and I can edit the buffer in the void applyToBuffer function.
But the problem is that I somehow cannot instantiate the plugin and add it to the master track pluginList. I’ve tried the code below which somehow calls the destructor immediately afterwards:

    auto id = edit->createNewItemID();
    id.writeID(edit->state, nullptr);
    this->plugin = std::make_shared<PluginClass>(PluginCreationInfo(*edit, edit->state, true));
    edit->getMasterPluginList().insertPlugin(this->plugin.get(), 0, &selectionManager);

My main question is that is this really the best way to do this kind of operations in Tracktion? I want to be able to insert this class on other Tracks as well. And if yes, what is the best practice to instantiate this plugin and inserting it into any Track of my choice?

That’s generally the correct way. Take a look at the following tutorial and corresponding example for the best way to do this:

1 Like

Thanks a lot, this was helpful! Somehow I missed this when going through the examples. I wish there was some kind of a link between the examples and the online documentation. For example when looking at the te::Plugin documentation in this page it would be a huge help if it mentioned that the DistortionEffectDemo is actually using it.

Yeah, I agree it would be helpful to tie this all together. We’re still in the process of adding documentation though so haven’t really thought of the best way to do it yet.

It probably will use some kind of tagging system though rather than “take a look at this tutorial” as each tutorial covers many topics but not the entirety of a complex class.

General advise would be to work your way through all of the tutorials first though. There’s not many and they’re quite simple and cover the most important parts of Tracktion Engine.

1 Like