# Plugin Multiple Callbacks on Create, Release, and SetDataParameter

**URL:** https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338
**Category:** FMOD Engine
**Created:** [December 21, 2019, 2:20pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338 "2019-12-21T14:20:54Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![matiaslizana](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/matiaslizana/32/185_2.png) [@matiaslizana](https://qa.fmod.com/u/matiaslizana)
#### Post date: [December 21, 2019, 2:20pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/1 "2019-12-21T14:20:54Z")

</div>

Hi, I’m developing a plugin and I don’t know why when I load one instance on studio, I debug my code and it calls create, setDataParameter and release multiple times (about 10), and this crashes my flow.

I made a blank project, using only 1 event, with 1 track, and instancing my plugin on pre-fader, also setting max-instances of that event to 1 (just for try), but it continues to call create a lot of times.

Can you tell me what’s happening with those callbacks?

Thanks

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [December 22, 2019, 9:17pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/2 "2019-12-22T21:17:28Z")

</div>

I have a similar issue where its not calling the creation callback on creating a user defined DSP with either `System::createDSP()` or `System::createDSPByPlugin()` (Core API)… A fix for these issues would be nice.

---

<div class="post-metadata">

### Author: ![matiaslizana](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/matiaslizana/32/185_2.png) [@matiaslizana](https://qa.fmod.com/u/matiaslizana)
#### Post date: [December 23, 2019, 11:13am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/3 "2019-12-23T11:13:02Z")

</div>

The worst part is for setDataParameter, because I have a bunch of data reading there, and every time I move another setFloatParameter knob I have on the plugin, the setDataParameter is calling and it tries to load again all the info.

It seems like every change on a parameter affects to all callbacks. Also creation and destruction has problems about it as @Sunkin351 says.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [January 7, 2020, 4:02am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/4 "2020-01-07T04:02:29Z")

</div>

Are you able to share the code you are using? Or a small version that reproduces the issue?

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [January 16, 2020, 2:38am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/5 "2020-01-16T02:38:20Z")

</div>

If you are fine with debugging C# code in Visual Studio, I’ll be glad to give you the code I use to reproduce it not calling the creation callback…

> <https://github.com/sunkin351/FmodAudio/blob/master/Examples/CustomDSPExample.cs>

It leaves the plugin state uninitialized causing a debug assertion on line 33, or a NullReferenceException on line 47. (Or on line 253, due to the multi-threaded environment setup within FMOD.)

Though to be fair, I just ported the C++ example to C#, so you’d probably get the same problems there.

Edit: I even put a breakpoint in the Creation Callback to make sure it wasn’t being called on DSP creation.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [January 22, 2020, 3:52am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/6 "2020-01-22T03:52:58Z")

</div>

You may need to check the C# wrapper, I was able to use our C# wrapper and get a custom DSP create callback triggered from a very basic example.

```
using UnityEngine;

public class CustomDSP : MonoBehaviour
{
    FMOD.DSP_CREATECALLBACK createCallback = new FMOD.DSP_CREATECALLBACK(MyDSPCreate);

    private void Start()
    {
        CreateCustomDSP();
    }

    public void CreateCustomDSP()
    {
        FMOD.DSP_DESCRIPTION dspDesc = new FMOD.DSP_DESCRIPTION()
        {
            version = 1,
            create = createCallback,
        };

        FMOD.RESULT result = FMODUnity.RuntimeManager.CoreSystem.createDSP(ref dspDesc, out FMOD.DSP dsp);
        Debug.Log("createDSP : " + result);
    }

    public static FMOD.RESULT MyDSPCreate(ref FMOD.DSP_STATE state)
    {
        Debug.Log("MyDSPCreate Callback");
        return FMOD.RESULT.OK;
    }
}
```

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [January 23, 2020, 11:05pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/7 "2020-01-23T23:05:58Z")

</div>

I wrote the C# wrapper I’m using… FmodAudio. Much research went into its construction. If you wanna check my work, by all means. Me and OP both have similar issues with FMOD dsp callbacks.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [January 28, 2020, 3:17am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/8 "2020-01-28T03:17:52Z")

</div>

At this point I have not been able to reproduce the issue with or without our C# wrapper.

If anyone can provide a test project that reproduces the issue I can look into this further.

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [March 15, 2020, 10:49pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/9 "2020-03-15T22:49:36Z")

</div>

Newest patch seems to have fixed it. Though, one issue remains. `FMOD_DSP_STATE::instance` is invalid by the time `FMOD_DSP_DESCRIPTION::release` is called? Why’s this?

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [March 20, 2020, 4:16am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/10 "2020-03-20T04:16:07Z")

</div>

The instance should always be valid, is it possible you are overwriting it at all?

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [March 20, 2020, 5:56pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/11 "2020-03-20T17:56:08Z")

</div>

I am not. The handle is as it always was on my end.

Another small detail: Is the `FMOD_DSP_DESCRIPTION::release` callback decoupled at all from `FMOD_DSP_Release()`? In my wrapper, I’m releasing a resource right after but that resource is needed from the callback… (In short, my resource is unavailable by the time the callback is called…)

Edit: That could be why the handle is invalid by the time the callback is called.

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [March 24, 2020, 9:43pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/12 "2020-03-24T21:43:34Z")

</div>

Calling [`FMOD_DSP_Release`](https://fmod.com/resources/documentation-api?version=2.0&page=core-api-dsp.html#dsp_release) will cause the release callback set in the `FMOD_DSP_DESCRIPTION` to be called, at which point the instance will still be valid.

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [March 26, 2020, 7:43pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/13 "2020-03-26T19:43:49Z")

</div>

`FMOD_DSP_GetUserData()` reported it was invalid by that time. (And previous calls to the method from other callbacks worked fine, so…)

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [April 30, 2020, 4:13am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/14 "2020-04-30T04:13:55Z")

</div>

Was this ever addressed?

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [May 4, 2020, 12:16am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/15 "2020-05-04T00:16:40Z")

</div>

> [@cameron-fmod](#):
>
> At this point I have not been able to reproduce the issue with or without our C# wrapper.
> 
> If anyone can provide a test project that reproduces the issue I can look into this further.

Any attempt to reproduce the issue has failed.

---

<div class="post-metadata">

### Author: ![Sunkin351](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/sunkin351/32/1140_2.png) [@Sunkin351](https://qa.fmod.com/u/Sunkin351)
#### Post date: [June 25, 2020, 9:40pm UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/16 "2020-06-25T21:40:30Z")

</div>

In the end, I was able to get everything working, and find out an important piece of information regarding DSP release/destruction. The release callback is decoupled from FMOD\_DSP\_Release() and is called at some later point in time. Not knowing this caused me some issues. But all is well.

---

<div class="post-metadata">

### Author: ![klater](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@klater](https://qa.fmod.com/u/klater)
#### Post date: [February 28, 2023, 7:48am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/17 "2023-02-28T07:48:58Z")

</div>

I have a similar issue where the Create callback is called whenever I change any parameter. To make sure it’s not just happening in my own plugin project, I simply added

```auto
FMOD_DSP_LOG(dsp_state, FMOD_DEBUG_LEVEL_LOG, "Create_Callback", "Create_Callback is just called");

```

to FMOD\_Gain\_dspcreate() in the example fmod\_gain project, and it’s doing the same thing.  
Here’s the logs that I’ve been getting whenever I move the gain knob.

```auto
23:42:30 Macro: Set Gain [#2 times]
23:42:30 fmod_gain.cpp(212), Create_Callback(): Create_Callback is just called
23:42:30 fmod_bank_loader.cpp(125), Manager::readBank(): fileversion = 141, compatVersion = 140 (oldest = 44, newest = 141)
23:42:30 Macro: Set Gain
23:42:30 fmod_gain.cpp(212), Create_Callback(): Create_Callback is just called
23:42:30 fmod_bank_loader.cpp(125), Manager::readBank(): fileversion = 141, compatVersion = 140 (oldest = 44, newest = 141)
23:42:30 Macro: Set Gain [#3 times]
23:42:30 fmod_gain.cpp(212), Create_Callback(): Create_Callback is just called
23:42:30 fmod_bank_loader.cpp(125), Manager::readBank(): fileversion = 141, compatVersion = 140 (oldest = 44, newest = 141)

```

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [March 7, 2023, 1:03am UTC](https://qa.fmod.com/t/plugin-multiple-callbacks-on-create-release-and-setdataparameter/15338/18 "2023-03-07T01:03:33Z")

</div>

I have not been able to reproduce this myself, although if you are using Live Update then the Studio API might be instantiating the DSP each time it’s touched.
