pub struct ProcessorContext { /* private fields */ }Implementations§
Source§impl ProcessorContext
impl ProcessorContext
Sourcepub fn set_parameter(
&self,
parameter: ProcessorParameter,
value: f32,
) -> Result<(), AicError>
pub fn set_parameter( &self, parameter: ProcessorParameter, value: f32, ) -> Result<(), AicError>
Modifies a processor parameter.
All parameters can be changed during audio processing. This function can be called from any thread.
§Arguments
parameter- Parameter to modifyvalue- New parameter value. See parameter documentation for ranges
§Returns
Returns Ok(()) on success or an AicError if the parameter cannot be set.
§Example
proc_ctx.set_parameter(ProcessorParameter::EnhancementLevel, 0.8).unwrap();Sourcepub fn parameter(&self, parameter: ProcessorParameter) -> Result<f32, AicError>
pub fn parameter(&self, parameter: ProcessorParameter) -> Result<f32, AicError>
Retrieves the current value of a parameter.
This function can be called from any thread.
§Arguments
parameter- Parameter to query
§Returns
Returns Ok(value) containing the current parameter value, or an AicError if the query fails.
§Example
let enhancement_level = processor_context.parameter(ProcessorParameter::EnhancementLevel).unwrap();
println!("Current enhancement level: {enhancement_level}");Sourcepub fn output_delay(&self) -> usize
pub fn output_delay(&self) -> usize
Returns the total output delay in samples for the current audio configuration.
This function provides the complete end-to-end latency introduced by the processor, which includes both algorithmic processing delay and any buffering overhead. Use this value to synchronize enhanced audio with other streams or to implement delay compensation in your application.
Delay behavior:
- Before initialization: Returns the base processing delay using the model’s optimal frame size at its native sample rate
- After initialization: Returns the actual delay for your specific configuration, including any additional buffering introduced by non-optimal frame sizes
Important: The delay value is always expressed in samples at the sample rate
you configured during initialize. To convert to time units:
delay_ms = (delay_samples * 1000) / sample_rate
Note: Using frame sizes different from the optimal value returned by
optimal_num_frames will increase the delay beyond the model’s base latency.
§Returns
Returns the delay in samples.
§Example
let delay = processor_context.output_delay();
println!("Output delay: {} samples", delay);Sourcepub fn reset(&self) -> Result<(), AicError>
pub fn reset(&self) -> Result<(), AicError>
Clears all internal state and buffers.
Call this when the audio stream is interrupted or when seeking to prevent artifacts from previous audio content.
The processor stays initialized to the configured settings.
§Returns
Returns Ok(()) on success or an AicError if the reset fails.
§Thread Safety
Real-time safe. Can be called from audio processing threads.
§Example
processor_context.reset().unwrap();