Skip to main content

StartedPluginAudioProcessor

Struct StartedPluginAudioProcessor 

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

destroy

Implementations§

Source§

impl<H: HostHandlers> StartedPluginAudioProcessor<H>

Source

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:

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 to process.

    This value can never decrease between two calls to process, unless reset is called, or if it was increased beyond u64::MAX and it wrapped around.

    This can be set to None if not available.

  • transport: Transport information, as of sample 0. See the TransportEvent documentation for more details about the available transport information.

    This can be None if 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.

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 stop_processing(self) -> StoppedPluginAudioProcessor<H>

Sends the plugin to sleep, implying the next process call will not be continuous with the last one.

This method returns an audio processor in the stopped state.

This operation is infallible.

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.

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.

Auto Trait Implementations§

§

impl<H> !RefUnwindSafe for StartedPluginAudioProcessor<H>

§

impl<H> !Sync for StartedPluginAudioProcessor<H>

§

impl<H> !UnwindSafe for StartedPluginAudioProcessor<H>

§

impl<H> Freeze for StartedPluginAudioProcessor<H>
where Arc<PluginInstanceInner<H>>: Freeze,

§

impl<H> Send for StartedPluginAudioProcessor<H>
where Arc<PluginInstanceInner<H>>: Send,

§

impl<H> Unpin for StartedPluginAudioProcessor<H>
where Arc<PluginInstanceInner<H>>: Unpin,

§

impl<H> UnsafeUnpin for StartedPluginAudioProcessor<H>
where Arc<PluginInstanceInner<H>>: UnsafeUnpin,

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.