Skip to content

XP event5x XPListening, games, ratings, comments and chat earn five times the XP

leftLeaderboard

juicewrld-desktopsrc-taurihostshimjwvst3.h

1.4.2Released Nov 21, 2026

jwvst3.h

161 lines8.7 KBC++
// The plugin host's VST 3 side, as plain C for Rust (host/shim.rs): modules, their classes, instances (setup,// processing, state, parameters) and each instance's editor window. Everything touching Steinberg's interfaces lives// in jwvst3.cpp; the host process (host/main.rs) drives it.//// Threads: the host's main thread (the UI thread VST 3 means) makes every call here except jw_plugin_process and// jw_plugin_set_processing, which run on that instance's audio thread. Errors come back as a message in `err`.#pragma once#include <stddef.h>#include <stdint.h>#ifdef __cplusplusextern "C" {#endiftypedef struct JwModule JwModule;typedef struct JwPlugin JwPlugin;typedef struct JwFactoryInfo {	char vendor[256];	char url[256];	char email[256];	int32_t flags;} JwFactoryInfo;typedef struct JwClassInfo {	char cid[33];             // the class ID, 32 hex digits	char category[128];       // "Audio Module Class" for plugins	char name[256];	char vendor[256];	char version[128];	char sdk_version[128];	char sub_categories[512]; // "Fx|EQ", as the factory says it	uint32_t class_flags;	int32_t cardinality;} JwClassInfo;/// What a new instance looks like once set up.typedef struct JwPluginInfo {	int32_t in_channels;   // channels of the main audio input bus (0: none, an instrument)	int32_t out_channels;  // of the main audio output bus	int32_t in_buses;      // audio input buses in all (a side chain is one more)	int32_t out_buses;	int32_t latency;       // IAudioProcessor::getLatencySamples	uint32_t tail;         // getTailSamples	int32_t has_editor;    // the controller can make an editor view	int32_t param_count;	int32_t single;        // component and controller are one object	int32_t bypass_param;  // the plugin has its own bypass parameter (kIsBypass)	char name[256];        // the class's name} JwPluginInfo;typedef struct JwParamInfo {	uint32_t id;	char title[256];	char short_title[128];	char units[64];	int32_t step_count;	double default_value;  // normalized	double value;          // normalized, now	int32_t flags;         // ParameterInfo::flags (1 automate, 2 read only, 4 wrap, 8 list, 16 hidden, 65536 bypass)	char display[128];     // the value as the plugin writes it} JwParamInfo;/// The page's transport, for ProcessContext.typedef struct JwTransport {	double tempo;          // beats per minute (0: unknown)	int32_t playing;	int64_t position;      // project time in samples} JwTransport;/// Calls back into the host process. All on the main thread except where noted.typedef struct JwCallbacks {	void* ctx;	/// IComponentHandler::performEdit (phase 1), beginEdit (0) and endEdit (2) from the plugin's own editor.	void (*param_edit)(void* ctx, uint32_t tag, uint32_t id, double value, int32_t phase);	/// IComponentHandler::restartComponent. May come from any thread: only record it.	void (*restart)(void* ctx, uint32_t tag, int32_t flags);	/// The editor window closed (its close button, or the plugin), at this position.	void (*editor_closed)(void* ctx, uint32_t tag, int32_t x, int32_t y);	/// The editor window was moved or resized by the user (when the move ends).	void (*editor_moved)(void* ctx, uint32_t tag, int32_t x, int32_t y, int32_t w, int32_t h);	/// IComponentHandler2::requestOpenEditor.	void (*open_editor)(void* ctx, uint32_t tag);} JwCallbacks;/// Once, on the main thread before anything else: the host context plugins see, and where calls go.void jw_init(const JwCallbacks* callbacks);/// Where the shim's own lines go: the host process's private handle to the app's log (a pipe no plugin sees), written/// with one WriteFile per line. Also where the exit report goes when something in the process calls ExitProcess (a/// plugin, or its C runtime's exit()): "[exit] {...}" naming the modules on that thread's stack. NULL: nowhere.void jw_set_log(void* handle);/// The scan child: jw_module_load reports each step to the log ("[stage] load", "[stage] context", "[stage] class 3/// of 718", "[stage] done"), so a module that ends the process is caught at the step it ended it in.void jw_set_stages(int32_t on);/// Test runs only (the host's debug build, asked by the run): editor windows open without taking focus and behind/// the other windows on the screen, so a scripted run never gets in the way of the person at the PC.void jw_set_quiet_windows(int32_t on);/// Loads a module (a .vst3 bundle folder or a single .vst3 file): LoadLibrary, InitDll, GetPluginFactory, then reads/// every class its factory lists (a shell such as Waves' WaveShell lists hundreds). A class whose info can't be read/// is skipped, not fatal.JwModule* jw_module_load(const char* path_utf8, char* err, size_t err_len);void jw_module_free(JwModule* m);int32_t jw_module_factory_info(JwModule* m, JwFactoryInfo* out);int32_t jw_module_class_count(JwModule* m);int32_t jw_module_class_info(JwModule* m, int32_t index, JwClassInfo* out);/// Creates and initializes an instance of class `cid` (32 hex digits): component, controller, their connection,/// the component's state handed to the controller. `tag` names it in callbacks.JwPlugin* jw_plugin_create(JwModule* m, const char* cid, uint32_t tag, char* err, size_t err_len);/// Stereo buses where the plugin takes them, processing set up at `rate` with blocks of up to `max_block`, then/// active. `offline` asks for kOffline processing (an export) instead of kRealtime.int32_t jw_plugin_setup(JwPlugin* p, double rate, int32_t max_block, int32_t offline, JwPluginInfo* out, char* err, size_t err_len);/// setActive(false) then (true): flushes delay lines and reverb tails, and takes a changed latency or bus layout.int32_t jw_plugin_reactivate(JwPlugin* p, JwPluginInfo* out);int32_t jw_plugin_latency(JwPlugin* p);/// Audio thread: setProcessing.int32_t jw_plugin_set_processing(JwPlugin* p, int32_t on);/// Audio thread: one block of up to max_block frames, stereo in and out (planar). The parameters changed since the/// last block go in with it, each at its newest value. Returns the plugin's tresult (0 is kResultOk).int32_t jw_plugin_process(JwPlugin* p, const float* in_l, const float* in_r, float* out_l, float* out_r, int32_t frames, const JwTransport* t);/// Whether parameter changes are waiting for the processor (any thread).int32_t jw_plugin_params_pending(JwPlugin* p);/// Audio thread, while processing (setProcessing(true)): hands the processor the parameter changes waiting, with no/// audio (process() with no samples and no buses, VST 3's parameter flush), so it plays and saves what the controller/// shows when no audio flows. Returns the plugin's tresult.int32_t jw_plugin_flush(JwPlugin* p);/// The component's (which 0) or the controller's (1) state. Free the bytes with jw_free.int32_t jw_plugin_get_state(JwPlugin* p, int32_t which, uint8_t** data, int64_t* len, char* err, size_t err_len);/// Sets both states the way a project loads: component, then the controller from it, then the controller's own.int32_t jw_plugin_set_state(JwPlugin* p, const uint8_t* comp, int64_t comp_len, const uint8_t* ctrl, int64_t ctrl_len, char* err, size_t err_len);int32_t jw_plugin_param_count(JwPlugin* p);int32_t jw_plugin_param_info(JwPlugin* p, int32_t index, JwParamInfo* out);/// A normalized value for parameter `id`: the controller shows it and the processor gets it with the next block.int32_t jw_plugin_set_param(JwPlugin* p, uint32_t id, double value);/// The plugin's own bypass parameter, if it has one: returns 0 when set, -1 when it has none.int32_t jw_plugin_set_bypass(JwPlugin* p, int32_t on);/// Main thread, now and then: output parameter changes from the processor go to the controller.void jw_plugin_idle(JwPlugin* p);/// Closes the editor, deactivates, disconnects, terminates and releases. Processing must have stopped.void jw_plugin_destroy(JwPlugin* p);/// The plugin's editor in a window of its own, owned by `owner` (it floats above it), titled `title`. At (x, y) in/// screen pixels when `use_pos` and that point is on a monitor, else centred over the owner. Shown again if open.int32_t jw_editor_open(JwPlugin* p, intptr_t owner, const char* title_utf8, int32_t x, int32_t y, int32_t use_pos, char* err, size_t err_len);/// Closes it (the view is removed and released); no editor_closed callback.void jw_editor_close(JwPlugin* p);int32_t jw_editor_is_open(JwPlugin* p);void jw_editor_set_title(JwPlugin* p, const char* title_utf8);/// Where the window is: x, y, width, height. Returns 0 when open.int32_t jw_editor_rect(JwPlugin* p, int32_t* rect4);void jw_free(void* data);/// Points the C runtime's stdin, stdout and stderr at NUL (closing the handles the process was started with), so/// nothing a plugin prints or reads touches the pipes to the app; the host keeps its own copies of those.void jw_redirect_stdio(void);#ifdef __cplusplus}#endif