vst
on Crates.io.vst
is a crate that implements the VST 2.4 specification by Steinberg. VSTs (Virtual Studio Technology) are audio plugins used in a variety of applications. Its basic features are as follows:vst
crate isn't quite there yet! It's not much of a framework, and instead just lets you interact with MIDI notes and an audio buffer. It also doesn't have proper UI support yet. But hey, it's 0.0.1 - give us some time. vst
is a fork of the original vst2
source, with a community of developers and maintainers keeping the project active.vst
crate, and not the vst2
crate. It sounds counterintuitive, but just roll with it.vst
dependency, as well as specify that our crate type is 'cdylib'. It should look like this:Plugin
trait for our Whisper
struct. This Plugin
trait contains all the info we need to comply with the VST standard in a struct aptly named Info
.Info
struct with mostly default options. But there's a lot of stuff we can change to tell our host what our plugin does and expects. We can find full options in the plugin.rs
file.name
- The name of our plugin as a String
vendor
- The creator (e.g. company) of our plugin as a String
presets
- The number of presets as an i32
. We can safely ignore this for now, and if you don't know what a preset is, don't worry.inputs
- The number of audio inputs as an i32
. This has a default of 2
(one for the left channel, one for the right). Since we're creating a synthesizer that requires no inputs, we'll set this to 0
later.outputs
- The number of audio outputs as an i32
. This again has a default of 2
. This makes sense for our application which will output stereo audio. If we were building a surround-sound white-noise-ear-blaster, we would want to change this.unique_id
- This is required, but kind of pointless.version
- pretty self explanatory. This is saved as an i32, but you can still do semantic versioning. For example, a value of 0001
would be the equivalent of version 0.0.0.1
. 1234
would be the equivalent of version 1.2.3.4
.category
- This is an enum that specifies the category of the plugin, which is used in some DAWs. We're making a Category::Synth
, which means we're going to create an output. If we made a Category::Effect
, we might process inputs and modify their buffer.initial_delay
, preset_chunks
, f64_precision
, silent_when_stopped
- don't worry about these right now!lib.rs
file.cargo run
, though, because VSTs are .dll
s. They need to be run inside of a VST host. If you use a DAW (Digital Audio Workstation), chances are you already have a VST host. Ableton Live, FL Studio, and Logic are a few popular examples. If you already have a VST host, look in your use manual on how to add VSTs or VST search directories.whisper.dll
should be present in your target/debug
directory. This is our VST file.whisper.dll
file onto the main window. It should look something like this.Info
struct.Plugin
trait has a few other functions - the most notable being process
. This is where we'll do a bunch of stuff with our audio buffer.-1.0
to 1.0
. So to achieve white noise, we want to fill our AudioBuffer
with, well, random noise.lib.rs
file, and define a new function.0
! We're just outputting silence. Let's fix this.Cargo.toml
file to remedy this.-1.0
to 1.0
to our buffer.use
statement at the top of the file.*output_sample = (random::<f32>() - 0.5f32) * 2f32;
looks weird, right? What's with the extra operations? random
function gives us a number between 0.0
and 1.0
, instead of -1.0
and 1.0
like we want. By subtracting 0.5
and then multiplying by 2.0
, we can get our desired result.random
function for every sample. This tutorial won't delve into optimization, but if you want to look at a possible solution, check out this example.--release
flag. This turns on certain optimizations that will help your plugin be more performant, at the cost of longer build times.note_on
event, and subtracting 1 from the counter whenever a note_off
event is received.Cell
.--release
flag to cargo builds to further optimize code. doomy
or _doomy
. You can also add me on telegram @piedoomy, where I'm most certain to respond.