I have the following code in VS 2022:
#include <pybind11/pybind11.h>
#include <JuceHeader.h>
namespace py = pybind11;
using namespace std;
using namespace juce;
class ErrorLoadingPlugin : public std::exception
{
public:
char* what()
{
return "Error: Could not load plugin.";
}
};
class Plugin
{
juce::AudioPluginFormatManager manager;
std::unique_ptr< AudioPluginInstance > instance;
public:
Plugin(string filepath, string formatname, int bitrate, int buffersize)
{
PluginDescription desc;
desc.fileOrIdentifier = filepath;
desc.pluginFormatName = formatname;
juce::String errmsg;
this->manager = juce::AudioPluginFormatManager();
this->instance = manager.createPluginInstance(desc, bitrate, buffersize, errmsg);
if (this->instance == nullptr)
{
throw ErrorLoadingPlugin();
};
};
};
PYBIND11_MODULE(PyMusic, m)
{
py::register_exception<ErrorLoadingPlugin>(module, "ErrorLoadingPlugin");
py::class_<Plugin>(m, "Pet")
.def(py::init<string, string, int, int>());
}
When I try to compile, I get the error “Attempting to reference a deleted function” in the line this->manager = juce::AudioPluginFormatManager();.
If I try to change it to
auto temp = juce::AudioPluginFormatManager();
this->manager = temp;
I get the same error but on the this->manager = temp line.
In another project I have the code:
#include <JuceHeader.h>
#include <iostream>
#include <pybind11/pybind11.h>
namespace py = pybind11;
using namespace std;
int main(int argc, char* argv[])
{
juce::PluginDescription desc;
desc.fileOrIdentifier = "D:\\soundshop\\vst\\Synth1V113beta3\\Synth1\\Synth1 VST64.dll";
desc.pluginFormatName = "VST3";
juce::String errmsg;
juce::AudioPluginFormatManager manager = juce::AudioPluginFormatManager();
auto instance = manager.createPluginInstance(desc, 44100, 512, errmsg);
cout << errmsg;
return 0;
}
And that compiles and runs just fine.
I have no idea how to get around this error.
