pub struct Gain(/* private fields */);Expand description
Relative loudness adjustment for audio clips.
Use Gain with PcmClipBuf::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) -> Gain
pub const fn percent(percent: u16) -> Gain
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) -> Gain
pub const fn db(db: i8) -> Gain
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 PcmClipBuf::with_gain for usage.