ValveSoftware / steam-audio

Steam Audio
https://valvesoftware.github.io/steam-audio/
Apache License 2.0
2.2k stars 152 forks source link

[FMOD, Unity] Steam Audio Spatializer Occlusion Works Only Once Per Gameobject Then Misbehaves #196

Open Sorgon opened 2 years ago

Sorgon commented 2 years ago

(Using steamaudio_fmod_4.0.3, Unity 2019.4.0f1, and FMOD 2.02.04)

I baked audio geometry and set up occlusion to be Simulation-Defined. On a gameobject I have a Steam Audio Source (with occlusion activated) and FMOD emitter.

First the sound will play as expected, but when I try to play the emitter again, there is no sound until I disable occlusion in FMOD live update.

I've tried this with emitters OnEnable, but also tried to play it from script, but the result was the same. Occlusion stops working correctly when I start to play the emitter again.

Sorgon commented 2 years ago

And when I try to use Runtime.PlayOneshot, it doesn't work at all, since there is no way how to add Steam Source to it.

gamesfortourists commented 2 years ago

I have the same issue. If you directly call instance.start() on the Event Emitter's instance, and never call Stop(), it works. Based on a lot of testing, the issue seems to revolve around when the emitter calls release() and clearHandle(). If you never call those, you can reuse the same instance, though this risks memory issues.

I think this has to do with how the Steam Audio FMOD Engine integration handles the FindDSP() function, though I can't be sure. Tests I've run indicate that the first time an Event Emitter creates an instance and calls an event, the Steam Audio Source calls UpdateParameters on FMODStudioEngineSource, which in turn calls FindDSP, which calls "MOD_DSP_getInfo.Invoke(mDSP, getInfoArgs)", and successfully finds a dspName in getInfoArgs. However, once the Event Emitter calls Stop(), and then Play() again, getInfoArgs returns null.

This seems to make Steam Audio, which can only use Event Emitters, very broken in FMOD--or at least, makes Steam Audio's primary capabilities for occlusion, pathing, etc. useless.

github-actions[bot] commented 1 month ago

This issue has been automatically marked stale, and will automatically be closed in 30 days if no activity occurs.

lakulish commented 3 weeks ago

commenting to keep open