pub struct AudioParams {
pub sample_rate: u32,
pub channels: u16,
pub sample_format: SampleFormat,
pub bitrate_bps: Option<u64>,
pub frame_size: Option<u32>,
pub loudness_lufs: Option<f32>,
}Expand description
Audio stream encoding / decoding parameters.
Fields§
§sample_rate: u32Sample rate in Hz (e.g. 48_000 for broadcast audio).
channels: u16Number of audio channels (1 = mono, 2 = stereo, 6 = 5.1, …).
sample_format: SampleFormatSample format (default: SampleFormat::F32).
bitrate_bps: Option<u64>Target or measured peak bitrate in bits per second, if known.
frame_size: Option<u32>Frame size (samples per channel per frame), if fixed by the codec.
For example, Opus uses 20 ms frames at 48 kHz → 960 samples.
loudness_lufs: Option<f32>Normalisation loudness target in LUFS, if known (e.g. −23 LUFS for EBU R128).
Implementations§
Source§impl AudioParams
impl AudioParams
Sourcepub fn new(sample_rate: u32, channels: u16) -> Self
pub fn new(sample_rate: u32, channels: u16) -> Self
Creates minimal AudioParams with sample_rate and channels.
Defaults: sample_format = SampleFormat::F32, other fields None.
Sourcepub fn frame_duration_secs(&self) -> Option<f64>
pub fn frame_duration_secs(&self) -> Option<f64>
Returns the duration of a single frame in seconds, or None if no
fixed frame size is set.
Sourcepub fn with_sample_format(self, fmt: SampleFormat) -> Self
pub fn with_sample_format(self, fmt: SampleFormat) -> Self
Builder-style setter for sample format.
Sourcepub fn with_bitrate(self, bps: u64) -> Self
pub fn with_bitrate(self, bps: u64) -> Self
Builder-style setter for bitrate.
Sourcepub fn with_frame_size(self, samples: u32) -> Self
pub fn with_frame_size(self, samples: u32) -> Self
Builder-style setter for frame size.
Sourcepub fn with_loudness(self, lufs: f32) -> Self
pub fn with_loudness(self, lufs: f32) -> Self
Builder-style setter for loudness target.
Trait Implementations§
Source§impl Clone for AudioParams
impl Clone for AudioParams
Source§fn clone(&self) -> AudioParams
fn clone(&self) -> AudioParams
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more