Skip to main content

PluginAudioProcessor

Enum PluginAudioProcessor 

Source
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>

Source

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.

Source

pub fn access_shared_handler<'s, R>( &'s self, access: impl for<'a> FnOnce(&'s <H as HostHandlers>::Shared<'a>) -> R, ) -> R

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.

Source

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.

Source

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.

Source

pub fn plugin_handle(&mut self) -> PluginAudioProcessorHandle<'_>

Returns this plugin instance’s audio processor handle.

Source

pub fn shared_plugin_handle(&self) -> PluginSharedHandle<'_>

Returns this plugin instance’s shared handle.

Source

pub fn matches(&self, instance: &PluginInstance<H>) -> bool

Returns true if this audio processor was created from the given plugin instance.

Source

pub fn is_started(&self) -> bool

Returns true if this audio processor is its started state, false otherwise.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<H: HostHandlers> From<StartedPluginAudioProcessor<H>> for PluginAudioProcessor<H>

Source§

fn from(p: StartedPluginAudioProcessor<H>) -> Self

Converts to this type from the input type.
Source§

impl<H: HostHandlers> From<StoppedPluginAudioProcessor<H>> for PluginAudioProcessor<H>

Source§

fn from(p: StoppedPluginAudioProcessor<H>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.