aeffect.h (5831B)
1 /* 2 * Copyright 2024 Michael Fabian 'Xaymar' Dirks <info@xaymar.com> 3 * Copyright 2024 Steinberg Media Technologies GmbH 4 * 5 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 8 * 9 * 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. 10 * 11 * 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 12 * 13 * 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. 14 */ 15 16 #pragma once 17 #include "vsttypes.h" 18 #include "vstversion.h" 19 20 #pragma pack(push, 8) 21 22 enum AEffectOpCodes { 23 audioEffectOpen, // Create/Open Effect 24 audioEffectClose, // Destroy/Close Effect 25 audioEffectSetProgram, // Set Program 26 audioEffectGetProgram, // Get Program 27 audioEffectSetProgramName, // Set Program Name 28 audioEffectGetProgramName, // Get Program Name 29 audioEffectGetParameterLabel, // Get Parameter Label 30 audioEffectGetParameterDisplay, // Get Parameter Display 31 audioEffectGetParameterName, // Get Parameter Name 32 AEffectOpCode_09, 33 audioEffectSetSampleRate, // Set Sample Rate 34 audioEffectSetBlockSize, // Set Block Size 35 audioEffectSuspendResume, // Suspend/Resume 36 audioEffectEditorGetSize, // Get Editor Size 37 audioEffectEditorOpen, // Create/Open Editor 38 audioEffectEditorClose, // Destroy/Close Editor 39 AEffectOpCode_10, 40 AEffectOpCode_11, 41 AEffectOpCode_12, 42 audioEffectEditorDoNothing, 43 AEffectOpCode_14, 44 AEffectOpCode_15, 45 AEffectOpCode_16, // Always FOURCC('N', 'v', 'E', 'F')? Might be different for some VST 1.x and 2.x plug-ins. Doesn't seem to be used. 46 audioEffectGetChunk, // Get Chunk 47 audioEffectSetChunk, // Set Chunk 48 49 // All OpCodes above this maximum are version 2.x 50 AEffectOpCodeMax 51 }; 52 53 enum AEffectMasterOpCodes { 54 AEffectMasterOpCode_00, 55 audioMasterAutomate = AEffectMasterOpCode_00, 56 AEffectMasterOpCode_01, 57 audioMasterVersion = AEffectMasterOpCode_01, 58 AEffectMasterOpCode_02, 59 AEffectMasterOpCode_03, 60 AEffectMasterOpCode_04, 61 62 // All OpCodes above this maximum are version 2.x 63 AEffectMasterOpCodeMax, 64 }; 65 66 enum AEffectFlags { // Guessed name based on struct+field combination. 67 AEffectFlagHasEditor = 1 << 0, 68 AEffectFlagCanReplacing = 1 << 4, 69 AEffectFlagProgramsAreChunks = 1 << 5, // Not sure what this means. 70 AEffectFlagIsSynthesizer = 1 << 8, 71 AEffectFlagIsSilentOnSilence = 1 << 9, // Does not generate tail samples? 72 }; 73 74 struct AEffect { 75 VstInt32 magic; // Must be FOURCC('V', 's', 't', 'P') 76 77 VstIntPtr(VstFunctionAPI* control)(AEffect* self, VstInt32 opcode, VstInt32 param1, VstIntPtr param2, void* ptr, float value); 78 79 #if (!defined VST_VERSION_SUPPORT) || (VST_VERSION_SUPPORT >= kVstVersion_2400) 80 // No 2.4 host ever calls this, processReplacing and processDoubleReplacing seem to be required. 81 [[deprecated]] 82 #endif 83 void(VstFunctionAPI* process)(AEffect* self, float** inputs, float** outputs, VstInt32 sampleFrames); 84 85 void(VstFunctionAPI* setParameter)(AEffect* self, VstInt32 index, float value); 86 87 float(VstFunctionAPI* getParameter)(AEffect* self, VstInt32 index); 88 89 VstInt32 numPrograms; 90 VstInt32 numParams; 91 VstInt32 numInputs; // Guessing names here based on the other ones. We already know what their type is anyway. 92 VstInt32 numOutputs; 93 VstInt32 flags; // AEffectFlags, see vst.h for more. 94 95 VstIntPtr __unk04; 96 VstIntPtr __unk05; 97 98 VstInt32 delay; 99 100 VstInt32 __unk06; 101 VstInt32 __unk07; 102 float __unk08; 103 104 void* effect_data; // I think this is effect private data. 105 void* host_data; // And this is host private data. 106 107 VstInt32 uniqueID; // A very collidable unique id. 32 bit is not a lot. 108 VstInt32 version; // VstVersion 109 110 /** Process float data in-place. 111 * 112 * Must be present for 2.4 or later hosts. Make sure you set the proper flag. 113 * 114 * \param inputs Input buffers. Can have pointers used in outputs. 115 * \param outputs Output buffers. Can have pointers used in inputs. 116 * \param sampleFrames Number of samples in all buffers. 117 */ 118 void(VstFunctionAPI* processReplacing)(AEffect* self, float** inputs, float** outputs, VstInt32 sampleFrames); 119 120 #if (!defined VST_VERSION_SUPPORT) || (VST_VERSION_SUPPORT >= kVstVersion_2400) 121 // These only appear in version >= 2.4 122 123 /** Process double data in-place. 124 * 125 * \param inputs Input buffers. Can have pointers used in outputs. 126 * \param outputs Output buffers. Can have pointers used in inputs. 127 * \param sampleFrames Number of samples in all buffers. 128 */ 129 void(VstFunctionAPI* processDoubleReplacing)(AEffect* self, double** inputs, double** outputs, VstInt32 sampleFrames); 130 131 char __unk12[56]; 132 #else 133 char __unk12[60]; 134 #endif 135 }; 136 137 // Master callback. 138 typedef VstIntPtr(VstFunctionAPI* audioMasterCallback)(AEffect*, VstInt32 opcode, VstInt32, VstInt32, void* ptr, float); 139 140 #pragma pack(pop)