iPlug2 - C++ Audio Plug-in Framework
IPlugConstants.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5 
6  See LICENSE.txt for more info.
7 
8  ==============================================================================
9 */
10 
11 #pragma once
12 
21 #include <stdint.h>
22 #include "IPlugPlatform.h"
23 
24 BEGIN_IPLUG_NAMESPACE
25 
26 #if !defined(SAMPLE_TYPE_FLOAT) && !defined(SAMPLE_TYPE_DOUBLE)
27 #define SAMPLE_TYPE_DOUBLE
28 #endif
29 
30 #ifdef SAMPLE_TYPE_DOUBLE
31 using PLUG_SAMPLE_DST = double;
32 using PLUG_SAMPLE_SRC = float;
33 #else
34 using PLUG_SAMPLE_DST = float;
35 using PLUG_SAMPLE_SRC = double;
36 #endif
37 
38 using sample = PLUG_SAMPLE_DST;
39 
40 #define LOGFILE "IPlugLog.txt"
41 #define MAX_PROCESS_TRACE_COUNT 100
42 #define MAX_IDLE_TRACE_COUNT 15
43 
44 enum EIPlugPluginType
45 {
46  kEffect = 0,
47  kInstrument = 1,
48  kMIDIEffect = 2
49 };
50 
51 enum EVST3ParamIDs
52 {
53 #ifdef IPLUG1_COMPATIBILITY
54  kBypassParam = 'bpas',
55  kPresetParam = 'prst',
56  kMIDICCParamStartIdx
57 #else
58  kBypassParam = 65536,
59  kPresetParam, // not used unless baked in presets declared
60  kMIDICCParamStartIdx
61 #endif
62 };
63 
64 //TODO: these should be in a namespace, to avoid conflicts with third-party libraries
65 static const double PI = 3.1415926535897932384626433832795;
66 
71 static const double AMP_DB = 8.685889638065036553;
76 static const double IAMP_DB = 0.11512925464970;
77 static const double DEFAULT_SAMPLE_RATE = 44100.0;
78 static const int MAX_PRESET_NAME_LEN = 256;
79 #define UNUSED_PRESET_NAME "empty"
80 #define DEFAULT_USER_PRESET_NAME "user preset"
81 
82 #define AU_MAX_IO_CHANNELS 128
83 
84 //TODO: check this shit really?
85 #define MAX_MACOS_PATH_LEN 1024
86 #define MAX_WIN32_PATH_LEN 256
87 #define MAX_WIN32_PARAM_LEN 256
88 #define IPLUG_WIN_MAX_WIDE_PATH 4096
89 
90 #define MAX_PLUGIN_NAME_LEN 128
91 
92 #define MAX_PARAM_NAME_LEN 32 // e.g. "Gain"
93 #define MAX_PARAM_LABEL_LEN 32 // e.g. "Percent"
94 #define MAX_PARAM_DISPLAY_LEN 32 // e.g. "100" / "Mute"
95 #define MAX_PARAM_GROUP_LEN 32 // e.g. "oscillator section"
96 #define MAX_BUS_NAME_LEN 32 // e.g. "sidechain input"
97 #define MAX_CHAN_NAME_LEN 32 // e.g. "input 1"
98 
99 #define MAX_VERSION_STR_LEN 32
100 #define MAX_BUILD_INFO_STR_LEN 256
101 static const int MAX_PARAM_DISPLAY_PRECISION = 6;
102 
103 #define MAX_AAX_PARAMID_LEN 32
104 
105 #define PARAM_UNINIT 99.99e-9
106 
107 #ifndef MAX_BLOB_LENGTH
108 #define MAX_BLOB_LENGTH 2048
109 #endif
110 
111 #ifndef IDLE_TIMER_RATE
112 #define IDLE_TIMER_RATE 20 // this controls the frequency of data going from processor to editor (and OnIdle calls)
113 #endif
114 
115 #ifndef MAX_SYSEX_SIZE
116 #define MAX_SYSEX_SIZE 512
117 #endif
118 
119 #define PARAM_TRANSFER_SIZE 512
120 #define MIDI_TRANSFER_SIZE 32
121 #define SYSEX_TRANSFER_SIZE 4
122 
123 // All version ints are stored as 0xVVVVRRMM: V = version, R = revision, M = minor revision.
124 #define IPLUG_VERSION 0x010000
125 #define IPLUG_VERSION_MAGIC 'pfft'
126 
127 static const int DEFAULT_BLOCK_SIZE = 1024;
128 static const double DEFAULT_TEMPO = 120.0;
129 static const int kNoParameter = -1;
130 static const int kNoValIdx = -1;
131 static const int kNoTag = -1;
132 
133 #define MAX_BUS_CHANS 64 // wild cards in channel i/o strings will result in this many channels
134 
135 //#if defined VST3_API || defined VST3C_API || defined VST3P_API
136 //#undef stricmp
137 //#undef strnicmp
138 //#include "pluginterfaces/vst/vsttypes.h"
139 //static const uint64_t kInvalidBusType = Steinberg::Vst::SpeakerArr::kEmpty;
140 //#elif defined AU_API || AUv3_API
141 //#include <CoreAudio/CoreAudio.h>
142 //static const uint64_t kInvalidBusType = kAudioChannelLayoutTag_Unknown;
143 //#elif defined AAX_API
144 //#include "AAX_Enums.h"
145 //static const uint64_t kInvalidBusType = AAX_eStemFormat_None;
146 //#else
147 //static const uint64_t kInvalidBusType = 0;
148 //#endif
149 
154 {
155  kReset,
156  kHost,
157  kPresetRecall,
158  kUI,
159  kDelegate,
160  kRecompile, // for FAUST JIT
161  kUnknown,
162  kNumParamSources
163 };
164 
165 static const char* ParamSourceStrs[kNumParamSources] = { "Reset", "Host", "Preset", "UI", "Editor Delegate", "Recompile", "Unknown"};
166 
170 enum ERoute
171 {
172  kInput = 0,
173  kOutput = 1
174 };
175 
176 static const char* RoutingDirStrs[2] = { "Input", "Output" };
177 
178 enum EAPI
179 {
180  kAPIVST2 = 0,
181  kAPIVST3 = 1,
182  kAPIAU = 2,
183  kAPIAUv3 = 3,
184  kAPIAAX = 4,
185  kAPIAPP = 5,
186  kAPIWAM = 6,
187  kAPIWEB = 7
188 };
189 
193 enum EHost
194 {
195  kHostUninit = -1,
196  kHostUnknown = 0,
197  kHostReaper,
198  kHostProTools,
199  kHostCubase,
200  kHostNuendo,
201  kHostSonar,
202  kHostVegas,
203  kHostFL,
204  kHostSamplitude,
205  kHostAbletonLive,
206  kHostTracktion,
207  kHostNTracks,
208  kHostMelodyneStudio,
209  kHostVSTScanner,
210  kHostAULab,
211  kHostForte,
212  kHostChainer,
213  kHostAudition,
214  kHostOrion,
215  kHostBias,
216  kHostSAWStudio,
217  kHostLogic,
218  kHostGarageBand,
219  kHostDigitalPerformer,
220  kHostStandalone,
221  kHostAudioMulch,
222  kHostStudioOne,
223  kHostVST3TestHost,
224  kHostArdour,
225  kHostRenoise,
226  kHostOpenMPT,
227  kHostWaveLab,
228  kHostWaveLabElements,
229  kHostTwistedWave,
230  kHostBitwig,
231  kHostWWW,
232 
233  kHostReason,
234  kHostGoldWave5x,
235  kHostWaveform,
236  kHostAudacity,
237  kHostAcoustica,
238  kHostPluginDoctor,
239  kHostiZotopeRX,
240  kHostSAVIHost,
241  kHostBlueCat,
242 
243  // These hosts don't report the host name:
244  // EnergyXT2
245  // MiniHost
246 };
247 
248 enum EResourceLocation
249 {
250  kNotFound = 0,
251  kAbsolutePath,
252  kWinBinary,
253  kPreloadedTexture
254 };
255 
256 // These constants come from vstpreset.cpp, allowing saving of VST3 format presets without including the VST3 SDK
257 typedef char ChunkID[4];
258 
259 enum ChunkType
260 {
261  kHeader,
262  kComponentState,
263  kControllerState,
264  kProgramData,
265  kMetaInfo,
266  kChunkList,
267  kNumPresetChunks
268 };
269 
270 static const ChunkID commonChunks[kNumPresetChunks] = {
271  {'V', 'S', 'T', '3'}, // kHeader
272  {'C', 'o', 'm', 'p'}, // kComponentState
273  {'C', 'o', 'n', 't'}, // kControllerState
274  {'P', 'r', 'o', 'g'}, // kProgramData
275  {'I', 'n', 'f', 'o'}, // kMetaInfo
276  {'L', 'i', 's', 't'} // kChunkList
277 };
278 
279 // Preset Header: header id + version + class id + list offset
280 static const int32_t kFormatVersion = 1;
281 static const int32_t kClassIDSize = 32; // ASCII-encoded FUID
282 static const int32_t kHeaderSize = sizeof (ChunkID) + sizeof (int32_t) + kClassIDSize + sizeof (int64_t);
283 //static const int32_t kListOffsetPos = kHeaderSize - sizeof (int64_t);
284 
285 // Preset Version Constants
286 static const int kFXPVersionNum = 1;
287 static const int kFXBVersionNum = 2;
288 
289 // This enumeration must match win32 Fkeys as specified in winuser.h
290 enum ESpecialKey
291 {
292  kFVIRTKEY = 0x01,
293  kFSHIFT = 0x04,
294  kFCONTROL = 0x08,
295  kFALT = 0x10,
296  kFLWIN = 0x20
297 };
298 
299 // This enumeration must match win32 virtual keys as specified in winuser.h
300 enum EVirtualKey
301 {
302  kVK_NONE = 0x00,
303 
304  kVK_LBUTTON = 0x01,
305  kVK_RBUTTON = 0x02,
306  kVK_MBUTTON = 0x04,
307 
308  kVK_BACK = 0x08,
309  kVK_TAB = 0x09,
310 
311  kVK_CLEAR = 0x0C,
312  kVK_RETURN = 0x0D,
313 
314  kVK_SHIFT = 0x10,
315  kVK_CONTROL = 0x11,
316  kVK_MENU = 0x12,
317  kVK_PAUSE = 0x13,
318  kVK_CAPITAL = 0x14,
319 
320  kVK_ESCAPE = 0x1B,
321 
322  kVK_SPACE = 0x20,
323  kVK_PRIOR = 0x21,
324  kVK_NEXT = 0x22,
325  kVK_END = 0x23,
326  kVK_HOME = 0x24,
327  kVK_LEFT = 0x25,
328  kVK_UP = 0x26,
329  kVK_RIGHT = 0x27,
330  kVK_DOWN = 0x28,
331  kVK_SELECT = 0x29,
332  kVK_PRINT = 0x2A,
333  kVK_SNAPSHOT = 0x2C,
334  kVK_INSERT = 0x2D,
335  kVK_DELETE = 0x2E,
336  kVK_HELP = 0x2F,
337 
338  kVK_0 = 0x30,
339  kVK_1 = 0x31,
340  kVK_2 = 0x32,
341  kVK_3 = 0x33,
342  kVK_4 = 0x34,
343  kVK_5 = 0x35,
344  kVK_6 = 0x36,
345  kVK_7 = 0x37,
346  kVK_8 = 0x38,
347  kVK_9 = 0x39,
348  kVK_A = 0x41,
349  kVK_B = 0x42,
350  kVK_C = 0x43,
351  kVK_D = 0x44,
352  kVK_E = 0x45,
353  kVK_F = 0x46,
354  kVK_G = 0x47,
355  kVK_H = 0x48,
356  kVK_I = 0x49,
357  kVK_J = 0x4A,
358  kVK_K = 0x4B,
359  kVK_L = 0x4C,
360  kVK_M = 0x4D,
361  kVK_N = 0x4E,
362  kVK_O = 0x4F,
363  kVK_P = 0x50,
364  kVK_Q = 0x51,
365  kVK_R = 0x52,
366  kVK_S = 0x53,
367  kVK_T = 0x54,
368  kVK_U = 0x55,
369  kVK_V = 0x56,
370  kVK_W = 0x57,
371  kVK_X = 0x58,
372  kVK_Y = 0x59,
373  kVK_Z = 0x5A,
374 
375  kVK_LWIN = 0x5B,
376 
377  kVK_NUMPAD0 = 0x60,
378  kVK_NUMPAD1 = 0x61,
379  kVK_NUMPAD2 = 0x62,
380  kVK_NUMPAD3 = 0x63,
381  kVK_NUMPAD4 = 0x64,
382  kVK_NUMPAD5 = 0x65,
383  kVK_NUMPAD6 = 0x66,
384  kVK_NUMPAD7 = 0x67,
385  kVK_NUMPAD8 = 0x68,
386  kVK_NUMPAD9 = 0x69,
387  kVK_MULTIPLY = 0x6A,
388  kVK_ADD = 0x6B,
389  kVK_SEPARATOR = 0x6C,
390  kVK_SUBTRACT = 0x6D,
391  kVK_DECIMAL = 0x6E,
392  kVK_DIVIDE = 0x6F,
393  kVK_F1 = 0x70,
394  kVK_F2 = 0x71,
395  kVK_F3 = 0x72,
396  kVK_F4 = 0x73,
397  kVK_F5 = 0x74,
398  kVK_F6 = 0x75,
399  kVK_F7 = 0x76,
400  kVK_F8 = 0x77,
401  kVK_F9 = 0x78,
402  kVK_F10 = 0x79,
403  kVK_F11 = 0x7A,
404  kVK_F12 = 0x7B,
405  kVK_F13 = 0x7C,
406  kVK_F14 = 0x7D,
407  kVK_F15 = 0x7E,
408  kVK_F16 = 0x7F,
409  kVK_F17 = 0x80,
410  kVK_F18 = 0x81,
411  kVK_F19 = 0x82,
412  kVK_F20 = 0x83,
413  kVK_F21 = 0x84,
414  kVK_F22 = 0x85,
415  kVK_F23 = 0x86,
416  kVK_F24 = 0x87,
417 
418  kVK_NUMLOCK = 0x90,
419  kVK_SCROLL = 0x91
420 };
421 
422 END_IPLUG_NAMESPACE
423 
Include to get consistently named preprocessor macros for different platforms and logging functionali...
EHost
Host identifier.
EParamSource
Used to identify the source of a parameter change.
ERoute
Used to identify whether a bus/channel connection is an input or an output.
static const double AMP_DB
Magic number for gain to dB conversion.
static const double IAMP_DB
Magic number for dB to gain conversion.