vst2sdk

A clean room reverse engineering project for the VST 2.x interface
Log | Files | Refs | README | LICENSE

vst.h (25638B)


      1 /*
      2  * Copyright 2020 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
      3  *
      4  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
      5  *
      6  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
      7  *
      8  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
      9  *
     10  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     11  */
     12 
     13 /*
     14  * This was created from released VST2.x plugins, and is technically under the 2-clause BSD license. Depending on which country you are in, Steinberg can do fuck all about this. Notable countries for this are most members of the United States of America, the entirety of Europe, Japan, and Russia.
     15  *
     16  * Consult a lawyer if you don't know if clean room reverse engineering is allowed in your country.
     17  *
     18  * See README.md for all information.
     19  */
     20 
     21 // Known additional information:
     22 // - Function call standard seems to be stdcall.
     23 // - Everything is aligned to 8 bytes.
     24 
     25 // VST Versioning:
     26 // - Base-10, thus can't store many version numbers.
     27 // - Always four components, with the major one being able to store the most numbers.
     28 // - Format is A...ABCD, so 1.2.3.4 would turn into 1234.
     29 
     30 #pragma once
     31 #ifndef VST2SDK_VST_H
     32 #define VST2SDK_VST_H
     33 
     34 #define VST_FUNCTION_INTERFACE __cdecl
     35 #define VST_ALIGNMENT 8
     36 #define VST_MAGICNUMBER 'VstP'
     37 
     38 // Common VST buffer lengths:
     39 // 8: OpCodes(GetLabel, GetName, GetValue)
     40 #define VST_BUFFER_8 8
     41 // 16:
     42 #define VST_BUFFER_16 16
     43 // 24: OpCodes?
     44 #define VST_BUFFER_24 24
     45 // 32: OpCodes(EffectName)
     46 #define VST_BUFFER_32 32
     47 #define VST_EFFECT_BUFFER_SIZE 32
     48 // 64: OpCodes(ProductName, VendorName)
     49 #define VST_BUFFER_64 64
     50 #define VST_VENDOR_BUFFER_SIZE VST_BUFFER_64
     51 #define VST_PRODUCT_BUFFER_SIZE VST_BUFFER_64
     52 #define VST_NAME_BUFFER_SIZE VST_BUFFER_64
     53 // 100:
     54 #define VST_BUFFER_100 100
     55 
     56 #define VST_MAX_CHANNELS 32 // Couldn't find any audio editing software which would attempt to add more channels.
     57 
     58 #pragma pack(push, VST_ALIGNMENT)
     59 
     60 #ifdef __cplusplus
     61 #include <cinttypes>
     62 extern "C" {
     63 #else
     64 #include <inttypes.h>
     65 #endif
     66 
     67 /*******************************************************************************
     68 |* Enumeration
     69 |*/
     70 enum VST_VERSION {
     71 	VST_VERSION_1       = 0, // Anything before 2.0, used by official plug-ins.
     72 	VST_VERSION_1_0_0_0 = 1000, // 1.0, used by some third-party plug-ins.
     73 	VST_VERSION_1_1_0_0 = 1100, // 1.1, used by some third-party plug-ins.
     74 	VST_VERSION_2       = 2, // 2.0, used by official plug-ins.
     75 	VST_VERSION_2_0_0_0 = 2000, // 2.0, used by some third-party plug-ins.
     76 	VST_VERSION_2_1_0_0 = 2100, // 2.1
     77 	VST_VERSION_2_2_0_0 = 2200, // 2.2
     78 	VST_VERSION_2_3_0_0 = 2300, // 2.3
     79 	VST_VERSION_2_4_0_0 = 2400, // 2.4
     80 
     81 	// Pad to force 32-bit number.
     82 	_VST_VERSION_PAD = 0xFFFFFFFFul,
     83 };
     84 
     85 enum VST_CATEGORY {
     86 	VST_CATEGORY_UNCATEGORIZED = 0x00,
     87 	VST_CATEGORY_01            = 0x01,
     88 	VST_CATEGORY_02            = 0x02,
     89 	VST_CATEGORY_03            = 0x03,
     90 	VST_CATEGORY_04            = 0x04,
     91 	VST_CATEGORY_05            = 0x05,
     92 	VST_CATEGORY_06            = 0x06,
     93 	VST_CATEGORY_07            = 0x07,
     94 	VST_CATEGORY_RESTORATION   = 0x08, // Denoising and similar effects.
     95 	VST_CATEGORY_09            = 0x09,
     96 	VST_CATEGORY_CONTAINER     = 0x0A, // Plugin contains more than one Plugin.
     97 	VST_CATEGORY_0B            = 0x0B,
     98 	VST_CATEGORY_MAX, // Not part of specification, marks maximum category.
     99 
    100 	// Pad to force 32-bit number.
    101 	_VST_CATEGORY_PAD = 0xFFFFFFFFul,
    102 };
    103 
    104 enum VST_EFFECT_OPCODE {
    105 	/* Create/Initialize the effect (if it has not been created already).
    106 	 * 
    107 	 * @return Always 0.
    108 	 */
    109 	VST_EFFECT_OPCODE_00         = 0x00,
    110 	VST_EFFECT_OPCODE_CREATE     = 0x00,
    111 	VST_EFFECT_OPCODE_INITIALIZE = 0x00,
    112 
    113 	/* Destroy the effect (if there is any) and free its memory.
    114 	 *
    115 	 * This should destroy the actual object created by VST_ENTRYPOINT.
    116 	 * 
    117 	 * @return Always 0.
    118 	 */
    119 	VST_EFFECT_OPCODE_01      = 0x01,
    120 	VST_EFFECT_OPCODE_DESTROY = 0x01,
    121 
    122 	/* Set Program
    123 	 *
    124 	 *
    125 	 */
    126 	VST_EFFECT_OPCODE_02 = 0x02,
    127 
    128 	/* Get Program
    129 	 *
    130 	 *
    131 	 */
    132 	VST_EFFECT_OPCODE_03 = 0x03,
    133 
    134 	/* Set Program Name
    135 	 *
    136 	 *
    137 	 */
    138 	VST_EFFECT_OPCODE_04 = 0x04,
    139 
    140 	/* Get Program Name
    141 	 *
    142 	 * "Returns 0. If ptr is valid, sets the first byte of ptr to 0 then returns 0."
    143 	 */
    144 	VST_EFFECT_OPCODE_05 = 0x05,
    145 
    146 	/* Get the value? label for the parameter.
    147 	 * 
    148 	 * @param p_int1 Parameter index.
    149 	 * @param p_ptr 'char[8]'
    150 	 * @return 0 on success, 1 on failure.
    151 	 */
    152 	VST_EFFECT_OPCODE_06             = 0x06,
    153 	VST_EFFECT_OPCODE_PARAM_GETLABEL = 0x06,
    154 
    155 	/* Get the string value for the parameter.
    156 	 * 
    157 	 * @param p_int1 Parameter index.
    158 	 * @param p_ptr 'char[8]'
    159 	 * @return 0 on success, 1 on failure.
    160 	 */
    161 	VST_EFFECT_OPCODE_07             = 0x07,
    162 	VST_EFFECT_OPCODE_PARAM_GETVALUE = 0x07,
    163 
    164 	/* Get the name for the parameter.
    165 	 * 
    166 	 * @param p_int1 Parameter index.
    167 	 * @param p_ptr 'char[8]'
    168 	 * @return 0 on success, 1 on failure.
    169 	 */
    170 	VST_EFFECT_OPCODE_08            = 0x08,
    171 	VST_EFFECT_OPCODE_PARAM_GETNAME = 0x08,
    172 
    173 	/*
    174 	 *
    175 	 *
    176 	 */
    177 	VST_EFFECT_OPCODE_09 = 0x09,
    178 
    179 	/* Set the new sample rate for the plugin to use.
    180 	 * 
    181 	 * @param p_float New sample rate as a float (double on 64-bit because register upgrades).
    182 	 */
    183 	VST_EFFECT_OPCODE_0A              = 0x0A,
    184 	VST_EFFECT_OPCODE_SETSAMPLERATE   = 0x0A,
    185 	VST_EFFECT_OPCODE_SET_SAMPLE_RATE = 0x0A,
    186 
    187 	/* Sets the block size, which is the maximum number of samples passed into the effect via process calls.
    188 	 *
    189 	 * @param p_int2 The maximum number of samples to be passed in.
    190 	 */
    191 	VST_EFFECT_OPCODE_0B             = 0x0B,
    192 	VST_EFFECT_OPCODE_SETBLOCKSIZE   = 0x0B,
    193 	VST_EFFECT_OPCODE_SET_BLOCK_SIZE = 0x0B,
    194 
    195 	/* Effect processing should be suspended/paused.
    196 	 *
    197 	 * Unclear if this is should result in a flush of buffers.
    198 	 * 
    199 	 * @param p_int2 0 if the effect should suspend processing, 1 if it should resume.
    200 	 */
    201 	VST_EFFECT_OPCODE_0C      = 0x0C,
    202 	VST_EFFECT_OPCODE_SUSPEND = 0x0C,
    203 
    204 	/* Retrieve the client rect size of the plugins window.
    205 	 * If no window has been created, returns the default rect.
    206 	 *
    207 	 * @param p_ptr Pointer of type 'struct vst_rect*'.
    208 	 * @return On success, returns 1 and updates p_ptr to the rect. On failure, returns 0.
    209 	 */
    210 	VST_EFFECT_OPCODE_0D             = 0x0D,
    211 	VST_EFFECT_OPCODE_WINDOW_GETRECT = 0x0D,
    212 
    213 	/* Create the window for the plugin.
    214 	 * 
    215 	 * @param p_ptr HWND of the parent window.
    216 	 * @return 0 on failure, or HWND on success.
    217 	 */
    218 	VST_EFFECT_OPCODE_0E            = 0x0E,
    219 	VST_EFFECT_OPCODE_WINDOW_CREATE = 0x0E,
    220 
    221 	/* Destroy the plugins window.
    222 	 * 
    223 	 * @return Always 0.
    224 	 */
    225 	VST_EFFECT_OPCODE_0F             = 0x0F,
    226 	VST_EFFECT_OPCODE_WINDOW_DESTROY = 0x0F,
    227 
    228 	/*
    229 	 *
    230 	 *
    231 	 */
    232 	VST_EFFECT_OPCODE_10 = 0x10,
    233 
    234 	/*
    235 	 *
    236 	 *
    237 	 */
    238 	VST_EFFECT_OPCODE_11 = 0x11,
    239 
    240 	/*
    241 	 *
    242 	 *
    243 	 */
    244 	VST_EFFECT_OPCODE_12 = 0x12,
    245 
    246 	/*
    247 	 *
    248 	 *
    249 	 */
    250 	VST_EFFECT_OPCODE_13 = 0x13,
    251 
    252 	/*
    253 	 *
    254 	 *
    255 	 */
    256 	VST_EFFECT_OPCODE_14 = 0x14,
    257 
    258 	/*
    259 	 *
    260 	 *
    261 	 */
    262 	VST_EFFECT_OPCODE_15 = 0x15,
    263 
    264 	/* Always returns the FourCC 'NvEF' (0x4E764566).
    265 	 */
    266 	VST_EFFECT_OPCODE_16 = 0x16,
    267 
    268 	/* Get Chunk
    269 	 *
    270 	 *
    271 	 */
    272 	VST_EFFECT_OPCODE_17 = 0x17,
    273 
    274 	/* Set Chunk
    275 	 *
    276 	 *
    277 	 */
    278 	VST_EFFECT_OPCODE_18 = 0x18,
    279 
    280 	// VST2.x starts here.
    281 
    282 	/*
    283 	 *
    284 	 *
    285 	 */
    286 	VST_EFFECT_OPCODE_19 = 0x19,
    287 
    288 	/* Can the parameter be automated?
    289 	 *
    290 	 * @param p_int1 Index of the parameter.
    291 	 * @return 1 if the parameter can be automated, otherwise 0.
    292 	 */
    293 	VST_EFFECT_OPCODE_1A                  = 0x1A,
    294 	VST_EFFECT_OPCODE_PARAM_ISAUTOMATABLE = 0x1A,
    295 
    296 	/*
    297 	 *
    298 	 *
    299 	 */
    300 	VST_EFFECT_OPCODE_1B = 0x1B,
    301 
    302 	/*
    303 	 *
    304 	 *
    305 	 */
    306 	VST_EFFECT_OPCODE_1C = 0x1C,
    307 
    308 	/*
    309 	 *
    310 	 *
    311 	 */
    312 	VST_EFFECT_OPCODE_1D = 0x1D, // See VST_EFFECT_OPCODE_05
    313 
    314 	/*
    315 	 *
    316 	 *
    317 	 */
    318 	VST_EFFECT_OPCODE_1E = 0x1E,
    319 
    320 	/* Input connected.
    321 	 *
    322 	 *
    323 	 */
    324 	VST_EFFECT_OPCODE_1F = 0x1F,
    325 
    326 	/* Input disconnected.
    327 	 *
    328 	 *
    329 	 */
    330 	VST_EFFECT_OPCODE_20 = 0x20,
    331 
    332 	/* Retrieve the name of the input channel at the given index.
    333 	 *
    334 	 * @param p_int1 Index of the input to get the name for.
    335 	 * @param p_ptr Pointer to a char* buffer able to hold at minimum 20 characters. Might need to be 32 even.
    336 	 * @return 0 on failure, 1 on success.
    337 	 */
    338 	VST_EFFECT_OPCODE_21                   = 0x21,
    339 	VST_EFFECT_OPCODE_INPUT_GETCHANNELNAME = 0x21,
    340 	VST_EFFECT_OPCODE_INPUT_CHANNEL_NAME   = 0x21,
    341 
    342 	/* Retrieve the name of the output channel at the given index.
    343 	 *
    344 	 * @param p_int1 Index of the output to get the name for.
    345 	 * @param p_ptr Pointer to a char* buffer able to hold at minimum 20 characters. Might need to be 32 even.
    346 	 * @return 0 on failure, 1 on success.
    347 	 */
    348 	VST_EFFECT_OPCODE_22                    = 0x22,
    349 	VST_EFFECT_OPCODE_OUTPUT_GETCHANNELNAME = 0x22,
    350 	VST_EFFECT_OPCODE_OUTPUT_CHANNEL_NAME   = 0x22,
    351 
    352 	/* Retrieve category of this effect.
    353 	 *
    354 	 * @return The category that this effect is in, see VST_CATEGORY.
    355 	 */
    356 	VST_EFFECT_OPCODE_23              = 0x23,
    357 	VST_EFFECT_OPCODE_EFFECT_CATEGORY = 0x23,
    358 
    359 	/*
    360 	 *
    361 	 *
    362 	 */
    363 	VST_EFFECT_OPCODE_24 = 0x24,
    364 
    365 	/*
    366 	 *
    367 	 *
    368 	 */
    369 	VST_EFFECT_OPCODE_25 = 0x25,
    370 
    371 	/*
    372 	 *
    373 	 *
    374 	 */
    375 	VST_EFFECT_OPCODE_26 = 0x26,
    376 
    377 	/*
    378 	 *
    379 	 *
    380 	 */
    381 	VST_EFFECT_OPCODE_27 = 0x27,
    382 
    383 	/*
    384 	 *
    385 	 *
    386 	 */
    387 	VST_EFFECT_OPCODE_28 = 0x28,
    388 
    389 	/*
    390 	 *
    391 	 *
    392 	 */
    393 	VST_EFFECT_OPCODE_29 = 0x29,
    394 
    395 	/* Set the speaker arrangement 
    396 	 *
    397 	 * @param p_int2 (vst_speaker_arrangement*) Pointer to a pointer to the speaker arrangement for the input.
    398 	 * @param p_ptr (vst_speaker_arrangement*) Pointer to a pointer to the speaker arrangement for the output.
    399 	 */
    400 	VST_EFFECT_OPCODE_2A                      = 0x2A,
    401 	VST_EFFECT_OPCODE_SET_SPEAKER_ARRANGEMENT = 0x2A,
    402 
    403 	/*
    404 	 *
    405 	 *
    406 	 */
    407 	VST_EFFECT_OPCODE_2B = 0x2B,
    408 
    409 	/* Enable/Disable bypassing the effect.
    410 	 *
    411 	 * @param p_int2 Zero if bypassing the effect is disabled, otherwise 1.
    412 	 */
    413 	VST_EFFECT_OPCODE_2C     = 0x2C,
    414 	VST_EFFECT_OPCODE_BYPASS = 0x2C,
    415 
    416 	/* Retrieve the effect name into the ptr buffer.
    417 	 *
    418 	 * @param p_ptr char[64] Buffer containing a zero-terminated effect information string. May be shorter than 64 bytes on older hosts.
    419 	 * @return Always 0, even on failure.
    420 	 */
    421 	VST_EFFECT_OPCODE_2D          = 0x2D,
    422 	VST_EFFECT_OPCODE_GETNAME     = 0x2D,
    423 	VST_EFFECT_OPCODE_EFFECT_NAME = 0x2D,
    424 
    425 	/* Translate an error code to a string.
    426 	 *
    427 	 * @param p_ptr char[256] Buffer that should contain a zero-terminated error string.
    428 	 */
    429 	VST_EFFECT_OPCODE_2E              = 0x2E,
    430 	VST_EFFECT_OPCODE_TRANSLATE_ERROR = 0x2E,
    431 
    432 	/* Retrieve the vendor name into the ptr buffer.
    433 	 *
    434 	 * @param p_ptr char[64] Buffer containing a zero-terminated vendor information string. May be shorter than 64 bytes on older hosts.
    435 	 * @return Always 0, even on failure.
    436 	 */
    437 	VST_EFFECT_OPCODE_2F          = 0x2F,
    438 	VST_EFFECT_OPCODE_GETVENDOR   = 0x2F,
    439 	VST_EFFECT_OPCODE_VENDOR_NAME = 0x2F,
    440 
    441 	/* See VST_EFFECT_OPCODE_GETNAME
    442 	 *
    443 	 * Rarely used, if at all even supported. Not sure what the purpose of this is even.
    444 	 */
    445 	VST_EFFECT_OPCODE_30           = 0x30,
    446 	VST_EFFECT_OPCODE_GETNAME2     = 0x30,
    447 	VST_EFFECT_OPCODE_PRODUCT_NAME = 0x30,
    448 
    449 	/* Retrieve the vendor version in return value.
    450 	 *
    451 	 * @return Version.
    452 	 */
    453 	VST_EFFECT_OPCODE_31               = 0x31,
    454 	VST_EFFECT_OPCODE_GETVENDORVERSION = 0x31,
    455 	VST_EFFECT_OPCODE_VENDOR_VERSION   = 0x31,
    456 
    457 	/* User defined OP Code, for custom interaction.
    458 	 * 
    459 	 */
    460 	VST_EFFECT_OPCODE_32     = 0x32,
    461 	VST_EFFECT_OPCODE_CUSTOM = 0x32,
    462 
    463 	/* Test for support of a specific named feature.
    464 	 * 
    465 	 * @param p_ptr Pointer to a zero-terminated buffer containing the feature name.
    466 	 * @return Non-zero if the feature is supported, otherwise 0.
    467 	 */
    468 	VST_EFFECT_OPCODE_33       = 0x33,
    469 	VST_EFFECT_OPCODE_SUPPORTS = 0x33,
    470 
    471 	/* Number of samples that are at the tail at the end of playback.
    472 	 * 
    473 	 * @return 0 or 1 for no tail, > 1 for number of samples to tail.
    474 	 */
    475 	VST_EFFECT_OPCODE_34             = 0x34,
    476 	VST_EFFECT_OPCODE_GETTAILSAMPLES = 0x34,
    477 	VST_EFFECT_OPCODE_TAIL_SAMPLES   = 0x34,
    478 
    479 	/*
    480 	 *
    481 	 *
    482 	 */
    483 	VST_EFFECT_OPCODE_35 = 0x35,
    484 
    485 	/*
    486 	 *
    487 	 *
    488 	 */
    489 	VST_EFFECT_OPCODE_36 = 0x36,
    490 
    491 	/*
    492 	 *
    493 	 *
    494 	 */
    495 	VST_EFFECT_OPCODE_37 = 0x37,
    496 
    497 	/*
    498 	 *
    499 	 *
    500 	 */
    501 	VST_EFFECT_OPCODE_38 = 0x38,
    502 
    503 	/* Parameter Properties
    504 	 *
    505 	 * @param p_ptr vst_parameter_properties*
    506 	 * @return 1 if supported, otherwise 0.
    507 	 */
    508 	VST_EFFECT_OPCODE_39                       = 0x39,
    509 	VST_EFFECT_OPCODE_GET_PARAMETER_PROPERTIES = VST_EFFECT_OPCODE_39,
    510 
    511 	/* Retrieve the VST Version supported.
    512 	 *
    513 	 * @return Return 0 for <2.0, 2 for 2.0, 2100 for 2.1, 2200 for 2.2, 2300 for 2.3, etc.
    514 	 */
    515 	VST_EFFECT_OPCODE_3A          = 0x3A,
    516 	VST_EFFECT_OPCODE_VST_VERSION = 0x3A,
    517 
    518 	// VST 2.1 or later
    519 
    520 	/*
    521 	 *
    522 	 *
    523 	 */
    524 	VST_EFFECT_OPCODE_3B = 0x3B,
    525 
    526 	/*
    527 	 *
    528 	 *
    529 	 */
    530 	VST_EFFECT_OPCODE_3C = 0x3C,
    531 
    532 	/*
    533 	 *
    534 	 *
    535 	 */
    536 	VST_EFFECT_OPCODE_3D = 0x3D,
    537 
    538 	/*
    539 	 *
    540 	 *
    541 	 */
    542 	VST_EFFECT_OPCODE_3E = 0x3E,
    543 
    544 	/*
    545 	 *
    546 	 *
    547 	 */
    548 	VST_EFFECT_OPCODE_3F = 0x3F,
    549 
    550 	/*
    551 	 *
    552 	 *
    553 	 */
    554 	VST_EFFECT_OPCODE_40 = 0x40,
    555 
    556 	/*
    557 	 *
    558 	 *
    559 	 */
    560 	VST_EFFECT_OPCODE_41 = 0x41,
    561 
    562 	/*
    563 	 *
    564 	 *
    565 	 */
    566 	VST_EFFECT_OPCODE_42 = 0x42,
    567 
    568 	/*
    569 	 *
    570 	 *
    571 	 */
    572 	VST_EFFECT_OPCODE_43 = 0x43,
    573 
    574 	/*
    575 	 *
    576 	 *
    577 	 */
    578 	VST_EFFECT_OPCODE_44 = 0x44,
    579 
    580 	// VST 2.3 or later
    581 
    582 	/* Retrieve the speaker arrangement.
    583 	 *
    584 	 * @param p_int2 (vst_speaker_arrangement**) Pointer to a pointer to the speaker arrangement for the input.
    585 	 * @param p_ptr (vst_speaker_arrangement**) Pointer to a pointer to the speaker arrangement for the output.
    586 	 */
    587 	VST_EFFECT_OPCODE_45                      = 0x45,
    588 	VST_EFFECT_OPCODE_GET_SPEAKER_ARRANGEMENT = 0x45,
    589 
    590 	/*
    591 	 *
    592 	 *
    593 	 */
    594 	VST_EFFECT_OPCODE_46 = 0x46,
    595 
    596 	/* Begin processing of audio.
    597 	 *
    598 	 * 
    599 	 * 
    600 	 */
    601 	VST_EFFECT_OPCODE_PROCESS_BEGIN = 0x47,
    602 
    603 	/* End processing of audio.
    604 	 *
    605 	 * 
    606 	 *
    607 	 */
    608 	VST_EFFECT_OPCODE_PROCESS_END = 0x48,
    609 
    610 	/*
    611 	 *
    612 	 *
    613 	 */
    614 	VST_EFFECT_OPCODE_49 = 0x49,
    615 
    616 	/*
    617 	 *
    618 	 *
    619 	 */
    620 	VST_EFFECT_OPCODE_4A = 0x4A,
    621 
    622 	/*
    623 	 *
    624 	 *
    625 	 */
    626 	VST_EFFECT_OPCODE_4B = 0x4B,
    627 
    628 	/*
    629 	 *
    630 	 *
    631 	 */
    632 	VST_EFFECT_OPCODE_4C = 0x4C,
    633 
    634 	// VST 2.4 or later
    635 
    636 	/*
    637 	 *
    638 	 *
    639 	 */
    640 	VST_EFFECT_OPCODE_4D = 0x4D,
    641 
    642 	/*
    643 	 *
    644 	 *
    645 	 */
    646 	VST_EFFECT_OPCODE_4E = 0x4E,
    647 
    648 	/*
    649 	 *
    650 	 *
    651 	 */
    652 	VST_EFFECT_OPCODE_4F = 0x4F,
    653 
    654 	// Highest number of known OPCODE.
    655 	VST_EFFECT_OPCODE_MAX,
    656 
    657 	// Pad to force 32-bit number.
    658 	_VST_EFFECT_OPCODE_PAD = 0xFFFFFFFFul,
    659 };
    660 
    661 enum VST_HOST_OPCODE {
    662 	/*
    663 	 * @param int1 -1 or Parameter Index
    664 	 * @return Expected to return... something.
    665 	 */
    666 	VST_HOST_OPCODE_00 = 0x00, // cb(vst, 0x00, ?, 0, 0);
    667 	VST_HOST_OPCODE_01 = 0x01,
    668 	VST_HOST_OPCODE_02 = 0x02, // bool cb(0, 0x02, 0, 0, 0);
    669 	VST_HOST_OPCODE_03 = 0x03,
    670 	VST_HOST_OPCODE_04 = 0x04,
    671 	VST_HOST_OPCODE_05 = 0x05,
    672 	VST_HOST_OPCODE_06 = 0x06,
    673 	VST_HOST_OPCODE_07 = 0x07,
    674 	VST_HOST_OPCODE_08 = 0x08,
    675 	VST_HOST_OPCODE_09 = 0x09,
    676 	VST_HOST_OPCODE_0A = 0x0A,
    677 	VST_HOST_OPCODE_0B = 0x0B,
    678 	VST_HOST_OPCODE_0C = 0x0C,
    679 	VST_HOST_OPCODE_0D = 0x0D,
    680 	VST_HOST_OPCODE_0E = 0x0E,
    681 	VST_HOST_OPCODE_0F = 0x0F,
    682 	VST_HOST_OPCODE_10 = 0x10,
    683 	VST_HOST_OPCODE_11 = 0x11,
    684 	VST_HOST_OPCODE_12 = 0x12,
    685 	VST_HOST_OPCODE_13 = 0x13,
    686 	VST_HOST_OPCODE_14 = 0x14,
    687 	VST_HOST_OPCODE_15 = 0x15,
    688 	VST_HOST_OPCODE_16 = 0x16,
    689 	VST_HOST_OPCODE_17 = 0x17,
    690 	VST_HOST_OPCODE_18 = 0x18,
    691 	VST_HOST_OPCODE_19 = 0x19,
    692 	VST_HOST_OPCODE_1A = 0x1A,
    693 	VST_HOST_OPCODE_1B = 0x1B,
    694 	VST_HOST_OPCODE_1C = 0x1C,
    695 	VST_HOST_OPCODE_1D = 0x1D,
    696 	VST_HOST_OPCODE_1E = 0x1E,
    697 	VST_HOST_OPCODE_1F = 0x1F,
    698 	VST_HOST_OPCODE_20 = 0x20,
    699 	VST_HOST_OPCODE_21 = 0x21,
    700 	VST_HOST_OPCODE_22 = 0x22,
    701 	VST_HOST_OPCODE_23 = 0x23,
    702 	VST_HOST_OPCODE_24 = 0x24,
    703 	VST_HOST_OPCODE_25 = 0x25,
    704 	VST_HOST_OPCODE_26 = 0x26,
    705 	VST_HOST_OPCODE_27 = 0x27,
    706 	VST_HOST_OPCODE_28 = 0x28,
    707 	VST_HOST_OPCODE_29 = 0x29,
    708 	VST_HOST_OPCODE_2A = 0x2A,
    709 
    710 	/* Parameter gained focus.
    711 	 *
    712 	 * @param int1 Parameter index.
    713 	 */
    714 	VST_HOST_OPCODE_2B = 0x2B,
    715 
    716 	/* Parameter lost focus.
    717 	 * 
    718 	 * @param int1 Parameter index.
    719 	 */
    720 	VST_HOST_OPCODE_2C = 0x2C,
    721 
    722 	VST_HOST_OPCODE_2D = 0x2D,
    723 	VST_HOST_OPCODE_2E = 0x2E,
    724 	VST_HOST_OPCODE_2F = 0x2F,
    725 
    726 	// Highest number of known OPCODE.
    727 	VST_HOST_OPCODE_MAX,
    728 
    729 	// Pad to force 32-bit number.
    730 	_VST_HOST_OPCODE_PAD = 0xFFFFFFFFul,
    731 };
    732 
    733 enum VST_ARRANGEMENT_TYPE {
    734 	/* Custom speaker arrangement.
    735 	 *
    736 	 * Accidentally discovered through random testing.
    737 	 */
    738 	VST_ARRANGEMENT_TYPE_CUSTOM = -2,
    739 
    740 	/* Unknown/Empty speaker layout.
    741 	 *
    742 	 */
    743 	VST_ARRANGEMENT_TYPE_UNKNOWN = -1,
    744 
    745 	/* Mono
    746 	 */
    747 	VST_ARRANGEMENT_TYPE_MONO = 0,
    748 
    749 	/* Stereo
    750 	 */
    751 	VST_ARRANGEMENT_TYPE_STEREO = 1,
    752 
    753 	/* 5.1
    754 	 */
    755 	VST_ARRANGEMENT_TYPE_5_1 = 0x0F,
    756 
    757 	// Pad to force 32-bit number.
    758 	_VST_ARRANGEMENT_TYPE_PAD = 0xFFFFFFFFul,
    759 };
    760 
    761 enum VST_SPEAKER_TYPE {
    762 	VST_SPEAKER_TYPE_MONO       = 0,
    763 	VST_SPEAKER_TYPE_LEFT       = 1,
    764 	VST_SPEAKER_TYPE_RIGHT      = 2,
    765 	VST_SPEAKER_TYPE_CENTER     = 3,
    766 	VST_SPEAKER_TYPE_LFE        = 4,
    767 	VST_SPEAKER_TYPE_LEFT_SIDE  = 5,
    768 	VST_SPEAKER_TYPE_RIGHT_SIDE = 6,
    769 
    770 	// Pad to force 32-bit number.
    771 	_VST_SPEAKER_TYPE_PAD = 0xFFFFFFFFul,
    772 };
    773 
    774 enum VST_PARAMETER_FLAGS {
    775 	/**
    776 	 * Parameter is an on/off switch.
    777 	 */
    778 	VST_PARAMETER_FLAGS_SWITCH = 1,
    779 	/**
    780 	 * Limits defined by integers.
    781 	 */
    782 	VST_PARAMETER_FLAGS_INTEGER_LIMITS = 1 << 1,
    783 	/**
    784 	 * Uses float steps.
    785 	 */
    786 	VST_PARAMETER_FLAGS_STEP_FLOAT = 1 << 2,
    787 	/**
    788 	 * Uses integer steps.
    789 	 */
    790 	VST_PARAMETER_FLAGS_STEP_INT = 1 << 3,
    791 	/**
    792 	 * Respect index variable for display ordering.
    793 	 */
    794 	VST_PARAMETER_FLAGS_INDEX = 1 << 4,
    795 	/**
    796 	 * Respect category value and names.
    797 	 */
    798 	VST_PARAMETER_FLAGS_CATEGORY = 1 << 5,
    799 	VST_PARAMETER_FLAGS_UNKNOWN6 = 1 << 6,
    800 	_VST_PARAMETER_FLAGS_PAD     = 0xFFFFFFFFul,
    801 };
    802 
    803 /*******************************************************************************
    804 |* Structures
    805 |*/
    806 
    807 struct vst_rect {
    808 	int16_t left;
    809 	int16_t top;
    810 	int16_t right;
    811 	int16_t bottom;
    812 };
    813 
    814 struct vst_effect {
    815 	int32_t magic_number; // Should always be VST_MAGICNUMBER
    816 
    817 	// 64-bit adds 4-byte padding here to align pointers.
    818 
    819 	/* Control the VST through an opcode and up to four parameters.
    820 	 * 
    821 	 * @param this Pointer to the effect itself.
    822 	 * @param opcode The opcode to run, see VST_EFFECT_OPCODES.
    823 	 * @param p_int1 Parameter, see VST_EFFECT_OPCODES.
    824 	 * @param p_int2 Parameter, see VST_EFFECT_OPCODES.
    825 	 * @param p_ptr Parameter, see VST_EFFECT_OPCODES.
    826 	 * @param p_float Parameter, see VST_EFFECT_OPCODES.
    827 	 */
    828 	intptr_t(VST_FUNCTION_INTERFACE* control)(vst_effect* pthis, VST_EFFECT_OPCODE opcode, int32_t p_int1, intptr_t p_int2, void* p_ptr, float p_float);
    829 
    830 	/* Process the given number of samples in inputs and outputs.
    831 	 *
    832 	 * Different to process_float how? Never seen any difference.
    833 	 * 
    834 	 * @param pthis Pointer to the effect itself.
    835 	 * @param inputs Pointer to an array of 'const float[samples]' with size numInputs.
    836 	 * @param outputs Pointer to an array of 'float[samples]' with size numOutputs.
    837 	 * @param samples Number of samples per channel in inputs.
    838 	 */
    839 	void(VST_FUNCTION_INTERFACE* process)(vst_effect* pthis, const float* const* inputs, float** outputs, int32_t samples);
    840 
    841 	/* Updates the value for the parameter at the given index, or does nothing if out of bounds.
    842 	 * 
    843 	 * @param pthis Pointer to the effect itself.
    844 	 * @param index Parameter index.
    845 	 * @param value New value for the parameter.
    846 	 */
    847 	void(VST_FUNCTION_INTERFACE* set_parameter)(vst_effect* pthis, uint32_t index, float value);
    848 
    849 	/* Returns the value stored for the parameter at index, or 0 if out of bounds.
    850 	 * 
    851 	 * @param pthis Pointer to the effect itself.
    852 	 * @param index Parameter index.
    853 	 * @return float Value of the parameter.
    854 	 */
    855 	float(VST_FUNCTION_INTERFACE* get_parameter)(vst_effect* pthis, uint32_t index);
    856 
    857 	int32_t num_programs; // Number of possible programs.
    858 	int32_t num_params; // Number of possible parameters.
    859 	int32_t num_inputs; // Number of inputs.
    860 	int32_t num_outputs; // Number of outputs.
    861 
    862 	/* Bitflags
    863 	 * 
    864 	 * Bit		Description
    865 	 * 1		Effect has "Editor"
    866 	 * 2		Unknown (Found in: ReaDelay)
    867 	 * 3		Unknown (Found in: ReaDelay)
    868 	 * 4		Unknown (Found in: ReaDelay)
    869 	 * 5		Has process_float (Found in: ReaDelay, ReaComp, ReaControlMIDI, ReaStream, ReaFir)
    870 	 * 6		Unknown (Found in: ReaControlMIDI, ReaStream, ReaFir)
    871 	 * 10		Unknown (Found in: ReaFir)
    872 	 * 13		Has process_double (Found in: ReaControlMIDI)
    873 	 */
    874 	int32_t flags;
    875 
    876 	// 64-bit adds 4-byte padding here to align pointers.
    877 
    878 	void* _unknown_ptr_00[2];
    879 
    880 	/* Initial delay before processing of samples can actually begin in Samples.
    881 	 *
    882 	 * Should be updated before or during handling the 0x47 control call. 
    883 	 */
    884 	int32_t delay;
    885 
    886 	int32_t _unknown_int32_00[2]; // Unknown int32_t values.
    887 	float   _unknown_float_00; // Seems to always be 1.0
    888 
    889 	void* effect_internal; // Pointer to Plugin internal data
    890 	void* host_internal; // Pointer to Host internal data.
    891 
    892 	/* Id of the plugin.
    893 	 *
    894 	 * Due to this not being enough for uniqueness, it should not be used alone 
    895 	 * for indexing. Ideally you want to index like this:
    896 	 *     [unique_id][module_name][version][flags]
    897 	 * If any of the checks after unique_id fail, you default to the first 
    898 	 * possible choice.
    899 	 */
    900 	int32_t unique_id;
    901 
    902 	/* Plugin version
    903 	 * 
    904 	 * Unrelated to the minimum VST Version, but often the same.
    905 	 */
    906 	int32_t version;
    907 
    908 	// There is no padding here if everything went right.
    909 
    910 	/* Process the given number of single samples in inputs and outputs.
    911 	 *
    912 	 * @param pthis Pointer to the effect itself.
    913 	 * @param inputs Pointer to an array of 'const float[samples]' with size numInputs.
    914 	 * @param outputs Pointer to an array of 'float[samples]' with size numOutputs.
    915 	 * @param samples Number of samples per channel in inputs.
    916 	 */
    917 	void(VST_FUNCTION_INTERFACE* process_float)(vst_effect* pthis, const float* const* inputs, float** outputs, int32_t samples);
    918 
    919 	/* Process the given number of double samples in inputs and outputs.
    920 	 *
    921 	 * Used only by 2.4 hosts and plugins, possibly restricted to said version.
    922 	 * 
    923 	 * @param pthis Pointer to the effect itself.
    924 	 * @param inputs Pointer to an array of 'const double[samples]' with size numInputs.
    925 	 * @param outputs Pointer to an array of 'double[samples]' with size numOutputs.
    926 	 * @param samples Number of samples per channel in inputs.
    927 	 */
    928 	void(VST_FUNCTION_INTERFACE* process_double)(vst_effect* pthis, const double* const* inputs, double** outputs, int32_t samples);
    929 
    930 	// Everything after this is unknown and was present in reacomp-standalone.dll.
    931 	uint8_t _unknown[56]; // 56-bytes of something. Could also just be 52-bytes.
    932 };
    933 
    934 struct vst_parameter_properties {
    935 	float step_f32;
    936 	float step_small_f32;
    937 	float step_large_f32;
    938 
    939 	char name[VST_BUFFER_64];
    940 
    941 	uint32_t flags;
    942 	int32_t  min_value_i32;
    943 	int32_t  max_value_i32;
    944 	int32_t  step_i32;
    945 
    946 	char label[VST_BUFFER_8];
    947 
    948 	uint16_t index;
    949 
    950 	uint16_t category;
    951 	uint16_t num_parameters_in_category;
    952 	uint16_t _unknown_00;
    953 
    954 	char category_label[VST_BUFFER_24];
    955 
    956 	char _unknown_01[VST_BUFFER_16];
    957 };
    958 
    959 struct vst_speaker_properties {
    960 	float            _unknown_00; // 10.0 if LFE, otherwise random? Never exceeds -PI to PI range.
    961 	float            _unknown_04; // 10.0 if LFE, otherwise random? Never exceeds -PI to PI range.
    962 	float            _unknown_08; // 0.0 if LFE, otherwise 1.0.
    963 	float            _unknown_0C;
    964 	char             name[VST_BUFFER_64];
    965 	VST_SPEAKER_TYPE type;
    966 
    967 	uint8_t _unknown[28]; // Padding detected from testing.
    968 };
    969 
    970 struct vst_speaker_arrangement {
    971 	VST_ARRANGEMENT_TYPE   type; // See VST_SPEAKER_ARRANGEMENT_TYPE
    972 	int32_t                channels; // Number of channels in speakers.
    973 	vst_speaker_properties speakers[VST_MAX_CHANNELS]; // Array of speaker properties, actual size defined by channels.
    974 };
    975 
    976 /* Callback used by the plugin to interface with the host.
    977  * 
    978  * @param opcode See VST_HOST_OPCODE
    979  * @param p_str Zero terminated string or null on call.
    980  * @return ?
    981  */
    982 typedef intptr_t (*vst_host_callback)(vst_effect* plugin, VST_HOST_OPCODE opcode, int32_t p_int1, int64_t p_int2, const char* p_str, float p_float);
    983 
    984 static const char* vst_host_string[] = {
    985 	"GetResourcePath", // ReaControlMIDI
    986 	"get_ini_file", // ReaControlMIDI
    987 	"resolve_fn", // ReaControlMIDI
    988 };
    989 
    990 /* Entry point for VST2.x plugins.
    991  *
    992  * @return A new instance of the VST2.x effect.
    993  */
    994 #define VST_ENTRYPOINT vst_effect* VSTPluginMain(vst_host_callback callback)
    995 #define VST_ENTRYPOINT_WINDOWS                   \
    996 	vst_effect* MAIN(vst_host_callback callback) \
    997 	{                                            \
    998 		return VSTPluginMain(callback);          \
    999 	}
   1000 #define VST_ENTRYPOINT_MACOS                           \
   1001 	vst_effect* main_macho(vst_host_callback callback) \
   1002 	{                                                  \
   1003 		return VSTPluginMain(callback);                \
   1004 	}
   1005 
   1006 #ifdef __cplusplus
   1007 }
   1008 #endif
   1009 
   1010 // Variable size variant of vst_speaker_arrangement.
   1011 #ifdef __cplusplus
   1012 template<size_t T>
   1013 struct vst_speaker_arrangement_t {
   1014 	VST_ARRANGEMENT_TYPE   type; // See VST_SPEAKER_ARRANGEMENT_TYPE
   1015 	int32_t                channels; // Number of channels in speakers.
   1016 	vst_speaker_properties speakers[T]; // Array of speaker properties, actual size defined by channels.
   1017 };
   1018 #endif
   1019 
   1020 #pragma pack(pop)
   1021 
   1022 #endif