-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to set a Global Volume #7706
Ability to set a Global Volume #7706
Conversation
This also opens the opportunity to fix the issue in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarity nit in the docs, but I won't block on it.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the global volume should change the sounds already playing that have been set relative to it.
Or as a start it should be mentioned that setting the global volume will only impact new sounds played after but not sounds already playing.
I think I would prefer an enum for the volume instead of having two fields, but I'm not completely sure on that.
Agreed, but this may not be trivial. Docs would be fine for me as a start.
This is nice :) |
Enum for volume makes a lot of sense, I'll have a go at changing the volume of already playing sounds. pub enum Volume {
Absolute(f32),
Relative(f32),
} |
That looks perfect. Ideally we could document what the |
Is there a way in rust to have positive only floats? |
I would newtype here and use a constructor method. |
I've added the volume enum but using the newtype for the volume level feels too verbose imo, some thoughts on this would be great. I also added the global volume as a field in the audio struct so you can set it using the |
Updating the volume for AudioSinks that have not been detached is easy, but I am unsure of how to update ones which have been detached (have no strong handle) so for now I will add message mentioning that only new sounds will be impacted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
It is a bit more verbose, but it prevent missing the absolute option completely.
I'm glad to see this added. Merging now, we can refine later as needed. |
# Objective The ability to ignore the global volume doesn't seem desirable and complicates the API. #7706 added global volume and the ability to ignore it, but there was no further discussion about whether that's useful. Feel free to discuss here :) ## Solution Replace the `Volume` type's functionality with the `VolumeLevel`. Remove `VolumeLevel`. I also removed `DerefMut` derive that effectively made the volume `pub` and actually ensured that the volume isn't set below `0` even in release builds. ## Migration Guide The option to ignore the global volume using `Volume::Absolute` has been removed and `Volume` now stores the volume level directly, removing the need for the `VolumeLevel` struct.
Objective
Adds a new resource to control a global volume.
Fixes #7690
Solution
Added a new resource to control global volume, this is then multiplied with an audio sources volume to get the output volume, individual audio sources can opt out of this my enabling the
absolute_volume
field inPlaybackSettings
.Changelog
Added
GlobalVolume
a resource to control global volume (in prelude).global_volume
field toAudioPlugin
or setting the initial value ofGlobalVolume
.Volume
enum that can beRelative
orAbsolute
.VolumeLevel
struct for defining a volume level.