pub enum PluginAudioProcessor<H: HostHandlers> {
Started(StartedPluginAudioProcessor<H>),
Stopped(StoppedPluginAudioProcessor<H>),
}Expand description
A handle to a plugin’s audio processor that can be in either its started or stopped state.
This is a convenience type that can be used where the type-states StartedPluginAudioProcessor and
StoppedPluginAudioProcessor are not very ergonomic, or to perform operations that are common
to both states.
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.
Variants§
Started(StartedPluginAudioProcessor<H>)
The audio processor is in it’s started state.
Stopped(StoppedPluginAudioProcessor<H>)
The audio processor is in it’s stopped state.
Implementations§
Source§impl<H: HostHandlers> PluginAudioProcessor<H>
impl<H: HostHandlers> PluginAudioProcessor<H>
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.
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.
Sourcepub fn is_started(&self) -> bool
pub fn is_started(&self) -> bool
Returns true if this audio processor is its started state, false otherwise.
Sourcepub fn as_started(
&self,
) -> Result<&StartedPluginAudioProcessor<H>, PluginInstanceError>
pub fn as_started( &self, ) -> Result<&StartedPluginAudioProcessor<H>, PluginInstanceError>
Returns this audio processor as a shared reference to its StartedPluginAudioProcessor
state, if it is in the started state.
§Errors
This returns a PluginInstanceError::ProcessingStopped error if the audio processor is
in the stopped state.
Sourcepub fn as_started_mut(
&mut self,
) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError>
pub fn as_started_mut( &mut self, ) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError>
Returns this audio processor as a mutable reference to its StartedPluginAudioProcessor
state, if it is in the started state.
§Errors
This returns a PluginInstanceError::ProcessingStopped error if the audio processor is
in the stopped state.
Sourcepub fn as_stopped(
&self,
) -> Result<&StoppedPluginAudioProcessor<H>, PluginInstanceError>
pub fn as_stopped( &self, ) -> Result<&StoppedPluginAudioProcessor<H>, PluginInstanceError>
Returns this audio processor as a shared reference to its StoppedPluginAudioProcessor
state, if it is in the stopped state.
§Errors
This returns a PluginInstanceError::ProcessingStarted error if the audio processor is
in the started state.
Sourcepub fn as_stopped_mut(
&mut self,
) -> Result<&mut StoppedPluginAudioProcessor<H>, PluginInstanceError>
pub fn as_stopped_mut( &mut self, ) -> Result<&mut StoppedPluginAudioProcessor<H>, PluginInstanceError>
Returns this audio processor as a mutable reference to its StoppedPluginAudioProcessor
state, if it is in the stopped state.
§Errors
This returns a PluginInstanceError::ProcessingStarted error if the audio processor is
in the started state.
Sourcepub fn start_processing(
&mut self,
) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError>
pub fn start_processing( &mut self, ) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError>
Starts this audio processor, and returns a mutable reference to its
StartedPluginAudioProcessor state.
§Errors
If the start operation failed, this returns a PluginInstanceError::StartProcessingFailed error.
If the audio processor was already started, this returns a
PluginInstanceError::ProcessingStarted error.
Sourcepub fn stop_processing(
&mut self,
) -> Result<&mut StoppedPluginAudioProcessor<H>, PluginInstanceError>
pub fn stop_processing( &mut self, ) -> Result<&mut StoppedPluginAudioProcessor<H>, PluginInstanceError>
Starts this audio processor, and returns a mutable reference to its
StoppedPluginAudioProcessor state.
§Errors
If the audio processor was already stopped, this returns a
PluginInstanceError::ProcessingStopped error.
Sourcepub fn ensure_processing_started(
&mut self,
) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError>
pub fn ensure_processing_started( &mut self, ) -> Result<&mut StartedPluginAudioProcessor<H>, PluginInstanceError>
Starts this audio processor, if it is not already started, and returns a mutable reference
to its StartedPluginAudioProcessor state.
If its already started, this does nothing and returns the mutable reference directly.
§Errors
If this audio processor was in its stopped state and the start operation failed, this
returns a PluginInstanceError::StartProcessingFailed error.
Sourcepub fn ensure_processing_stopped(
&mut self,
) -> &mut StoppedPluginAudioProcessor<H>
pub fn ensure_processing_stopped( &mut self, ) -> &mut StoppedPluginAudioProcessor<H>
Stops this audio processor, if it is not already stopped, and returns a mutable reference
to its StoppedPluginAudioProcessor state.
If its already stopped, this does nothing and returns the mutable reference directly.
This operation is infallible.
Sourcepub fn into_started(
self,
) -> Result<StartedPluginAudioProcessor<H>, ProcessingStartError<H>>
pub fn into_started( self, ) -> Result<StartedPluginAudioProcessor<H>, ProcessingStartError<H>>
Starts this audio processor, if it is not already started, and returns its
StartedPluginAudioProcessor state, consuming the PluginAudioProcessor instance in
the process.
If it is already started, this does nothing and returns the StartedPluginAudioProcessor state directly.
§Errors
If this audio processor was in its stopped state and the start operation failed, this
returns a ProcessingStartError, from which the StoppedPluginAudioProcessor can be
recovered.
Sourcepub fn into_stopped(self) -> StoppedPluginAudioProcessor<H>
pub fn into_stopped(self) -> StoppedPluginAudioProcessor<H>
Stops this audio processor, if it is not already stopped, and returns its
StoppedPluginAudioProcessor state, consuming the PluginAudioProcessor instance in
the process.
If it is already stopped, this does nothing and returns the StoppedPluginAudioProcessor state directly.
This operation is infallible.