jarikomppa / soloud

Free, easy, portable audio engine for games
http://soloud-audio.com
Other
1.8k stars 282 forks source link

play3d does not update positional information before mixing thread runs. #95

Closed vk2gpu closed 9 years ago

vk2gpu commented 9 years ago

I've been noticing that far away sounds at first don't attenuate correctly, and wondering if this is something that should be resolved through my own usage of the API (which is pretty easy to do), or if SoLoud should handle this (which would reduce workload for the user).

Basically I am having a sound play at full volume as update3dAudio has not yet run. I'm finding I need to play3d with sound paused, call update3dAudio, then unpause to ensure the volume is setup correctly. This is cumbersome for anyone who is treating the API as fire & forget, and also extra overhead that could be deferred.

My own solution is probably going to be to put all sounds to setPause false on into a queue, and unpause them after the frame's update3dAudio call. I think it is probably better to have SoLoud do this for the user, or failing that run update3dAudio on a single voice on play3d to ensure the volume is up to date. Alternatively, the 3D audio should perhaps be updated prior to mixing (perhaps only every N frames) as this will introduce a guarantee. This could be more overhead than required to solve the problem though.

Any thoughts on this? I'm happy to fix this up and submit a pull request, but I thought it warranted raising an issue to see what the preferred fix would be.

jarikomppa commented 9 years ago

Yes, you have a point. Basically what happens is:

I'll have to add the initial calculation to the play3d call (outside audio mutex) - it actually WAS set up this way earlier but, well, brainfart.

jarikomppa commented 9 years ago

done, needs cleanup but I'll leave that for the future..