Skip to main content

beamer_core/
setup.rs

1//! Plugin setup types for declaring host information requirements.
2//!
3//! Use these types with [`Descriptor::Setup`](crate::Descriptor::Setup) to specify what
4//! information your plugin needs from the host during preparation.
5//!
6//! # Quick Reference
7//!
8//! | Type | Value | Use Case |
9//! |------|-------|----------|
10//! | `()` | - | Stateless plugins (gain, pan) |
11//! | [`SampleRate`] | `f64` | Time-based DSP (delay, filter, envelope) |
12//! | [`MaxBufferSize`] | `usize` | FFT, lookahead buffers |
13//! | [`MainInputChannels`] | `u32` | Per-channel input processing |
14//! | [`MainOutputChannels`] | `u32` | Per-channel output state |
15//! | [`AuxInputCount`] | `usize` | Sidechain-aware processing |
16//! | [`AuxOutputCount`] | `usize` | Multi-bus output |
17//! | [`ProcessMode`] | enum | Quality settings for offline rendering |
18//!
19//! # Combining Types
20//!
21//! Request multiple values using tuples:
22//!
23//! ```ignore
24//! type Setup = (SampleRate, MaxBufferSize);
25//! type Setup = (SampleRate, MainOutputChannels);
26//! type Setup = (SampleRate, MaxBufferSize, ProcessMode);
27//! ```
28//!
29//! # Examples
30//!
31//! ```ignore
32//! use beamer::setup::*;
33//!
34//! // Stateless plugin (gain, pan)
35//! impl Descriptor for Gain {
36//!     type Setup = ();
37//!     fn prepare(self, _: ()) -> Self { self }
38//! }
39//!
40//! // Time-based DSP (delay, filter, envelope, smoothing)
41//! impl Descriptor for Delay {
42//!     type Setup = SampleRate;
43//!     fn prepare(self, sample_rate: SampleRate) -> DelayProcessor {
44//!         let buffer_size = (2.0 * sample_rate.hz()) as usize;
45//!         DelayProcessor { buffer: vec![0.0; buffer_size], /* ... */ }
46//!     }
47//! }
48//!
49//! // FFT or lookahead processing
50//! impl Descriptor for Fft {
51//!     type Setup = (SampleRate, MaxBufferSize);
52//!     fn prepare(self, (sr, mbs): (SampleRate, MaxBufferSize)) -> FftProcessor {
53//!         FftProcessor { fft_buffer: vec![0.0; mbs.0], /* ... */ }
54//!     }
55//! }
56//! ```
57
58pub use crate::plugin::{
59    // Core trait
60    PluginSetup,
61    // Individual setup types
62    AuxInputCount,
63    AuxOutputCount,
64    MainInputChannels,
65    MainOutputChannels,
66    MaxBufferSize,
67    ProcessMode,
68    SampleRate,
69};