Greetings,
I have a very simple project with 2 events and each one contains a stream and an instance of my custom plugin.
When I try to use the API I noticed that it always uses only 1 instance of the plugin.
Is it possible to use an instance for each event?
This is the code I use to load the FMOD project using Studio API
result = FMOD::Studio::System::create(&m_system);
SucceededOrWarn("[FMOD] Cannot create System.", result);
result = m_system->getCoreSystem(&m_coreSystem);
SucceededOrWarn("[FMOD] Cannot get coreSystem", result);
result = m_coreSystem->setPluginPath("D:\\TEST\\Plugins");
SucceededOrWarn("[FMOD] Cannot set plugin path", result);
unsigned int pluginHandle;
result = m_coreSystem->loadPlugin("MyCustomPlugin", &pluginHandle, FMOD_PLUGINTYPE_DSP);
SucceededOrWarn("[FMOD] Cannot load the plugin", result);
result = m_coreSystem->setSoftwareFormat(0, FMOD_SPEAKERMODE_STEREO, 0);
SucceededOrWarn("[FMOD] Cannot set software format", result);
result = m_system->initialize(1024, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, nullptr);
SucceededOrWarn("[FMOD] Cannot initialize system", result);
result = m_system->loadBankFile("D:\\TEST\\Master.bank", FMOD_STUDIO_LOAD_BANK_NORMAL, &m_masterBank);
SucceededOrWarn("[FMOD] Cannot load Master.bank", result);
result = m_system->loadBankFile("D:\\TEST\\Master.strings.bank", FMOD_STUDIO_LOAD_BANK_NORMAL, &m_stringsBank);
SucceededOrWarn("[FMOD] Cannot load Master.strings.bank", result);
result = m_system->getEvent("event:/dimmi_L", &m_eventDescriptionLeft);
SucceededOrWarn("[FMOD] Cannot get event dimmi_L.", result);
result = m_eventDescriptionLeft->createInstance(&m_eventInstanceLeft);
SucceededOrWarn("[FMOD] Cannot create event instance", result);
result = m_system->getEvent("event:/dimmi_R", &m_eventDescriptionRight);
SucceededOrWarn("[FMOD] Cannot get event dimmi_R.", result);
result = m_eventDescriptionRight->createInstance(&m_eventInstanceRight);
SucceededOrWarn("[FMOD] Cannot create event instance", result);
Hi,
What version of FMOD are you using?
How are you accessing the plugin? I can see it being created but could I get a code snippet when you are trying to interact with it?
Hi!
I’m using FMOD Studio 2.02.09 and FMOD Studio API 202113
Here the code on how I interact with the events:
result = m_eventInstanceLeft->start();
SucceededOrWarn("[FMOD] Cannot start event Left", result);
result = m_eventInstanceRight->start();
SucceededOrWarn("[FMOD] Cannot start event Right", result);
// Position the listener at the origin
m_attributes_left = {{ 0 }};
m_attributes_left.forward.z = 1.0f;
m_attributes_left.up.y = 1.0f;
m_system->setListenerAttributes(0, &m_attributes_left);
m_attributes_right = {{ 0 }};
m_attributes_right.forward.z = 1.0f;
m_attributes_right.up.y = 1.0f;
.....
.....
.....
// update left/right passing parameters to plugin
m_attributes_left.position.x = float(x1);
m_attributes_left.position.y = float(y1);
m_attributes_left.position.z = float(z1);
m_eventInstanceLeft->set3DAttributes(&m_attributes_left);
m_attributes_right.position.x = float(x2);
m_attributes_right.position.y = float(y2);
m_attributes_right.position.z = float(z2);
m_eventInstanceRight->set3DAttributes(&m_attributes_right);
Note that with the same code if I create a second copy of my plugin called “My Custom Plugin 2” (MyCustomPlugin2.dll) and assign it to the event:dimmi_R in FMOD Studio and load at startup like this:
unsigned int pluginHandle;
result = m_coreSystem->loadPlugin("MyCustomPlugin", &pluginHandle, FMOD_PLUGINTYPE_DSP);
SucceededOrWarn("[FMOD] Cannot load the plugin", result);
unsigned int pluginHandle2;
result = m_coreSystem->loadPlugin("MyCustomPlugin2", &pluginHandle2, FMOD_PLUGINTYPE_DSP);
SucceededOrWarn("[FMOD] Cannot load the plugin 2", result);
It works perfectly. Could be a problem on the plugin itself ? Is there an option when the plugin is
created to specify that must be instanced more than once ?
Thank you for your support.
Giuseppe
1 Like
Hello,
I solved the problem with my plugin.
Instead of initialize global variables on event sys_register I moved everything in a class and initialized each time the CREATE event is called.
thank you
Giuseppe
1 Like
Hi.
Thank you for sharing the solution.