pub struct Vst3Host { /* private fields */ }Expand description
VST3 host instance
Implementations§
Source§impl Vst3Host
impl Vst3Host
Sourcepub fn new() -> Result<Self>
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.
Sourcepub fn builder() -> Vst3HostBuilder
pub fn builder() -> Vst3HostBuilder
Create a new VST3 host builder
Sourcepub fn add_scan_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn add_scan_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Add a custom path to scan for VST3 plugins
Sourcepub fn discover_plugins(&mut self) -> Result<Vec<PluginInfo>>
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.
Sourcepub fn scan_plugin_paths(&self) -> Vec<PathBuf>
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.
Sourcepub fn discover_plugins_with_callback<F>(
&mut self,
on_progress: F,
) -> Result<Vec<PluginInfo>>where
F: FnMut(DiscoveryProgress),
pub fn discover_plugins_with_callback<F>(
&mut self,
on_progress: F,
) -> Result<Vec<PluginInfo>>where
F: FnMut(DiscoveryProgress),
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.
Sourcepub fn discover_plugins_safe(&self) -> SafeDiscoveryReport
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.
Sourcepub fn load_plugin_class<P: AsRef<Path>>(
&mut self,
path: P,
class_id: &str,
) -> Result<Plugin>
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.
Sourcepub fn probe_plugin<P: AsRef<Path>>(&self, path: P) -> ProbeResult
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.
Sourcepub fn config(&self) -> &AudioConfig
pub fn config(&self) -> &AudioConfig
Get audio configuration
Source§impl Vst3Host
impl Vst3Host
Sourcepub fn play(&self, plugin: Plugin) -> Result<AudioHandle>
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));Sourcepub fn play_with_input(&self, plugin: Plugin) -> Result<AudioHandle>
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.
Sourcepub fn play_realtime(
&self,
plugin: Plugin,
command_capacity: usize,
) -> Result<RtAudioHandle>
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));