pub struct ProcessorConfig {
pub sample_rate: u32,
pub num_channels: u16,
pub num_frames: usize,
pub allow_variable_frames: bool,
}Expand description
Audio processing configuration passed to Processor::initialize.
Use ProcessorConfig::optimal as a starting point, then adjust fields
to match your stream layout.
Fields§
§sample_rate: u32Sample rate in Hz (8000 - 192000).
num_channels: u16Number of audio channels in the stream (1 for mono, 2 for stereo, etc).
num_frames: usizeSamples per channel provided to each processing call. Note that using a non-optimal number of frames increases latency.
allow_variable_frames: boolAllows frame counts below num_frames at the cost of added latency.
Implementations§
Source§impl ProcessorConfig
impl ProcessorConfig
Sourcepub fn optimal(model: &Model<'_>) -> Self
pub fn optimal(model: &Model<'_>) -> Self
Returns a ProcessorConfig pre-filled with the model’s optimal sample rate and frame size.
num_channels will be set to 1 and allow_variable_frames to false.
Adjust the number of channels and enable variable frames by using the builder pattern.
let config = ProcessorConfig::optimal(&model)
.with_num_channels(2)
.with_allow_variable_frames(true);If you need to configure a non-optimal sample rate or number of frames,
construct the ProcessorConfig struct directly. For example:
let config = ProcessorConfig {
num_channels: 2,
sample_rate: 44100,
num_frames: model.optimal_num_frames(44100),
allow_variable_frames: true,
};Sourcepub fn with_num_channels(self, num_channels: u16) -> Self
pub fn with_num_channels(self, num_channels: u16) -> Self
Sets the number of audio channels for processing.
§Arguments
num_channels- Number of audio channels (1 for mono, 2 for stereo, etc.)
Sourcepub fn with_allow_variable_frames(self, allow_variable_frames: bool) -> Self
pub fn with_allow_variable_frames(self, allow_variable_frames: bool) -> Self
Enables or disables variable frame size support.
When enabled, allows processing frame counts below num_frames at the cost of added latency.
§Arguments
allow_variable_frames-trueto enable variable frame sizes,falsefor fixed size
Trait Implementations§
Source§impl Clone for ProcessorConfig
impl Clone for ProcessorConfig
Source§fn clone(&self) -> ProcessorConfig
fn clone(&self) -> ProcessorConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProcessorConfig
impl Debug for ProcessorConfig
impl Eq for ProcessorConfig
Source§impl Hash for ProcessorConfig
impl Hash for ProcessorConfig
Source§impl PartialEq for ProcessorConfig
impl PartialEq for ProcessorConfig
Source§fn eq(&self, other: &ProcessorConfig) -> bool
fn eq(&self, other: &ProcessorConfig) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ProcessorConfig
Auto Trait Implementations§
impl Freeze for ProcessorConfig
impl RefUnwindSafe for ProcessorConfig
impl Send for ProcessorConfig
impl Sync for ProcessorConfig
impl Unpin for ProcessorConfig
impl UnsafeUnpin for ProcessorConfig
impl UnwindSafe for ProcessorConfig
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> 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