pub struct StartedPluginAudioProcessor<H: HostHandlers> { /* private fields */ }Expand description
A handle to a plugin’s audio processor that is in the started state.
A host can call process or stop_processing on a plugin which audio processor is in
this state.
This type is generic over the HostHandlers type that was used to create the plugin instance.
The shared and audio processor handlers can be accessed with the
access_shared_handler,
access_handler and access_handler_mut
methods.
Note that in order to maintain thread-safety, this type must be either dropped or stopped and
passed to either PluginInstance::deactivate or PluginInstance::deactivate_with, before
the PluginInstance itself is dropped. If this is not done, the plugin instance will never
be deactivated or destroyed, and will leak all its associated resources.
Implementations§
Source§impl<H: HostHandlers> StartedPluginAudioProcessor<H>
impl<H: HostHandlers> StartedPluginAudioProcessor<H>
Sourcepub fn process(
&mut self,
audio_inputs: &InputAudioBuffers<'_>,
audio_outputs: &mut OutputAudioBuffers<'_>,
input_events: &InputEvents<'_>,
output_events: &mut OutputEvents<'_>,
steady_time: Option<u64>,
transport: Option<&TransportEvent>,
) -> Result<ProcessStatus, PluginInstanceError>
pub fn process( &mut self, audio_inputs: &InputAudioBuffers<'_>, audio_outputs: &mut OutputAudioBuffers<'_>, input_events: &InputEvents<'_>, output_events: &mut OutputEvents<'_>, steady_time: Option<u64>, transport: Option<&TransportEvent>, ) -> Result<ProcessStatus, PluginInstanceError>
Process a chunk of audio frames and events.
This plugin function requires the following arguments:
audio_inputs: TheInputAudioBuffersthe plugin is going to read audio frames from. Can beInputAudioBuffers::emptyif the plugin takes no audio input at all.audio_output: TheOutputAudioBuffersthe plugin is going to read audio frames from. Can beOutputAudioBuffers::emptyif the plugin produces no audio output at all.input_events: TheInputEventslist the plugin is going to receive events from. Can beInputEvents::emptyif the plugin doesn’t need to receive any events.output_events: TheOutputEventsbuffer the plugin is going to write the events it produces. Can beOutputEvents::voidto ignore any events the plugin produces.
Additionally, the following optional arguments can also be given:
-
steady_time: A steady sample time counter. This can be used to calculate the sleep duration between two process calls. This value may be specific to this plugin instance and have no relation to what other plugin instances may receive.The only requirement is that this value must be increased by at least the frame count of the audio buffers (see
InputAudioBuffers::min_available_frames_with) for the next call toprocess.This value can never decrease between two calls to
process, unlessresetis called, or if it was increased beyondu64::MAXand it wrapped around.This can be set to
Noneif not available. -
transport: Transport information, as of sample0. See theTransportEventdocumentation for more details about the available transport information.This can be
Noneif no transport is available, i.e. if the host is free-running.
Once processing is complete, the function returns a ProcessStatus to inform the host
whether the plugin can be put to sleep or not. See the ProcessStatus documentation
for more information.
§Errors
This function can return PluginInstanceError::NullProcessFunction if the plugin
implementation did not provide a valid underlying process function pointer.
This can also return PluginInstanceError::ProcessingFailed if the process function
failed for any reason.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets the plugin’s audio processing state.
This clears all the plugin’s internal buffers, kills all voices, and resets all processing state such as envelopes, LFOs, oscillators, filters, etc.
Calling this method allows the steady_time parameter passed to process
to jump backwards.
Sourcepub fn stop_processing(self) -> StoppedPluginAudioProcessor<H>
pub fn stop_processing(self) -> StoppedPluginAudioProcessor<H>
Accesses the SharedHandler for this instance, using the provided closure.
This function returns the return value of the provided closure directly.
Note that the lifetime of the SharedHandler cannot be statically known, as it is bound
to the plugin instance itself.
Unlike access_handler and
access_handler_mut, there is no way to obtain a mutable
reference to the SharedHandler, as it may be concurrently accessed by other threads.
Sourcepub fn access_handler<'s, R>(
&'s self,
access: impl for<'a> FnOnce(&'s <H as HostHandlers>::AudioProcessor<'a>) -> R,
) -> R
pub fn access_handler<'s, R>( &'s self, access: impl for<'a> FnOnce(&'s <H as HostHandlers>::AudioProcessor<'a>) -> R, ) -> R
Accesses the AudioProcessorHandler for this instance, using the provided closure.
This function returns the return value of the provided closure directly.
Note that the lifetime of the AudioProcessorHandler cannot be statically known, as it is bound
to the plugin instance itself.
See the access_handler_mut method to receive a mutable
reference to the AudioProcessorHandler instead.
Sourcepub fn access_handler_mut<'s, R>(
&'s mut self,
access: impl for<'a> FnOnce(&'s mut <H as HostHandlers>::AudioProcessor<'a>) -> R,
) -> R
pub fn access_handler_mut<'s, R>( &'s mut self, access: impl for<'a> FnOnce(&'s mut <H as HostHandlers>::AudioProcessor<'a>) -> R, ) -> R
Accesses the AudioProcessorHandler for this instance, using the provided closure.
This function returns the return value of the provided closure directly.
Note that the lifetime of the AudioProcessorHandler cannot be statically known, as it is bound
to the plugin instance itself.
See the access_handler method to receive a shared
reference to the AudioProcessorHandler instead.
Sourcepub fn plugin_handle(&mut self) -> PluginAudioProcessorHandle<'_>
pub fn plugin_handle(&mut self) -> PluginAudioProcessorHandle<'_>
Returns this plugin instance’s audio processor handle.
Returns this plugin instance’s shared handle.
Sourcepub fn matches(&self, instance: &PluginInstance<H>) -> bool
pub fn matches(&self, instance: &PluginInstance<H>) -> bool
Returns true if this audio processor was created from the given plugin instance.