I’m building a Native Audio Plugin in C++ and currently having issues when Unity moves from being in play mode to out of play mode. From what I understand from the documentation the call back:
UNITY_AUDIODSP_RESULT UNITY_AUDIODSP_CALLBACK ProcessCallback(UnityAudioEffectState* state, float* inbuffer, float* outbuffer, unsigned int length, int inchannels, int outchannels)
is called even when the engine is not in play mode. The issues I’m having are that when I quit play mode and then hit play again, the audio plugin stops responding to my custom events (in this case, note on and note off messages). I have to unload the plugin and reload it do get it to function again.
I’ve seen in the PluginInterface.h file a callback called:
UnityAudioEffect_ResetCallback reset; // The reset callback is called by the user to bring back the plugin instance into its initial state. Use to avoid clicks or artifacts.
This seems like what I need to do when the engine is not in play mode, so I can reset the plug in and when the engine is in play mode again - start any processing again from scratch.
However, I’m struggling to understand how to invoke this reset call back, does anybody know whether this is from the native C++ code or from within Unity that I call it and what form the callback has to be for it to work or how it is triggered by Unity?
Any help would be greatly appreciated!