Expand description
Core types and traits to implement a Clack plugin.
The PluginAudioProcessor trait is the main one required to be implemented for a Clack plugin. It
can also be associated to two more types, implementing PluginMainThread and PluginShared,
following the CLAP thread model, as described below.
§Thread model
CLAP’s thread model for plugins is split into three classes of operations: those happening in an audio processing thread, those happening in the main thread, and thread-safe operations:
-
The audio thread (
[audio-thread]in the CLAP specification): this is represented by a type implementing the mainPluginAudioProcessortrait (also named the audio processor), which isSendbut!Sync, and is the only one required to implement a Clack plugin.This type handles all DSP in one of the host’s audio threads, of which there may be multiple, if the host uses a thread pool for example.
The host is free to
SendthePluginAudioProcessortype between any of its audio threads, but any operation of this class is guaranteed to be exclusive (&mut) to a single audio thread.One exception is for CLAP plugins’ activation and deactivation (represented in Clack by the plugin type’s construction and destruction), which is guaranteed to happen in the Main Thread instead. This allows the plugin’s
activateanddeactivatemethods to receive temporary exclusive references to the main thread type during its construction and destruction. -
The main thread (
[main-thread]in the CLAP specification): this is represented by a type implementing thePluginMainThreadtrait, which is neitherSendnorSync. If main-thread operations are not needed by a plugin implementation,()can be used instead.This type can handle all non-thread-safe operations, such as those related to GUI handling, however extensions can extend its use to more kinds of operations.
The host cannot
Sendthis type to any other threads, and this type has to be constructed before any other operation is done on the plugin. -
Thread-safe operations (
[thread-safe]in the CLAP specification) are represented by a type implementing thePluginSharedtrait, which is bothSendandSync, and will be shared between the main thread and the audio thread. If it isn’t needed ,()can be used instead.It can be used to hold read-only data (such as all the detected host extensions), or to hold any other kind of synchronized state.
However, it should be noted that this type can be used by the host simultaneously from threads that are neither the main thread nor the audio thread.
Modules§
- features
- A set of standard plugin features meant to be used for a plugin descriptor’s features.
Structs§
- Features
Iter - An iterator over a
PluginDescriptor’s features list. - Plugin
Descriptor - Provides metadata about a given Plugin, such as its ID, name, version, and more.
- Plugin
Instance - A wrapper around a
Plugininstance.
Enums§
- Plugin
Error - A generic, type-erased error type for plugin-originating errors.
Traits§
- Plugin
- The main trait required to implement a CLAP plugin.
- Plugin
Audio Processor - The audio processor and main part of a plugin.
- Plugin
Main Thread - The part of the data and operation of a plugin that must be on the main thread.
- Plugin
Shared - The part of the data and operations of a plugin that are thread-safe.