Skip to main content

Module setup

Module setup 

Source
Expand description

Plugin setup types for declaring host information requirements.

Use these types with Descriptor::Setup to specify what information your plugin needs from the host during preparation.

§Quick Reference

TypeValueUse Case
()-Stateless plugins (gain, pan)
SampleRatef64Time-based DSP (delay, filter, envelope)
MaxBufferSizeusizeFFT, lookahead buffers
MainInputChannelsu32Per-channel input processing
MainOutputChannelsu32Per-channel output state
AuxInputCountusizeSidechain-aware processing
AuxOutputCountusizeMulti-bus output
ProcessModeenumQuality settings for offline rendering

§Combining Types

Request multiple values using tuples:

type Setup = (SampleRate, MaxBufferSize);
type Setup = (SampleRate, MainOutputChannels);
type Setup = (SampleRate, MaxBufferSize, ProcessMode);

§Examples

use beamer::setup::*;

// Stateless plugin (gain, pan)
impl Descriptor for Gain {
    type Setup = ();
    fn prepare(self, _: ()) -> Self { self }
}

// Time-based DSP (delay, filter, envelope, smoothing)
impl Descriptor for Delay {
    type Setup = SampleRate;
    fn prepare(self, sample_rate: SampleRate) -> DelayProcessor {
        let buffer_size = (2.0 * sample_rate.hz()) as usize;
        DelayProcessor { buffer: vec![0.0; buffer_size], /* ... */ }
    }
}

// FFT or lookahead processing
impl Descriptor for Fft {
    type Setup = (SampleRate, MaxBufferSize);
    fn prepare(self, (sr, mbs): (SampleRate, MaxBufferSize)) -> FftProcessor {
        FftProcessor { fft_buffer: vec![0.0; mbs.0], /* ... */ }
    }
}

Re-exports§

pub use crate::plugin::PluginSetup;
pub use crate::plugin::AuxInputCount;
pub use crate::plugin::AuxOutputCount;
pub use crate::plugin::MainInputChannels;
pub use crate::plugin::MainOutputChannels;
pub use crate::plugin::MaxBufferSize;
pub use crate::plugin::ProcessMode;
pub use crate::plugin::SampleRate;