Skip to main content

Vst3Host

Struct Vst3Host 

Source
pub struct Vst3Host { /* private fields */ }
Expand description

VST3 host instance

Implementations§

Source§

impl Vst3Host

Source

pub fn new() -> Result<Self>

Create a new VST3 host with default settings.

Discovery scans the standard system VST3 directories (consistent with Vst3Host::default). For explicit control use Vst3Host::builder; the builder does not scan system paths unless you opt in with Vst3HostBuilder::scan_default_paths.

Source

pub fn builder() -> Vst3HostBuilder

Create a new VST3 host builder

Source

pub fn add_scan_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Add a custom path to scan for VST3 plugins

Source

pub fn discover_plugins(&mut self) -> Result<Vec<PluginInfo>>

Discover VST3 plugins in configured scan paths.

§This can take your process down

Every candidate is instantiated in this process to read its metadata, so a plugin that aborts, segfaults, or throws a C++ exception through the Rust frames during its own initialisation kills the host — there is nothing this function can catch. That is not hypothetical: a licensed Waves plugin in a normal /Library/Audio/Plug-Ins/VST3 aborts with “Rust cannot catch foreign exceptions” during its license check.

Prefer Self::discover_plugins_safe, which introspects each plugin in a short-lived child process and reports the casualties as skips instead of dying. Use this one only when you control which plugins are present.

Source

pub fn scan_plugin_paths(&self) -> Vec<PathBuf>

List VST3 bundle paths in the configured scan locations without loading them.

Fast and safe: unlike Self::discover_plugins (which loads and initializes every plugin to read its metadata, and can be slow or crash-prone in-process), this only walks the filesystem. Use it when you just need the list of available .vst3 paths (e.g. to populate a picker) and will load on demand.

Source

pub fn discover_plugins_with_callback<F>( &mut self, on_progress: F, ) -> Result<Vec<PluginInfo>>

Discover VST3 plugins, reporting progress through a callback.

The callback receives DiscoveryProgress events: one Started at the beginning, a Found or Error per candidate, and a final Completed. Returns the successfully-inspected plugins, same as Self::discover_plugins.

Source

pub fn discover_plugins_safe(&self) -> SafeDiscoveryReport

Crash-resistantly discover plugins in the configured scan paths.

Unlike Self::discover_plugins — which instantiates each plugin in-process to read its metadata, so a single plugin that abort()s or makes a pure-virtual call during init takes down the whole host — this introspects every plugin in a throwaway child process (vst3-host-probe). A plugin that crashes kills only that child; the scan completes and returns the plugins it could introspect, recording the skipped ones (and why) in the returned SafeDiscoveryReport.

Trade-off: this spawns one probe process per plugin, so it is slower than the in-process path. Use it to safely scan an untrusted folder; keep Self::discover_plugins for speed when you trust the plugins.

The probe timeout per plugin defaults to DEFAULT_PROBE_TIMEOUT; override it with Vst3HostBuilder::probe_timeout.

If the vst3-host-probe binary cannot be located the scan never runs; the report is empty and says why in SafeDiscoveryReport::error.

Source

pub fn load_plugin<P: AsRef<Path>>(&mut self, path: P) -> Result<Plugin>

Load a VST3 plugin

Source

pub fn load_plugin_class<P: AsRef<Path>>( &mut self, path: P, class_id: &str, ) -> Result<Plugin>

Load a particular audio class from a VST3 bundle.

class_id may be either a current class id exported by the factory or a retired id mapped to its replacement by the bundle’s validated moduleinfo.json. This is useful when restoring a session whose plugin id predates a vendor’s UID migration.

Source

pub fn probe_plugin<P: AsRef<Path>>(&self, path: P) -> ProbeResult

Probe whether a plugin loads safely, without risking the host process — it is loaded in an isolated helper, so a crash is contained. This is the “validate plugins” operation a scanner uses to blacklist bad plugins.

Requires the process-isolation feature.

Source

pub fn config(&self) -> &AudioConfig

Get audio configuration

Source§

impl Vst3Host

Source

pub fn play(&self, plugin: Plugin) -> Result<AudioHandle>

Load a plugin and immediately start playing it through the default audio output device, using the host’s configured sample rate and block size.

This is the “batteries-included” path: it wires a CpalBackend to the plugin and pumps audio for you. The returned AudioHandle keeps the stream alive — drop it to stop — and lets you keep sending MIDI / changing parameters while it plays:

let mut host = Vst3Host::new()?;
let plugin = host.load_plugin("/path/to/synth.vst3")?;
let audio = host.play(plugin)?;
audio.lock().send_midi_note(60, 100, MidiChannel::Ch1)?;
std::thread::sleep(std::time::Duration::from_secs(1));
Source

pub fn play_with_input(&self, plugin: Plugin) -> Result<AudioHandle>

Host a plugin on live audio input (effect hosting): capture from the default input device, process through the plugin, and play the result on the default output device.

Use this for effect plugins (EQ, reverb, compressor); for instruments use Self::play. Control the plugin via the returned AudioHandle.

Source

pub fn play_realtime( &self, plugin: Plugin, command_capacity: usize, ) -> Result<RtAudioHandle>

Play a plugin through the default device using the lock-free real-time path (a RealtimePluginRunner) instead of the mutex-based Self::play.

The audio callback takes no lock; queue MIDI and parameter changes through the returned handle’s RtControl:

let mut host = Vst3Host::new()?;
let plugin = host.load_plugin("/path/synth.vst3")?;
let mut audio = host.play_realtime(plugin, 1024)?;
audio.control().send_midi(MidiEvent::NoteOn { channel: MidiChannel::Ch1, note: 60, velocity: 100 });
std::thread::sleep(std::time::Duration::from_secs(1));

Trait Implementations§

Source§

impl Default for Vst3Host

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.