Refactoring audio, seeking input

(Nolan) #1

Hey folks,

I’ve been slowly refactoring the spatial audio systems and am seeking feedback on next steps. Current challenges I’m facing:

  1. I’m not clear on how to loop audio. There are Rodio methods for looping, but those methods aren’t exposed.
  2. I’m not clear on how to set individual sound volumes, or indeed how to control individual sounds.

But, more fundamentally:

  1. 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.

  1. It doesn’t seem possible to access the underlying Rodio source to implement looping and individual sound control.
  2. 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:

  1. Emitters map to sink instances one-to-one. If an entity makes multiple simultaneous sounds, you’ll need multiple emitters.
  2. 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.
  3. 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. :slight_smile:

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. :slight_smile:


(Jacob Kiesel) #2

Go for it. :+1: I trust your judgement on this and would really appreciate anything you can do. We’ve talked elsewhere about some of your questions so I won’t reiterate that here. If there’s anything you need from me specifically feel free to ping me on discord.