tesselode / kira

Library for expressive game audio.
https://crates.io/crates/kira
Apache License 2.0
836 stars 42 forks source link

Feature request: `get_volume()` for StaticSoundHandle and StreamingSoundHandle #92

Open GitGhillie opened 1 month ago

GitGhillie commented 1 month ago

get_volume() would get the volume as set by set_volume().

Other audio libraries seem to have this in their API: https://www.fmod.com/docs/2.00/api/studio-api-eventinstance.html#studio_eventinstance_getvolume https://docs.rs/rodio/latest/rodio/struct.Sink.html#method.volume

And it could be helpful in situations where the volume is set from different places.

ItsDoot commented 1 month ago

Alternatively, if we could pass a closure to set_volume() of the form |cur_vol: Volume| calculate_new_volume(cur_vol), that would cover the most notable usecase(s).

tesselode commented 1 month ago

I've discussed this a bit in the Bevy discord, but there's some considerations for a feature like this:

I don't want to add this unless the pros outweigh the cons (performance, potential disappointment/confusion when people realize they can't rely on get_volume returning a number). The pros seem minimal to me currently, and I have no idea what the cons are.