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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more