audioeffect.hpp (4146B)
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 "aeffect.h" 18 #include "aeffeditor.h" 19 #include "vstevent.h" 20 #include "vstkey.h" 21 #include "vstparameter.h" 22 #include "vstpin.h" 23 #include "vstspeaker.h" 24 #include "vsttypes.h" 25 26 // This may work. Or it may not. We don't guarantee compatibility with the original. 27 class AudioEffect { 28 public: 29 AudioEffect(audioMasterCallback audioMaster, VstInt32 __unk00, VstInt32 __unk01); 30 virtual ~AudioEffect(); 31 32 protected: 33 // Internal 34 virtual VstIntPtr control(VstInt32 opcode, VstInt32 param1, VstIntPtr param2, void* ptr, float value); 35 36 public: 37 // AudioEffect 38 virtual AEffect* getAeffect(); 39 virtual void setEditor(AEffEditor* editor); 40 41 virtual void process(float** inputs, float** outputs, VstInt32 sampleFrames){}; 42 43 virtual float getParameter(VstInt32 index) 44 { 45 return 0; 46 } 47 virtual void setParameter(VstInt32 index, float value){}; 48 49 virtual void processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames){}; 50 51 // AEffect 52 virtual void setUniqueID(VstInt32 uniqueID); 53 virtual void setNumInputs(VstInt32 numInputs); 54 virtual void setNumOutputs(VstInt32 numOutputs); 55 virtual void setInitialDelay(VstInt32 delay); 56 virtual void canProcessReplacing(bool value); 57 virtual void isSynth(bool value); 58 virtual void programsAreChunks(bool value); 59 60 // Audio Master (sorted by AEffectMasterOpCodes) 61 virtual void setParameterAutomated(VstInt32 index, float value); 62 63 // Audio Plugin (sorted by AEffectOpCodes) 64 virtual void open(){}; 65 virtual void close(){}; 66 virtual void setProgram(VstInt32 program){}; 67 virtual VstInt32 getProgram() 68 { 69 return 0; 70 } 71 virtual void setProgramName(char* name){}; 72 virtual void getProgramName(char* name) 73 { 74 *name = 0; 75 } 76 virtual void getParameterLabel(VstInt32 index, char* label){}; 77 virtual void getParameterDisplay(VstInt32 index, char* text){}; 78 virtual void getParameterName(VstInt32 index, char* text){}; 79 virtual void setSampleRate(float newSamplerate){}; 80 virtual void setBlockSize(VstInt32 newBlockSize){}; 81 virtual void suspend(){}; 82 virtual void resume(){}; 83 virtual VstInt32 getChunk(void** data, bool isPreset = false) 84 { 85 return 0; 86 } 87 virtual VstInt32 setChunk(void* data, VstInt32 byteSize, bool isPreset = false) 88 { 89 return 0; 90 } 91 92 // Defined by Implementation 93 94 protected: // Needs to be accessible by AudioEffectX 95 AEffect cEffect; // vst2wrapper requires this. 96 audioMasterCallback audioMaster; // vst2wrapper requires this. 97 VstInt32 numPrograms; 98 VstInt32 curProgram; 99 AEffEditor* editor; 100 };