Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
135 stars 2 forks source link

Audio playback events in Protoflux. #327

Open moonheart08 opened 11 months ago

moonheart08 commented 11 months ago

Is your feature request related to a problem? Please describe.

I'd like my avatar's ears to be able to track nearby sounds, currently the best approximation I have is tracking nearby users.

Describe the solution you'd like

Events for the beginning, end, and ticking of an audio source, including an undetermined one (i.e. listening for new audio sources to begin)

Describe alternatives you've considered

A node for querying nearest sounds (plural) would also work.

Additional Context

No response

Frooxius commented 11 months ago

This would be a bit tricky to do, because we would need to instrument every sound effect to be potentially trackable.

This would mean everyone would pay performance cost even when not using this feature or tracking any sounds.

moonheart08 commented 11 months ago

This would be a bit tricky to do, because we would need to instrument every sound effect to be potentially trackable.

This would mean everyone would pay performance cost even when not using this feature or tracking any sounds.

I've been doing a bunch of RE so I could look into PoCing this and getting a general idea of what costs need paid where.

I have a feeling that given boundedness of queries, this shouldn't be too bad? each "tracking" slot could run a spatial query (which could easily be flattened to 2D to avoid maintaining a 3D tree, worlds tend to be wider than they are tall. Look at Box2D's dynamic tree for an example of a pretty performant approach here), and all running audio would just insert itself into the tree and update it's proxy semi-regularly (does not need to be every frame, i'd think? worthwhile concession at least.)

In worlds with no queries, simply do not update the tree.