Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper way to use OpenBLAS and AI model with this template #2

Open
SuperKogito opened this issue Feb 14, 2024 · 0 comments
Open

Proper way to use OpenBLAS and AI model with this template #2

SuperKogito opened this issue Feb 14, 2024 · 0 comments

Comments

@SuperKogito
Copy link

First of all, thank you for sharing this great project ❤️ It is imo a life saver for anyone getting started with Audio plugins.
I already tested it on Windows 10 (mingw) and Ubuntu 22.04 and it works on both.

I am currently trying to develop an AI based plugin effect.
My Plugin uses OpenBLAS and although the resulting VST3 works on my machine, but when I try it on other machines it is not scanned/ recognised by the DAW.

I suspect this to be related to multi-threading issues when using OpenBLAS, or my architecture. I also noticed that my inference/ run is invoked even though my plugin is paused/ stopped. Hence I would like to ask if there is a way to handle this; something
something like void deactivate() or some way to bridge the run logic in this case. Does this make any sense?

My second question; what would be a suitable architecture for loading an AI model, invoking it and then cleaning it in the Audio plugin? atm I use this approach:

#include "DistrhoPlugin.hpp"

START_NAMESPACE_DISTRHO

// --------------------------------------------------------------------------------------------------------------------

class ImGuiPluginDSP : public Plugin
{

    // inits ...
    Model* model;

public:
   /**
      Plugin class constructor.@n
      You must set all parameter values to their defaults, matching ParameterRanges::def.
    */
    ImGuiPluginDSP()
        : Plugin(kParamCount, 0, 0), // parameters, programs, states
          model(nullptr)
    {
        // load model weights ...
       load_weights();
    }

    ~ImGuiPluginDSP() override
    {
        // free model
         free_model();
        // free weights
        free_weights();
    }

protected:
    // ----------------------------------------------------------------------------------------------------------------
    // Information

...

    // ----------------------------------------------------------------------------------------------------------------
    // Internal data



    // ----------------------------------------------------------------------------------------------------------------
    // Audio/MIDI Processing

   /**
      Activate this plugin.
    */
    void activate() override
    {
        // allocate and init model
	model_init();
    }

   /**
      Run/process function for plugins without MIDI input.
      @note Some parameters might be null if there are no audio inputs or outputs.
    */
    void run(const float** inputs, float** outputs, uint32_t frames) override
    {
        // run model inference/ routine
        model_process(model, inputs[0], inputs[1], frames, outputs);
        
    }

    // ----------------------------------------------------------------------------------------------------------------
    // Callbacks (optional)



    // ----------------------------------------------------------------------------------------------------------------

    DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImGuiPluginDSP)
};

// --------------------------------------------------------------------------------------------------------------------

Plugin* createPlugin()
{
    return new ImGuiPluginDSP();
}

// --------------------------------------------------------------------------------------------------------------------

END_NAMESPACE_DISTRHO

I should also mention that my model code is in C (not sure if this is relevent).
I am using windows 10 with mingw 13.2.0
I would appreciate any response. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant