A lightweight C++ wrapper for loading and working with VST3 plugins.
OwnVst3Host is a C++ library that provides a simplified interface for hosting VST3 plugins in your applications. It handles the complex details of the VST3 SDK and provides an easy-to-use API for loading plugins, manipulating parameters, processing audio, and handling MIDI events.
- Load VST3 plugins from file paths
- Get plugin information (name, vendor, etc.)
- Create and manage plugin editor UI
- List, get, and set plugin parameters
- Process audio through plugins
- Send MIDI events to instrument plugins
- Detect plugin types (instrument vs effect)
- Cross-platform support (Windows, macOS, Linux)
- C++17 or higher
- VST3 SDK (Steinberg)
- Windows, macOS, or Linux operating system
git clone --recurse-submodules https://github.com/ModernMube/OwnVST3.git- Include the OwnVst3Host header and source files in your project
- Make sure the VST3 SDK is properly set up and linked
- When building as a DLL, define:
OWN_VST3_HOST_EXPORTSfor the C++ APIOWN_VST3_WRAPPER_EXPORTSfor the C wrapper API
mkdir build
cd build
cmake ..
cmake --build .mkdir build
cd build
cmake ..
make#include "ownvst3.h"
#include <iostream>
#include <vector>
int main() {
// Create plugin instance
OwnVst3Host::Vst3Plugin plugin;
// Load a VST3 plugin
if (plugin.loadPlugin("C:/Path/To/YourPlugin.vst3")) {
// Initialize with sample rate and block size
plugin.initialize(44100.0, 512);
// Print plugin information
std::cout << "Plugin loaded: " << plugin.getName() << std::endl;
std::cout << plugin.getPluginInfo() << std::endl;
// Get parameters
auto params = plugin.getParameters();
std::cout << "Parameters:" << std::endl;
for (const auto& param : params) {
std::cout << " " << param.name << " (ID: " << param.id << ")" << std::endl;
}
// Create audio buffer for processing
float* inputBuffer[2] = { /* your input data */ };
float* outputBuffer[2] = { /* buffer for output data */ };
OwnVst3Host::AudioBuffer buffer;
buffer.inputs = inputBuffer;
buffer.outputs = outputBuffer;
buffer.numChannels = 2;
buffer.numSamples = 512;
// Process audio
plugin.processAudio(buffer);
// Or send MIDI events if it's an instrument
if (plugin.isInstrument()) {
std::vector<OwnVst3Host::MidiEvent> midiEvents;
// Add note-on event
OwnVst3Host::MidiEvent noteOn;
noteOn.status = 0x90; // Note on, channel 0
noteOn.data1 = 60; // C4
noteOn.data2 = 100; // Velocity
noteOn.sampleOffset = 0;
midiEvents.push_back(noteOn);
plugin.processMidi(midiEvents);
}
}
return 0;
}The main class for interacting with VST3 plugins.
Vst3Plugin()- Creates a new VST3 plugin instance~Vst3Plugin()- Cleans up and releases resources
bool loadPlugin(const std::string& pluginPath)- Loads a VST3 plugin from the specified pathbool initialize(double sampleRate, int maxBlockSize)- Initializes the plugin with sample rate and block size
bool createEditor(void* windowHandle)- Creates and attaches the plugin's editor to a windowvoid closeEditor()- Closes the plugin editorvoid resizeEditor(int width, int height)- Resizes the plugin editor windowbool getEditorSize(int& width, int& height)- Gets the editor's preferred sizevoid processIdle()- Processes idle events (should be called periodically from UI thread)bool isEditorOpen()- Checks if the editor window is currently open
std::vector<Vst3Parameter> getParameters()- Gets all available parametersint getParameterCount()- Gets total parameter countbool getParameterInfo(int index, Vst3Parameter& outParam)- Gets parameter by indexbool setParameter(int paramId, double value)- Sets a parameter valuedouble getParameter(int paramId)- Gets a parameter value
bool processAudio(AudioBuffer& buffer)- Processes audio through the pluginbool processMidi(const std::vector<MidiEvent>& events)- Sends MIDI events to the pluginint getActualInputChannels()- Gets the actual input channel count accepted by the pluginint getActualOutputChannels()- Gets the actual output channel count accepted by the plugin
void setTempo(double bpm)- Sets the playback tempo (BPM)void setTransportState(bool playing)- Sets the transport playing statevoid resetTransportPosition()- Resets the transport sample position counter
bool isInstrument()- Checks if the plugin is an instrumentbool isEffect()- Checks if the plugin is an effectbool isMidiOnly()- Checks if the plugin accepts MIDI but has no audio output
std::string getName()- Gets the plugin namestd::string getVendor()- Gets the plugin vendorstd::string getVersion()- Gets the plugin versionstd::string getPluginInfo()- Gets formatted plugin information
A C-compatible wrapper is available for use with languages that can interface with C but not C++. Include ownvst3_wrapper.h for access.
VST3PluginHandle VST3Plugin_Create()- Creates a new plugin instancevoid VST3Plugin_Destroy(VST3PluginHandle handle)- Destroys a plugin instancebool VST3Plugin_LoadPlugin(VST3PluginHandle handle, const char* pluginPath)- Loads a pluginbool VST3Plugin_Initialize(VST3PluginHandle handle, double sampleRate, int maxBlockSize)- Initializes the pluginbool VST3Plugin_CreateEditor(VST3PluginHandle handle, void* windowHandle)- Creates editorvoid VST3Plugin_CloseEditor(VST3PluginHandle handle)- Closes editorvoid VST3Plugin_ResizeEditor(VST3PluginHandle handle, int width, int height)- Resizes editorbool VST3Plugin_GetEditorSize(VST3PluginHandle handle, int* width, int* height)- Gets editor sizevoid VST3Plugin_ProcessIdle(VST3PluginHandle handle)- Processes idle eventsbool VST3Plugin_IsEditorOpen(VST3PluginHandle handle)- Checks if editor is currently openint VST3Plugin_GetParameterCount(VST3PluginHandle handle)- Gets parameter countbool VST3Plugin_GetParameterAt(VST3PluginHandle handle, int index, VST3ParameterC* parameter)- Gets parameter by indexbool VST3Plugin_SetParameter(VST3PluginHandle handle, int paramId, double value)- Sets parameterdouble VST3Plugin_GetParameter(VST3PluginHandle handle, int paramId)- Gets parameter valuebool VST3Plugin_ProcessAudio(VST3PluginHandle handle, AudioBufferC* buffer)- Processes audiobool VST3Plugin_ProcessMidi(VST3PluginHandle handle, const MidiEventC* events, int eventCount)- Processes MIDIint VST3Plugin_GetActualInputChannels(VST3PluginHandle handle)- Gets actual input channelsint VST3Plugin_GetActualOutputChannels(VST3PluginHandle handle)- Gets actual output channelsvoid VST3Plugin_SetTempo(VST3PluginHandle handle, double bpm)- Sets playback tempovoid VST3Plugin_SetTransportState(VST3PluginHandle handle, bool isPlaying)- Sets transport statevoid VST3Plugin_ResetTransportPosition(VST3PluginHandle handle)- Resets transport positionbool VST3Plugin_IsInstrument(VST3PluginHandle handle)- Checks if instrumentbool VST3Plugin_IsEffect(VST3PluginHandle handle)- Checks if effectbool VST3Plugin_IsMidiOnly(VST3PluginHandle handle)- Checks if plugin is MIDI onlyconst char* VST3Plugin_GetName(VST3PluginHandle handle)- Gets plugin nameconst char* VST3Plugin_GetVendor(VST3PluginHandle handle)- Gets plugin vendorconst char* VST3Plugin_GetVersion(VST3PluginHandle handle)- Gets plugin versionconst char* VST3Plugin_GetPluginInfo(VST3PluginHandle handle)- Gets plugin infovoid VST3Plugin_ClearStringCache()- Clears the internal string cache
This project is available under the MIT License.
Based on the VST3 SDK by Steinberg Media Technologies GmbH.
If you find this project helpful, consider buying me a coffee!
