2022-03-03 23:34:06 +01:00
|
|
|
//! Traits and structs describing plugins and editors.
|
|
|
|
|
2022-02-05 17:11:24 +01:00
|
|
|
use std::sync::Arc;
|
2022-01-25 02:19:31 +01:00
|
|
|
|
2022-10-21 23:52:46 +02:00
|
|
|
use crate::async_executor::AsyncExecutor;
|
2022-02-02 15:01:41 +01:00
|
|
|
use crate::buffer::Buffer;
|
2022-10-21 23:12:05 +02:00
|
|
|
use crate::context::{InitContext, ProcessContext};
|
|
|
|
use crate::editor::Editor;
|
2022-04-07 23:28:31 +02:00
|
|
|
use crate::midi::MidiConfig;
|
2022-10-20 12:26:12 +02:00
|
|
|
use crate::params::Params;
|
2022-06-02 01:16:30 +02:00
|
|
|
use crate::wrapper::clap::features::ClapFeature;
|
2022-10-20 12:41:48 +02:00
|
|
|
use crate::wrapper::state::PluginState;
|
2022-01-25 02:19:31 +01:00
|
|
|
|
|
|
|
/// Basic functionality that needs to be implemented by a plugin. The wrappers will use this to
|
|
|
|
/// expose the plugin in a particular plugin format.
|
|
|
|
///
|
2022-04-24 18:34:40 +02:00
|
|
|
/// The main thing you need to do is define a `[Params]` struct containing all of your parameters.
|
2022-03-16 17:04:38 +01:00
|
|
|
/// See the trait's documentation for more information on how to do that, or check out the examples.
|
|
|
|
///
|
2022-01-25 02:19:31 +01:00
|
|
|
/// This is super basic, and lots of things I didn't need or want to use yet haven't been
|
|
|
|
/// implemented. Notable missing features include:
|
|
|
|
///
|
2022-07-05 22:53:14 +02:00
|
|
|
/// - MIDI SysEx and MIDI2 for CLAP, note expressions, polyphonic modulation and MIDI1 are already
|
|
|
|
/// supported
|
2022-06-18 18:50:53 +02:00
|
|
|
/// - Audio thread thread pools (with host integration in CLAP)
|
2022-02-05 13:32:03 +01:00
|
|
|
#[allow(unused_variables)]
|
2022-10-20 16:12:46 +02:00
|
|
|
pub trait Plugin: Default + Send + 'static {
|
2022-10-21 23:34:59 +02:00
|
|
|
/// The plugin's name.
|
2022-01-26 18:14:13 +01:00
|
|
|
const NAME: &'static str;
|
2022-10-21 23:34:59 +02:00
|
|
|
/// The name of the plugin's vendor.
|
2022-01-26 18:14:13 +01:00
|
|
|
const VENDOR: &'static str;
|
2022-10-21 23:34:59 +02:00
|
|
|
/// A URL pointing to the plugin's web page.
|
2022-01-26 18:14:13 +01:00
|
|
|
const URL: &'static str;
|
2022-10-21 23:34:59 +02:00
|
|
|
/// The vendor's email address.
|
2022-01-26 18:14:13 +01:00
|
|
|
const EMAIL: &'static str;
|
|
|
|
|
2022-01-26 22:20:15 +01:00
|
|
|
/// Semver compatible version string (e.g. `0.0.1`). Hosts likely won't do anything with this,
|
|
|
|
/// but just in case they do this should only contain decimals values and dots.
|
|
|
|
const VERSION: &'static str;
|
2022-01-26 19:49:22 +01:00
|
|
|
|
2022-05-23 17:07:48 +02:00
|
|
|
/// The default number of input channels. This merely serves as a default. The host will probe
|
|
|
|
/// the plugin's supported configuration using
|
|
|
|
/// [`accepts_bus_config()`][Self::accepts_bus_config()], and the selected configuration is
|
|
|
|
/// passed to [`initialize()`][Self::initialize()]. Some hosts like, like Bitwig and Ardour, use
|
|
|
|
/// the defaults instead of setting up the busses properly.
|
|
|
|
///
|
|
|
|
/// Setting this to zero causes the plugin to have no main input bus.
|
2022-08-19 14:34:21 +02:00
|
|
|
const DEFAULT_INPUT_CHANNELS: u32 = 2;
|
2022-05-23 17:07:48 +02:00
|
|
|
/// The default number of output channels. All of the same caveats mentioned for
|
2022-08-19 14:34:21 +02:00
|
|
|
/// `DEFAULT_INPUT_CHANNELS` apply here.
|
2022-05-23 17:07:48 +02:00
|
|
|
///
|
|
|
|
/// Setting this to zero causes the plugin to have no main output bus.
|
2022-08-19 14:34:21 +02:00
|
|
|
const DEFAULT_OUTPUT_CHANNELS: u32 = 2;
|
2022-01-25 02:19:31 +01:00
|
|
|
|
2022-05-23 17:07:48 +02:00
|
|
|
/// If set, then the plugin will have this many sidechain input busses with a default number of
|
|
|
|
/// channels. Not all hosts support more than one sidechain input bus. Negotiating the actual
|
2022-08-19 14:34:21 +02:00
|
|
|
/// configuration works the same was as with `DEFAULT_INPUT_CHANNELS`.
|
2022-05-23 17:07:48 +02:00
|
|
|
const DEFAULT_AUX_INPUTS: Option<AuxiliaryIOConfig> = None;
|
|
|
|
/// If set, then the plugin will have this many auxiliary output busses with a default number of
|
2022-09-29 12:28:56 +02:00
|
|
|
/// channels. Negotiating the actual configuration works the same was as with
|
2022-08-19 14:34:21 +02:00
|
|
|
/// `DEFAULT_INPUT_CHANNELS`.
|
2022-05-23 17:07:48 +02:00
|
|
|
const DEFAULT_AUX_OUTPUTS: Option<AuxiliaryIOConfig> = None;
|
|
|
|
|
2022-05-28 00:20:32 +02:00
|
|
|
/// Optional names for the main and auxiliary input and output ports. Will be generated if not
|
|
|
|
/// set. This is mostly useful to give descriptive names to the outputs for multi-output
|
|
|
|
/// plugins.
|
|
|
|
const PORT_NAMES: PortNames = PortNames {
|
|
|
|
main_input: None,
|
|
|
|
main_output: None,
|
|
|
|
aux_inputs: None,
|
|
|
|
aux_outputs: None,
|
|
|
|
};
|
|
|
|
|
2022-04-11 19:52:51 +02:00
|
|
|
/// Whether the plugin accepts note events, and what which events it wants to receive. If this
|
|
|
|
/// is set to [`MidiConfig::None`], then the plugin won't receive any note events.
|
2022-04-07 20:27:37 +02:00
|
|
|
const MIDI_INPUT: MidiConfig = MidiConfig::None;
|
2022-04-11 19:52:51 +02:00
|
|
|
/// Whether the plugin can output note events. If this is set to [`MidiConfig::None`], then the
|
2022-09-29 12:28:56 +02:00
|
|
|
/// plugin won't have a note output port. When this is set to another value, then in most hosts
|
2022-04-11 19:52:51 +02:00
|
|
|
/// the plugin will consume all note and MIDI CC input. If you don't want that, then you will
|
|
|
|
/// need to forward those events yourself.
|
|
|
|
const MIDI_OUTPUT: MidiConfig = MidiConfig::None;
|
2022-03-10 18:57:17 +01:00
|
|
|
/// If enabled, the audio processing cycle may be split up into multiple smaller chunks if
|
|
|
|
/// parameter values change occur in the middle of the buffer. Depending on the host these
|
|
|
|
/// blocks may be as small as a single sample. Bitwig Studio sends at most one parameter change
|
|
|
|
/// every 64 samples.
|
|
|
|
const SAMPLE_ACCURATE_AUTOMATION: bool = false;
|
2022-02-04 01:09:09 +01:00
|
|
|
|
2022-07-05 22:20:07 +02:00
|
|
|
/// If this is set to true, then the plugin will report itself as having a hard realtime
|
|
|
|
/// processing requirement when the host asks for it. Supported hosts will never ask the plugin
|
|
|
|
/// to do offline processing.
|
|
|
|
const HARD_REALTIME_ONLY: bool = false;
|
|
|
|
|
2022-10-21 23:52:46 +02:00
|
|
|
/// The plugin's [`AsyncExecutor`] type. Use `()` if the plugin does not need to perform
|
|
|
|
/// expensive background tasks.
|
|
|
|
//
|
|
|
|
// This needs to be an associated type so we can have a nice type safe interface in the
|
|
|
|
// `*Context` traits.
|
|
|
|
//
|
|
|
|
// NOTE: Sadly it's not yet possible to default this and the `async_executor()` function to
|
|
|
|
// `()`: https://github.com/rust-lang/rust/issues/29661
|
|
|
|
type AsyncExecutor: AsyncExecutor;
|
|
|
|
|
|
|
|
/// The plugin's background task executor. Use `()` if the plugin does not need this
|
|
|
|
/// functinlality.
|
|
|
|
fn async_executor(&self) -> Self::AsyncExecutor;
|
|
|
|
|
2022-01-25 02:19:31 +01:00
|
|
|
/// The plugin's parameters. The host will update the parameter values before calling
|
|
|
|
/// `process()`. These parameters are identified by strings that should never change when the
|
|
|
|
/// plugin receives an update.
|
2022-04-07 15:31:46 +02:00
|
|
|
fn params(&self) -> Arc<dyn Params>;
|
2022-01-25 02:19:31 +01:00
|
|
|
|
2022-02-06 17:12:57 +01:00
|
|
|
/// The plugin's editor, if it has one. The actual editor instance is created in
|
2022-03-03 23:05:01 +01:00
|
|
|
/// [`Editor::spawn()`]. A plugin editor likely wants to interact with the plugin's parameters
|
|
|
|
/// and other shared data, so you'll need to move [`Arc`] pointing to any data you want to
|
|
|
|
/// access into the editor. You can later modify the parameters through the
|
2022-03-03 23:30:29 +01:00
|
|
|
/// [`GuiContext`][crate::prelude::GuiContext] and [`ParamSetter`][crate::prelude::ParamSetter] after the editor
|
2022-03-03 23:05:01 +01:00
|
|
|
/// GUI has been created.
|
2022-02-06 17:12:57 +01:00
|
|
|
fn editor(&self) -> Option<Box<dyn Editor>> {
|
2022-02-05 12:46:26 +01:00
|
|
|
None
|
|
|
|
}
|
|
|
|
|
2022-10-20 12:41:48 +02:00
|
|
|
/// This function is always called just before a [`PluginState`] is loaded. This lets you
|
|
|
|
/// directly modify old plugin state to perform migrations based on the [`PluginState::version`]
|
|
|
|
/// field. Some examples of use cases for this are renaming parameter indices, remapping
|
|
|
|
/// parameter values, and preserving old preset compatibility when introducing new parameters
|
|
|
|
/// with default values that would otherwise change the sound of a preset. Keep in mind that
|
|
|
|
/// automation may still be broken in the first two use cases.
|
|
|
|
///
|
|
|
|
/// # Note
|
|
|
|
///
|
|
|
|
/// This is an advanced feature that the vast majority of plugins won't need to implement.
|
|
|
|
fn filter_state(state: &mut PluginState) {}
|
|
|
|
|
2022-01-25 02:19:31 +01:00
|
|
|
//
|
|
|
|
// The following functions follow the lifetime of the plugin.
|
|
|
|
//
|
|
|
|
|
|
|
|
/// Whether the plugin supports a bus config. This only acts as a check, and the plugin
|
|
|
|
/// shouldn't do anything beyond returning true or false.
|
2022-02-04 01:13:00 +01:00
|
|
|
fn accepts_bus_config(&self, config: &BusConfig) -> bool {
|
2022-08-19 14:34:21 +02:00
|
|
|
config.num_input_channels == Self::DEFAULT_INPUT_CHANNELS
|
|
|
|
&& config.num_output_channels == Self::DEFAULT_OUTPUT_CHANNELS
|
2022-02-04 01:13:00 +01:00
|
|
|
}
|
2022-01-25 02:19:31 +01:00
|
|
|
|
2022-05-22 13:39:19 +02:00
|
|
|
/// Initialize the plugin for the given bus and buffer configurations. These configurations will
|
|
|
|
/// not change until this function is called again, so feel free to copy these objects to your
|
|
|
|
/// plugin's object. If the plugin is being restored from an old state, then that state will
|
|
|
|
/// have already been restored at this point. If based on those parameters (or for any reason
|
|
|
|
/// whatsoever) the plugin needs to introduce latency, then you can do so here using the process
|
|
|
|
/// context. Depending on how the host restores plugin state, this function may also be called
|
2022-09-29 12:28:56 +02:00
|
|
|
/// twice in rapid succession. If the plugin fails to initialize for whatever reason, then this
|
2022-05-22 13:39:19 +02:00
|
|
|
/// should return `false`.
|
2022-01-25 02:19:31 +01:00
|
|
|
///
|
2022-02-01 17:09:23 +01:00
|
|
|
/// Before this point, the plugin should not have done any expensive initialization. Please
|
2022-01-25 02:19:31 +01:00
|
|
|
/// don't be that plugin that takes twenty seconds to scan.
|
2022-03-08 00:35:55 +01:00
|
|
|
///
|
|
|
|
/// After this function [`reset()`][Self::reset()] will always be called. If you need to clear
|
2022-09-29 12:28:56 +02:00
|
|
|
/// state, such as filters or envelopes, then you should do so in that function instead.
|
2022-02-01 17:09:23 +01:00
|
|
|
fn initialize(
|
|
|
|
&mut self,
|
|
|
|
bus_config: &BusConfig,
|
|
|
|
buffer_config: &BufferConfig,
|
2022-10-22 00:21:08 +02:00
|
|
|
context: &mut impl InitContext<Self>,
|
2022-02-04 01:13:00 +01:00
|
|
|
) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2022-01-25 02:19:31 +01:00
|
|
|
|
2022-03-08 00:35:55 +01:00
|
|
|
/// Clear internal state such as filters and envelopes. This is always called after
|
2022-04-26 13:37:53 +02:00
|
|
|
/// [`initialize()`][Self::initialize()], and it may also be called at any other time from the
|
2022-03-08 00:35:55 +01:00
|
|
|
/// audio thread. You should thus not do any allocations in this function.
|
|
|
|
fn reset(&mut self) {}
|
|
|
|
|
2022-02-03 16:22:32 +01:00
|
|
|
/// Process audio. The host's input buffers have already been copied to the output buffers if
|
|
|
|
/// they are not processing audio in place (most hosts do however). All channels are also
|
2022-09-29 12:28:56 +02:00
|
|
|
/// guaranteed to contain the same number of samples. Lastly, denormals have already been taken
|
2022-02-03 16:22:32 +01:00
|
|
|
/// case of by NIH-plug, and you can optionally enable the `assert_process_allocs` feature to
|
2022-09-29 12:28:56 +02:00
|
|
|
/// abort the program when any allocation occurs in the process function while running in debug
|
2022-02-03 16:22:32 +01:00
|
|
|
/// mode.
|
2022-01-25 02:19:31 +01:00
|
|
|
///
|
2022-03-03 23:05:01 +01:00
|
|
|
/// The framework provides convenient iterators on the [`Buffer`] object to process audio either
|
2022-03-01 17:11:25 +01:00
|
|
|
/// either per-sample per-channel, or per-block per-channel per-sample. The first approach is
|
|
|
|
/// preferred for plugins that don't require block-based processing because of their use of
|
|
|
|
/// per-sample SIMD or excessive branching. The parameter smoothers can also work in both modes:
|
2022-03-03 23:30:29 +01:00
|
|
|
/// use [`Smoother::next()`][crate::prelude::Smoother::next()] for per-sample processing, and
|
|
|
|
/// [`Smoother::next_block()`][crate::prelude::Smoother::next_block()] for block-based
|
2022-07-06 14:26:43 +02:00
|
|
|
/// processing.
|
2022-03-01 17:11:25 +01:00
|
|
|
///
|
2022-05-27 02:30:57 +02:00
|
|
|
/// The `context` object contains context information as well as callbacks for working with note
|
|
|
|
/// events. The [`AuxiliaryBuffers`] contain the plugin's sidechain input buffers and
|
|
|
|
/// auxiliary output buffers if it has any.
|
|
|
|
///
|
2022-01-25 02:19:31 +01:00
|
|
|
/// TODO: Provide a way to access auxiliary input channels if the IO configuration is
|
2022-09-29 12:28:56 +02:00
|
|
|
/// asymmetric
|
2022-05-27 02:30:57 +02:00
|
|
|
fn process(
|
|
|
|
&mut self,
|
|
|
|
buffer: &mut Buffer,
|
|
|
|
aux: &mut AuxiliaryBuffers,
|
2022-10-22 01:15:16 +02:00
|
|
|
context: &mut impl ProcessContext<Self>,
|
2022-05-27 02:30:57 +02:00
|
|
|
) -> ProcessStatus;
|
2022-03-01 17:11:25 +01:00
|
|
|
|
2022-05-24 13:03:30 +02:00
|
|
|
/// Called when the plugin is deactivated. The host will call
|
|
|
|
/// [`initialize()`][Self::initialize()] again before the plugin resumes processing audio. These
|
|
|
|
/// two functions will not be called when the host only temporarily stops processing audio. You
|
|
|
|
/// can clean up or deallocate resources here. In most cases you can safely ignore this.
|
|
|
|
///
|
|
|
|
/// There is no one-to-one relationship between calls to `initialize()` and `deactivate()`.
|
|
|
|
/// `initialize()` may be called more than once before `deactivate()` is called, for instance
|
|
|
|
/// when restoring state while the plugin is still activate.
|
|
|
|
fn deactivate(&mut self) {}
|
2022-01-25 02:19:31 +01:00
|
|
|
}
|
|
|
|
|
2022-02-28 14:45:07 +01:00
|
|
|
/// Provides auxiliary metadata needed for a CLAP plugin.
|
|
|
|
pub trait ClapPlugin: Plugin {
|
2022-02-28 17:04:39 +01:00
|
|
|
/// A unique ID that identifies this particular plugin. This is usually in reverse domain name
|
|
|
|
/// notation, e.g. `com.manufacturer.plugin-name`.
|
|
|
|
const CLAP_ID: &'static str;
|
2022-07-04 12:44:30 +02:00
|
|
|
/// An optional short description for the plugin.
|
|
|
|
const CLAP_DESCRIPTION: Option<&'static str>;
|
|
|
|
/// The URL to the plugin's manual, if available.
|
|
|
|
const CLAP_MANUAL_URL: Option<&'static str>;
|
|
|
|
/// The URL to the plugin's support page, if available.
|
|
|
|
const CLAP_SUPPORT_URL: Option<&'static str>;
|
|
|
|
/// Keywords describing the plugin. The host may use this to classify the plugin in its plugin
|
|
|
|
/// browser.
|
2022-06-02 01:16:30 +02:00
|
|
|
const CLAP_FEATURES: &'static [ClapFeature];
|
2022-07-05 22:53:14 +02:00
|
|
|
|
|
|
|
/// If set, this informs the host about the plugin's capabilities for polyphonic modulation.
|
|
|
|
const CLAP_POLY_MODULATION_CONFIG: Option<PolyModulationConfig> = None;
|
2022-02-28 14:45:07 +01:00
|
|
|
}
|
|
|
|
|
2022-01-27 22:13:13 +01:00
|
|
|
/// Provides auxiliary metadata needed for a VST3 plugin.
|
|
|
|
pub trait Vst3Plugin: Plugin {
|
|
|
|
/// The unique class ID that identifies this particular plugin. You can use the
|
|
|
|
/// `*b"fooofooofooofooo"` syntax for this.
|
2022-02-10 21:30:39 +01:00
|
|
|
///
|
|
|
|
/// This will be shuffled into a different byte order on Windows for project-compatibility.
|
2022-01-27 22:13:13 +01:00
|
|
|
const VST3_CLASS_ID: [u8; 16];
|
2022-04-27 15:16:52 +02:00
|
|
|
/// One or more categories, separated by pipe characters (`|`), up to 127 characters. Anything
|
2022-09-29 12:28:56 +02:00
|
|
|
/// longer than that will be truncated. See the VST3 SDK for examples of common categories:
|
2022-01-28 18:10:28 +01:00
|
|
|
/// <https://github.com/steinbergmedia/vst3_pluginterfaces/blob/2ad397ade5b51007860bedb3b01b8afd2c5f6fba/vst/ivstaudioprocessor.h#L49-L90>
|
2022-06-02 01:16:30 +02:00
|
|
|
//
|
2022-07-06 13:55:26 +02:00
|
|
|
// TODO: Create a category enum similar to ClapFeature
|
2022-01-27 22:13:13 +01:00
|
|
|
const VST3_CATEGORIES: &'static str;
|
2022-02-10 21:30:39 +01:00
|
|
|
|
2022-03-03 23:05:01 +01:00
|
|
|
/// [`VST3_CLASS_ID`][Self::VST3_CLASS_ID`] in the correct order for the current platform so
|
|
|
|
/// projects and presets can be shared between platforms. This should not be overridden.
|
2022-02-10 21:30:39 +01:00
|
|
|
const PLATFORM_VST3_CLASS_ID: [u8; 16] = swap_vst3_uid_byte_order(Self::VST3_CLASS_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
const fn swap_vst3_uid_byte_order(uid: [u8; 16]) -> [u8; 16] {
|
|
|
|
uid
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_os = "windows")]
|
|
|
|
const fn swap_vst3_uid_byte_order(mut uid: [u8; 16]) -> [u8; 16] {
|
|
|
|
// No mutable references in const functions, so we can't use `uid.swap()`
|
|
|
|
let original_uid = uid;
|
|
|
|
|
|
|
|
uid[0] = original_uid[3];
|
|
|
|
uid[1] = original_uid[2];
|
|
|
|
uid[2] = original_uid[1];
|
|
|
|
uid[3] = original_uid[0];
|
|
|
|
|
|
|
|
uid[4] = original_uid[5];
|
|
|
|
uid[5] = original_uid[4];
|
|
|
|
uid[6] = original_uid[7];
|
|
|
|
uid[7] = original_uid[6];
|
|
|
|
|
|
|
|
uid
|
2022-01-27 22:13:13 +01:00
|
|
|
}
|
|
|
|
|
2022-05-23 17:07:48 +02:00
|
|
|
/// The plugin's IO configuration.
|
2022-01-31 19:40:52 +01:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
2022-01-25 02:19:31 +01:00
|
|
|
pub struct BusConfig {
|
|
|
|
/// The number of input channels for the plugin.
|
|
|
|
pub num_input_channels: u32,
|
|
|
|
/// The number of output channels for the plugin.
|
|
|
|
pub num_output_channels: u32,
|
2022-05-23 17:07:48 +02:00
|
|
|
/// Any additional sidechain inputs.
|
|
|
|
pub aux_input_busses: AuxiliaryIOConfig,
|
|
|
|
/// Any additional outputs.
|
|
|
|
pub aux_output_busses: AuxiliaryIOConfig,
|
|
|
|
}
|
|
|
|
|
2022-09-29 12:28:56 +02:00
|
|
|
/// Configuration for auxiliary inputs or outputs on [`BusConfig`].
|
2022-05-23 17:07:48 +02:00
|
|
|
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
|
|
|
|
pub struct AuxiliaryIOConfig {
|
|
|
|
/// The number of auxiliary input or output busses.
|
|
|
|
pub num_busses: u32,
|
|
|
|
/// The number of channels in each bus.
|
|
|
|
pub num_channels: u32,
|
2022-01-25 02:19:31 +01:00
|
|
|
}
|
|
|
|
|
2022-05-28 00:20:32 +02:00
|
|
|
/// Contains names for the main input and output ports as well as for all of the auxiliary input and
|
|
|
|
/// output ports. Setting these is optional, but it makes working with multi-output plugins much
|
|
|
|
/// more convenient.
|
|
|
|
#[derive(Debug, Default, Clone, PartialEq, Eq)]
|
|
|
|
pub struct PortNames {
|
|
|
|
/// The name for the main input port. Will be generated if not set.
|
|
|
|
pub main_input: Option<&'static str>,
|
|
|
|
/// The name for the main output port. Will be generated if not set.
|
|
|
|
pub main_output: Option<&'static str>,
|
|
|
|
/// Names for auxiliary (sidechain) input ports. Will be generated if not set or if this slice
|
|
|
|
/// does not contain enough names.
|
|
|
|
pub aux_inputs: Option<&'static [&'static str]>,
|
|
|
|
/// Names for auxiliary output ports. Will be generated if not set or if this slice does not
|
|
|
|
/// contain enough names.
|
|
|
|
pub aux_outputs: Option<&'static [&'static str]>,
|
|
|
|
}
|
|
|
|
|
2022-01-25 02:19:31 +01:00
|
|
|
/// Configuration for (the host's) audio buffers.
|
2022-02-02 15:39:55 +01:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
2022-01-25 02:19:31 +01:00
|
|
|
pub struct BufferConfig {
|
|
|
|
/// The current sample rate.
|
|
|
|
pub sample_rate: f32,
|
2022-05-22 13:21:39 +02:00
|
|
|
/// The minimum buffer size the host will use. This may not be set.
|
|
|
|
pub min_buffer_size: Option<u32>,
|
2022-01-25 02:19:31 +01:00
|
|
|
/// The maximum buffer size the host will use. The plugin should be able to accept variable
|
2022-05-22 13:21:39 +02:00
|
|
|
/// sized buffers up to this size, or between the minimum and the maximum buffer size if both
|
|
|
|
/// are set.
|
2022-01-25 02:19:31 +01:00
|
|
|
pub max_buffer_size: u32,
|
2022-05-22 13:33:38 +02:00
|
|
|
/// The current processing mode. The host will reinitialize the plugin any time this changes.
|
|
|
|
pub process_mode: ProcessMode,
|
2022-01-25 02:19:31 +01:00
|
|
|
}
|
2022-01-27 21:03:49 +01:00
|
|
|
|
2022-05-27 02:30:57 +02:00
|
|
|
/// Contains auxiliary (sidechain) input and output buffers for a process call.
|
|
|
|
pub struct AuxiliaryBuffers<'a> {
|
|
|
|
/// All auxiliary (sidechain) inputs defined for this plugin. The data in these buffers can
|
|
|
|
/// safely be overwritten. Auxiliary inputs can be defined by setting
|
|
|
|
/// [`Plugin::DEFAULT_AUX_INPUTS`][`crate::prelude::Plugin::DEFAULT_AUX_INPUTS`].
|
|
|
|
pub inputs: &'a mut [Buffer<'a>],
|
|
|
|
/// Get all auxiliary outputs defined for this plugin. Auxiliary outputs can be defined by
|
|
|
|
/// setting [`Plugin::DEFAULT_AUX_OUTPUTS`][`crate::prelude::Plugin::DEFAULT_AUX_OUTPUTS`].
|
|
|
|
pub outputs: &'a mut [Buffer<'a>],
|
|
|
|
}
|
|
|
|
|
2022-01-27 21:03:49 +01:00
|
|
|
/// Indicates the current situation after the plugin has processed audio.
|
2022-01-28 13:40:47 +01:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
2022-01-27 21:03:49 +01:00
|
|
|
pub enum ProcessStatus {
|
|
|
|
/// Something went wrong while processing audio.
|
|
|
|
Error(&'static str),
|
|
|
|
/// The plugin has finished processing audio. When the input is silent, the most may suspend the
|
|
|
|
/// plugin to save resources as it sees fit.
|
|
|
|
Normal,
|
|
|
|
/// The plugin has a (reverb) tail with a specific length in samples.
|
|
|
|
Tail(u32),
|
|
|
|
/// This plugin will continue to produce sound regardless of whether or not the input is silent,
|
|
|
|
/// and should thus not be deactivated by the host. This is essentially the same as having an
|
2022-09-29 12:28:56 +02:00
|
|
|
/// infinite tail.
|
2022-01-27 21:03:49 +01:00
|
|
|
KeepAlive,
|
|
|
|
}
|
2022-05-22 13:33:38 +02:00
|
|
|
|
2022-10-20 12:21:24 +02:00
|
|
|
/// The plugin's current processing mode. Exposed through [`BufferConfig::process_mode`]. The host
|
|
|
|
/// will reinitialize the plugin whenever this changes.
|
2022-05-22 13:33:38 +02:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
|
|
pub enum ProcessMode {
|
|
|
|
/// The plugin is processing audio in real time at a fixed rate.
|
|
|
|
Realtime,
|
|
|
|
/// The plugin is processing audio at a real time-like pace, but at irregular intervals. The
|
|
|
|
/// host may do this to process audio ahead of time to loosen realtime constraints and to reduce
|
|
|
|
/// the chance of xruns happening. This is only used by VST3.
|
|
|
|
Buffered,
|
|
|
|
/// The plugin is rendering audio offline, potentially faster than realtime ('freewheeling').
|
|
|
|
/// The host will continuously call the process function back to back until all audio has been
|
|
|
|
/// processed.
|
|
|
|
Offline,
|
|
|
|
}
|
2022-07-05 22:53:14 +02:00
|
|
|
|
|
|
|
/// Configuration for the plugin's polyphonic modulation options, if it supports .
|
|
|
|
pub struct PolyModulationConfig {
|
|
|
|
/// The maximum number of voices this plugin will ever use. Call the context's
|
2022-07-05 23:24:05 +02:00
|
|
|
/// `set_current_voice_capacity()` method during initialization or audio processing to set the
|
|
|
|
/// polyphony limit.
|
|
|
|
pub max_voice_capacity: u32,
|
2022-07-05 22:53:14 +02:00
|
|
|
/// If set to `true`, then the host may send note events for the same channel and key, but using
|
|
|
|
/// different voice IDs. Bitwig Studio, for instance, can use this to do voice stacking. After
|
|
|
|
/// enabling this, you should always prioritize using voice IDs to map note events to voices.
|
|
|
|
pub supports_overlapping_voices: bool,
|
|
|
|
}
|