pub struct Gain(/* private fields */);target_os=none only.Expand description
Relative loudness adjustment for audio clips.
Use Gain with AudioClipBuf::with_gain to make a clip louder or quieter
before playback.
with_gain is intended for const clip definitions, so the adjusted samples
are precomputed at compile time with no extra runtime work.
You can set gain by percent or by dB:
Gain::percentwhere100means unchanged and values above100are louder.Gain::dbwhere positive dB is louder and negative dB is quieter.
This is different from Volume used by
max_volume, initial_volume, and
set_volume,
which set the absolute playback loudness behavior for the whole player.
See the audio_player module documentation for usage examples.
Implementations§
Source§impl Gain
impl Gain
Sourcepub const fn percent(percent: u16) -> Self
pub const fn percent(percent: u16) -> Self
Creates a gain from percentage.
100 is unity gain. Values above 100 boost the signal.
See the audio_player module documentation for usage examples.
Sourcepub const fn db(db: i8) -> Self
pub const fn db(db: i8) -> Self
Creates gain from dB with a bounded boost range.
Values above +12 dB clamp to +12 dB.
Values below -96 dB clamp to -96 dB.
See AudioClipBuf::with_gain for usage.
Trait Implementations§
impl Copy for Gain
impl Eq for Gain
impl StructuralPartialEq for Gain
Auto Trait Implementations§
impl Freeze for Gain
impl RefUnwindSafe for Gain
impl Send for Gain
impl Sync for Gain
impl Unpin for Gain
impl UnwindSafe for Gain
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more