I’ve been slowly refactoring the spatial audio systems and am seeking feedback on next steps. Current challenges I’m facing:
- I’m not clear on how to loop audio. There are Rodio methods for looping, but those methods aren’t exposed.
- I’m not clear on how to set individual sound volumes, or indeed how to control individual sounds.
But, more fundamentally:
- I’m unclear on the purpose of the line:
It looks like that adds sources to audio emitters, but I’m unclear of what
4 is? A limit on how many sources can be added to each emitter? I’m also unclear on the purpose of the bool.
- It doesn’t seem possible to access the underlying Rodio source to implement looping and individual sound control.
- I don’t know that anyone is even using this API. There are no examples beyond the simple non-spatial sounds in the Pong demos. There is no documentation, either.
I’m thinking of stripping this API down to its bare essentials, then building it alongside a game that actually uses spatial sounds to figure out what is needed. Specific changes I have in mind:
- Emitters map to sink instances one-to-one. If an entity makes multiple simultaneous sounds, you’ll need multiple emitters.
- Emitters contain methods for setting volume, looping, etc. So if you have a vehicle that emits an engine sound, along with occasional ambient sounds that don’t loop, the vehicle would contain an emitter set to loop, and another emitter with a picker containing the playback logic.
- I may get rid of the DjSystem entirely, in favor of an emitter with a picker. If an emitter has a transform, it gets a spatial sink hooked into the listener. If it doesn’t have a transform, it just plays without spatialization. So your music would just be an entity with an emitter, no transform, and a picker on the emitter that selects new music when the first track ends. No need to have two separate routes for audio, just a unified system that adapts to the presence of a transform.
Anyhow, it’d be hard to create a full design doc, because we’re not evolving a spatial audio system that works into one that’s better. I’m also not sure what’s needed, and won’t until I build the game I’m currently working on now.
All this is my long way of checking in. Is anyone currently using the spatial audio system extensively, and if so, can you show me what magic you’re doing to make it work? I don’t want to completely gut and refactor an API if it’s working fine for folks and I just don’t know how.
Sorry, not trying to sound harsh with this. Just seems like this API was built without any consumers, and it’s been a bit tough to work with something I’m not even sure works.