aeffectx.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. /*
  2. * aeffectx.h - simple header to allow VeSTige compilation and eventually work
  3. *
  4. * Copyright (c) 2006 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef AEFFECTX_H
  25. #define AEFFECTX_H
  26. #include <stdint.h>
  27. #include <type_traits>
  28. // Calling convention
  29. #define VST_CALL_CONV __cdecl
  30. template<typename T>
  31. constexpr int32_t CCONST(T a, T b, T c, T d)
  32. {
  33. static_assert(std::is_convertible<T,int32_t>::value, "int32 compatibility required.");
  34. return (
  35. static_cast<int32_t>(a) << 24 |
  36. static_cast<int32_t>(b) << 16 |
  37. static_cast<int32_t>(c) << 8 |
  38. static_cast<int32_t>(d) << 0);
  39. }
  40. constexpr int audioMasterAutomate = 0;
  41. constexpr int audioMasterVersion = 1;
  42. constexpr int audioMasterCurrentId = 2;
  43. constexpr int audioMasterIdle = 3;
  44. constexpr int audioMasterPinConnected = 4;
  45. // unsupported? 5
  46. constexpr int audioMasterWantMidi = 6;
  47. constexpr int audioMasterGetTime = 7;
  48. constexpr int audioMasterProcessEvents = 8;
  49. constexpr int audioMasterSetTime = 9;
  50. constexpr int audioMasterTempoAt = 10;
  51. constexpr int audioMasterGetNumAutomatableParameters = 11;
  52. constexpr int audioMasterGetParameterQuantization = 12;
  53. constexpr int audioMasterIOChanged = 13;
  54. constexpr int audioMasterNeedIdle = 14;
  55. constexpr int audioMasterSizeWindow = 15;
  56. constexpr int audioMasterGetSampleRate = 16;
  57. constexpr int audioMasterGetBlockSize = 17;
  58. constexpr int audioMasterGetInputLatency = 18;
  59. constexpr int audioMasterGetOutputLatency = 19;
  60. constexpr int audioMasterGetPreviousPlug = 20;
  61. constexpr int audioMasterGetNextPlug = 21;
  62. constexpr int audioMasterWillReplaceOrAccumulate = 22;
  63. constexpr int audioMasterGetCurrentProcessLevel = 23;
  64. constexpr int audioMasterGetAutomationState = 24;
  65. constexpr int audioMasterOfflineStart = 25;
  66. constexpr int audioMasterOfflineRead = 26;
  67. constexpr int audioMasterOfflineWrite = 27;
  68. constexpr int audioMasterOfflineGetCurrentPass = 28;
  69. constexpr int audioMasterOfflineGetCurrentMetaPass = 29;
  70. constexpr int audioMasterSetOutputSampleRate = 30;
  71. // unsupported? 31
  72. constexpr int audioMasterGetSpeakerArrangement = 31; // deprecated in 2.4?
  73. constexpr int audioMasterGetVendorString = 32;
  74. constexpr int audioMasterGetProductString = 33;
  75. constexpr int audioMasterGetVendorVersion = 34;
  76. constexpr int audioMasterVendorSpecific = 35;
  77. constexpr int audioMasterSetIcon = 36;
  78. constexpr int audioMasterCanDo = 37;
  79. constexpr int audioMasterGetLanguage = 38;
  80. constexpr int audioMasterOpenWindow = 39;
  81. constexpr int audioMasterCloseWindow = 40;
  82. constexpr int audioMasterGetDirectory = 41;
  83. constexpr int audioMasterUpdateDisplay = 42;
  84. constexpr int audioMasterBeginEdit = 43;
  85. constexpr int audioMasterEndEdit = 44;
  86. constexpr int audioMasterOpenFileSelector = 45;
  87. constexpr int audioMasterCloseFileSelector = 46; // currently unused
  88. constexpr int audioMasterEditFile = 47; // currently unused
  89. constexpr int audioMasterGetChunkFile = 48; // currently unused
  90. constexpr int audioMasterGetInputSpeakerArrangement = 49; // currently unused
  91. constexpr int effFlagsHasEditor = 1;
  92. constexpr int effFlagsCanReplacing = 1 << 4; // very likely
  93. constexpr int effFlagsIsSynth = 1 << 8; // currently unused
  94. constexpr int effOpen = 0;
  95. constexpr int effClose = 1; // currently unused
  96. constexpr int effSetProgram = 2; // currently unused
  97. constexpr int effGetProgram = 3; // currently unused
  98. constexpr int effGetProgramName = 5; // currently unused
  99. constexpr int effGetParamLabel = 6;
  100. constexpr int effGetParamDisplay = 7;
  101. constexpr int effGetParamName = 8; // currently unused
  102. constexpr int effSetSampleRate = 10;
  103. constexpr int effSetBlockSize = 11;
  104. constexpr int effMainsChanged = 12;
  105. constexpr int effEditGetRect = 13;
  106. constexpr int effEditOpen = 14;
  107. constexpr int effEditClose = 15;
  108. constexpr int effEditIdle = 19;
  109. constexpr int effEditTop = 20;
  110. constexpr int effSetChunk = 24;
  111. constexpr int effProcessEvents = 25;
  112. constexpr int effGetEffectName = 45;
  113. constexpr int effGetVendorString = 47;
  114. constexpr int effGetProductString = 48;
  115. constexpr int effGetVendorVersion = 49;
  116. constexpr int effCanDo = 51; // currently unused
  117. constexpr int effGetVstVersion = 58; // currently unused
  118. constexpr int kEffectMagic = CCONST( 'V', 's', 't', 'P' );
  119. constexpr int kVstLangEnglish = 1;
  120. constexpr int kVstMidiType = 1;
  121. constexpr int kVstTransportChanged = 1;
  122. constexpr int kVstTransportPlaying = 1 << 1;
  123. constexpr int kVstTransportCycleActive = 1 << 2;
  124. constexpr int kVstTransportRecording = 1 << 3; // currently unused
  125. constexpr int kVstPpqPosValid = 1 << 9;
  126. constexpr int kVstTempoValid = 1 << 10;
  127. constexpr int kVstBarsValid = 1 << 11;
  128. constexpr int kVstCyclePosValid = 1 << 12;
  129. constexpr int kVstTimeSigValid = 1 << 13;
  130. constexpr int kVstSmpteValid = 1 << 14; // currently unused
  131. constexpr int kVstClockValid = 1 << 15; // currently unused
  132. // currently unused
  133. constexpr int kVstSmpte24fps = 0;
  134. constexpr int kVstSmpte25fps = 1;
  135. constexpr int kVstSmpte2997fps = 2;
  136. constexpr int kVstSmpte30fps = 3;
  137. constexpr int kVstSmpte2997dfps = 4;
  138. constexpr int kVstSmpte30dfps = 5;
  139. constexpr int kVstSmpteFilm16mm = 6; // very likely
  140. constexpr int kVstSmpteFilm35mm = 7; // very likely
  141. constexpr int kVstSmpte239fps = 10;
  142. constexpr int kVstSmpte249fps = 11;
  143. constexpr int kVstSmpte599fps = 12;
  144. constexpr int kVstSmpte60fps = 13;
  145. class VstMidiEvent
  146. {
  147. public:
  148. // 00
  149. int32_t type;
  150. // 04
  151. int32_t byteSize;
  152. // 08
  153. int32_t deltaFrames;
  154. // 0c?
  155. int32_t flags;
  156. // 10?
  157. int32_t noteLength;
  158. // 14?
  159. int32_t noteOffset;
  160. // 18
  161. char midiData[4];
  162. // 1c?
  163. char detune;
  164. // 1d?
  165. char noteOffVelocity;
  166. // 1e?
  167. char reserved1;
  168. // 1f?
  169. char reserved2;
  170. } ;
  171. class VstEvent
  172. {
  173. char dump[sizeof( VstMidiEvent )];
  174. } ;
  175. class VstEvents
  176. {
  177. public:
  178. // 00
  179. int32_t numEvents;
  180. // 04
  181. void *reserved;
  182. // 08
  183. VstEvent* events[1];
  184. } ;
  185. class AEffect
  186. {
  187. public:
  188. // Never use virtual functions!!!
  189. // 00-03
  190. int32_t magic;
  191. // dispatcher 04-07
  192. intptr_t (VST_CALL_CONV * dispatcher)( AEffect * , int32_t , int32_t , intptr_t, void * , float );
  193. // process, quite sure 08-0b
  194. void (VST_CALL_CONV * process)( AEffect * , float * * , float * * , int32_t );
  195. // setParameter 0c-0f
  196. void (VST_CALL_CONV * setParameter)( AEffect * , int32_t , float );
  197. // getParameter 10-13
  198. float (VST_CALL_CONV * getParameter)( AEffect * , int32_t );
  199. // programs 14-17
  200. int32_t numPrograms;
  201. // Params 18-1b
  202. int32_t numParams;
  203. // Input 1c-1f
  204. int32_t numInputs;
  205. // Output 20-23
  206. int32_t numOutputs;
  207. // flags 24-27
  208. int32_t flags;
  209. // Fill somewhere 28-2b
  210. void *ptr1;
  211. void *ptr2;
  212. // Zeroes 2c-2f 30-33 34-37 38-3b
  213. char empty3[4 + 4 + 4];
  214. // 1.0f 3c-3f
  215. float unknown_float;
  216. // An object? pointer 40-43
  217. void *ptr3;
  218. // Zeroes 44-47
  219. void *user;
  220. // Id 48-4b
  221. int32_t uniqueID;
  222. // Don't know 4c-4f
  223. char unknown1[4];
  224. // processReplacing 50-53
  225. void (VST_CALL_CONV * processReplacing)( AEffect * , float * * , float * * , int );
  226. } ;
  227. class VstTimeInfo
  228. {
  229. public:
  230. // 00
  231. double samplePos;
  232. // 08
  233. double sampleRate;
  234. // unconfirmed 10
  235. double nanoSeconds;
  236. // 18
  237. double ppqPos;
  238. // 20
  239. double tempo;
  240. // 28
  241. double barStartPos;
  242. // 30
  243. double cycleStartPos;
  244. // 38
  245. double cycleEndPos;
  246. // 40
  247. int32_t timeSigNumerator;
  248. // 44
  249. int32_t timeSigDenominator;
  250. // 48 unused
  251. int32_t smpteOffset;
  252. // 4c unused
  253. int32_t smpteFrameRate;
  254. // 50? unused, where does this come from?
  255. int32_t samplesToNextClock;
  256. // 54
  257. int32_t flags;
  258. } ;
  259. typedef intptr_t (VST_CALL_CONV * audioMasterCallback)( AEffect * , int32_t, int32_t, intptr_t, void * , float );
  260. #endif