Support decibels in bevy_audio::Volume#17605
Merged
alice-i-cecile merged 12 commits intobevyengine:mainfrom Feb 10, 2025
Merged
Support decibels in bevy_audio::Volume#17605alice-i-cecile merged 12 commits intobevyengine:mainfrom
alice-i-cecile merged 12 commits intobevyengine:mainfrom
Conversation
Co-authored-by: Zachary Harrold <zac@harrold.com.au>
mgi388
commented
Jan 31, 2025
SolarLiner
reviewed
Jan 31, 2025
Contributor
SolarLiner
left a comment
There was a problem hiding this comment.
Maybe I went into the territory of bikeshedding, but I have some comments on this, which maybe warrants a new pass at the PR.
Contributor
|
I think the points in the previous review should be addressed. I agree with the problems they pointed out. |
Co-authored-by: Zachary Harrold <zac@harrold.com.au>
SolarLiner
suggested changes
Feb 3, 2025
Contributor
Author
|
SolarLiner
reviewed
Feb 10, 2025
SolarLiner
approved these changes
Feb 10, 2025
alice-i-cecile
approved these changes
Feb 10, 2025
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
Very nicely made, and really clear, excellent docs. This is something that I think will be kept around even after swapping backends.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Volumetype from newtyping anf32to an enum withLinearandDecibelsvariants.VolumeLevelto use Decibel and Amplitude Ratio Units #9582.Solution
Compared to #9582, this PR has the following main differences:
opsfor doingVolumearithmetic. Can add two volumes, e.g. to increase/decrease the current volume. Can multiply two volumes, e.g. to get the “effective” volume of an audio source considering global volume.Testing
cargo run --example soundtrack.cargo run --example audio_control.cargo run --example spatial_audio_2d.cargo run --example spatial_audio_3d.cargo run --example pitch.cargo run --example decodable.cargo run --example audio.Migration Guide
Audio volume can now be configured using decibel values, as well as using linear scale values. To enable this, some types and functions in
bevy_audiohave changed.Volumeis now an enum withLinearandDecibelsvariants.Before:
After:
Volume::ZEROhas been renamed to the more semantically correctVolume::SILENTbecauseVolumenow supports decibels and "zero volume" in decibels actually means "normal volume".AudioSinkPlaybacktrait's volume-related methods now deal withVolumetypes rather thanf32s.AudioSinkPlayback::volume()now returns aVolumerather than anf32.AudioSinkPlayback::set_volumenow receives aVolumerather than anf32. This affects theAudioSinkandSpatialAudioSinkimplementations of the trait. The previousf32values are equivalent to the volume converted to linear scale so theVolume:: Linearvariant should be used to migrate betweenf32s andVolume.GlobalVolume::newfunction now receives aVolumeinstead of anf32.