Change volume of sfx
Dajamante opened this issue · comments
Hi Nathan,
Can you please look at the audio.rs file?
I am trying to make a contribution to modify the volume, but I don't know if I should have an audio channel for that.
I will make a proper pull request in time :)
It's okay to open a pull request even if it isn't ready. In fact, it makes it a lot easier for me to see exactly what you've changed in the pull request view.
The answer to your question is YES! I'm using bevy_kira_audio for sound. This library sets volume on a channel and then all sounds in that channel play at that volume, so if the volume is not 1.0
, then you will need to create a new channel, set the volume, and then play the sound in that channel (like we do for the music).
Given that this is a "toy" game engine, just naively creating a new channel for each new sound effect might work okay. If it ends up affecting performance (or hitting some limit of channels), then we may need to do something more clever, like creating a set number of channels at various volumes, and playing the sound in the channel with the volume that is closest to the one that was specified.
Right, I can start a proper pull request with the naive solution :).
For better implementation, do you mean always creating a set of 10 channels, and playing the sfx and music depending on user specifications?
Edit: I close this issue as I opened a non-ready PR :)
For better implementation, do you mean always creating a set of 10 channels, and playing the sfx and music depending on user specifications?
Yep, something like that.