- Home /
Native Audio Plugin resetCallback to reset the plug in to its initial sate?
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!
I've now noticed that if I stop the game from playing, start the game again, stop it again, the next time I press play the plugin functions normally. Which confuses me even more!
Answer by manassehclifford · Dec 03, 2021 at 10:03 AM
Hi I am facing the same issue with my native audio plugin development. have you found a solution for this?. I have a work around where i load an empty audio file into the audio source linked to the mixer and set it in loop. so now every time i reset play my plugin works properly . its not ideal but it works. please let me know if you have figured out a proper solution for this. thanks. ,Hi I am facing the same issue. Have you found a solution for this problem?
Your answer
Follow this Question
Related Questions
Using CVOpenGLTextureCache in Plugin on OSX - Get correct OpenGL context? 0 Answers
Native Plugin: What has to happen in the RenderEvent? 1 Answer
Native Plugin works in editor but not in build 0 Answers
android time cheat plugin problem with broadcastreceiver 1 Answer
Audio signal plug-in? 1 Answer