iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Classes | Macros | Enumerations | Functions
IPlug::Utilities

Utility functions and macros. More...

Classes

class  IMidiQueueBase< T >
 A class to help with queuing timestamped MIDI messages. More...
 

Macros

#define MAKE_QUOTE(str)   #str
 
#define MAKE_STR(str)   MAKE_QUOTE(str)
 
#define GET_PARAM_FROM_VARARG(paramType, vp, v)
 

Enumerations

enum  EDOMVirtualKey {
  DOM_VK_BACK_SPACE = 0x08 , DOM_VK_TAB = 0x09 , DOM_VK_RETURN = 0x0D , DOM_VK_SHIFT = 0x10 ,
  DOM_VK_CONTROL = 0x11 , DOM_VK_ALT = 0x12 , DOM_VK_PAUSE = 0x13 , DOM_VK_CAPS_LOCK = 0x14 ,
  DOM_VK_ESCAPE = 0x1B , DOM_VK_SPACE = 0x20 , DOM_VK_PAGE_UP = 0x21 , DOM_VK_PAGE_DOWN = 0x22 ,
  DOM_VK_END = 0x23 , DOM_VK_HOME = 0x24 , DOM_VK_LEFT = 0x25 , DOM_VK_UP = 0x26 ,
  DOM_VK_RIGHT = 0x27 , DOM_VK_DOWN = 0x28 , DOM_VK_INSERT = 0x2D , DOM_VK_DELETE = 0x2E ,
  DOM_VK_F1 = 0x70 , DOM_VK_F2 = 0x71 , DOM_VK_F3 = 0x72 , DOM_VK_F4 = 0x73 ,
  DOM_VK_F5 = 0x74 , DOM_VK_F6 = 0x75 , DOM_VK_F7 = 0x76 , DOM_VK_F8 = 0x77 ,
  DOM_VK_F9 = 0x78 , DOM_VK_F10 = 0x79 , DOM_VK_F11 = 0x7A , DOM_VK_F12 = 0x7B ,
  DOM_VK_NUMPAD0 = 0x60 , DOM_VK_NUMPAD1 = 0x61 , DOM_VK_NUMPAD2 = 0x62 , DOM_VK_NUMPAD3 = 0x63 ,
  DOM_VK_NUMPAD4 = 0x64 , DOM_VK_NUMPAD5 = 0x65 , DOM_VK_NUMPAD6 = 0x66 , DOM_VK_NUMPAD7 = 0x67 ,
  DOM_VK_NUMPAD8 = 0x68 , DOM_VK_NUMPAD9 = 0x69
}
 

Functions

template<typename T >
BEGIN_IPLUG_NAMESPACE T Clip (T x, T lo, T hi)
 Clips the value x between lo and hi. More...
 
template<typename T >
Lerp (T a, T b, T f)
 Linear interpolate between values a and b. More...
 
static bool CStringHasContents (const char *str)
 
static double DBToAmp (double dB)
 Calculates gain from a given dB value. More...
 
static double AmpToDB (double amp)
 
static void GetVersionParts (int versionInteger, int &maj, int &min, int &pat)
 Helper function to unpack the version number parts as individual integers. More...
 
static int GetDecimalVersion (int versionInteger)
 Helper function to get the version number as a decimal integer. More...
 
static void GetVersionStr (int versionInteger, WDL_String &str)
 Helper function to get the semantic version number as a string from an integer. More...
 
template<class SRC , class DEST >
void CastCopy (DEST *pDest, SRC *pSrc, int n)
 Helper function to loop through a buffer of samples copying and casting from e.g float to double. More...
 
static void ToLower (char *cDest, const char *cSrc)
 Converts a C string to lowercase. More...
 
static EHost LookUpHost (const char *inHost)
 Gets the host ID from a human-readable name. More...
 
static void GetHostNameStr (EHost host, WDL_String &str)
 Gets a human-readable name from host identifier. More...
 
static void MidiNoteName (double midiPitch, WDL_String &noteName, bool cents=false, bool middleCisC4=false)
 Converts a MIDI pitch number to a human-readable note name. More...
 
static std::u16string UTF8ToUTF16String (const char *utf8)
 Convert UTF-8 string to UTF-16 std::u16string using WDL functions. More...
 
static std::string UTF16ToUTF8String (const std::u16string &u16str)
 Convert UTF-16 std::u16string to UTF-8 std::string using WDL functions. More...
 
static std::string UTF16ToUTF8String (char16_t c)
 Convert single UTF-16 char16_t to UTF-8 std::string using WDL functions. More...
 
static std::string UTF16ToUTF8String (const char16_t *begin, const char16_t *end)
 Convert UTF-16 char16_t pointer range to UTF-8 std::string using WDL functions. More...
 
int DOMKeyToVirtualKey (uint32_t domKeyCode)
 Converts a DOM virtual key code to an iPlug2 virtual key code. More...
 

Detailed Description

Utility functions and macros.

Macro Definition Documentation

◆ GET_PARAM_FROM_VARARG

#define GET_PARAM_FROM_VARARG (   paramType,
  vp,
 
)

Definition at line 66 of file IPlugUtilities.h.

◆ MAKE_QUOTE

#define MAKE_QUOTE (   str)    #str

Definition at line 62 of file IPlugUtilities.h.

◆ MAKE_STR

#define MAKE_STR (   str)    MAKE_QUOTE(str)

Definition at line 63 of file IPlugUtilities.h.

Enumeration Type Documentation

◆ EDOMVirtualKey

enum EDOMVirtualKey

Definition at line 484 of file IPlugUtilities.h.

Function Documentation

◆ AmpToDB()

static double AmpToDB ( double  amp)
inlinestatic
Returns
dB calculated as an approximation of \( 20*log_{10}(x) \)
See also
AMP_DB

Definition at line 107 of file IPlugUtilities.h.

References AMP_DB.

Referenced by IBMeterControl::OnMsgFromDelegate(), IVMeterControl< MAXNC >::OnMsgFromDelegate(), and IVPeakAvgMeterControl< MAXNC >::OnMsgFromDelegate().

◆ CastCopy()

template<class SRC , class DEST >
void CastCopy ( DEST *  pDest,
SRC *  pSrc,
int  n 
)

Helper function to loop through a buffer of samples copying and casting from e.g float to double.

Template Parameters
SRCThe source type
DESTThe destination type
Parameters
pDestPtr to the destination buffer
pSrcPtr to the source buffer
nThe number of or elements in the buffer

Definition at line 151 of file IPlugUtilities.h.

◆ Clip()

template<typename T >
BEGIN_IPLUG_NAMESPACE T Clip ( x,
lo,
hi 
)

◆ CStringHasContents()

static bool CStringHasContents ( const char *  str)
inlinestatic

Definition at line 60 of file IPlugUtilities.h.

◆ DBToAmp()

static double DBToAmp ( double  dB)
inlinestatic

Calculates gain from a given dB value.

Parameters
dBValue in dB
Returns
Gain calculated as an approximation of \( 10^{\frac{x}{20}} \)
See also
IAMP_DB

Definition at line 99 of file IPlugUtilities.h.

References IAMP_DB.

◆ DOMKeyToVirtualKey()

int DOMKeyToVirtualKey ( uint32_t  domKeyCode)
inline

Converts a DOM virtual key code to an iPlug2 virtual key code.

Parameters
domKeyCodeThe DOM virtual key code to convert
Returns
The corresponding iPlug2 virtual key code, or 0 if no mapping exists

Definition at line 534 of file IPlugUtilities.h.

◆ GetDecimalVersion()

static int GetDecimalVersion ( int  versionInteger)
inlinestatic

Helper function to get the version number as a decimal integer.

Parameters
versionIntegerThe version number packed into an integer
Returns
int Decimal version

Definition at line 127 of file IPlugUtilities.h.

References GetVersionParts().

Referenced by IPluginBase::GetHostVersion(), and IPluginBase::GetPluginVersion().

◆ GetHostNameStr()

static void GetHostNameStr ( EHost  host,
WDL_String &  str 
)
static

Gets a human-readable name from host identifier.

Parameters
hostHost identifier (see EHost)
strWDL_String to set
int hostID = EHost::kHostAbletonLive;
WDL_String hostName;
GetHostNameStr(hostID, hostName);
static void GetHostNameStr(EHost host, WDL_String &str)
Gets a human-readable name from host identifier.

Definition at line 240 of file IPlugUtilities.h.

Referenced by IPluginBase::GetHostStr().

◆ GetVersionParts()

static void GetVersionParts ( int  versionInteger,
int &  maj,
int &  min,
int &  pat 
)
inlinestatic

Helper function to unpack the version number parts as individual integers.

Parameters
versionIntegerThe version number packed into an integer
majThe major version
minThe minor version
patThe patch version

Definition at line 117 of file IPlugUtilities.h.

Referenced by GetDecimalVersion(), and GetVersionStr().

◆ GetVersionStr()

static void GetVersionStr ( int  versionInteger,
WDL_String &  str 
)
inlinestatic

Helper function to get the semantic version number as a string from an integer.

Parameters
versionIntegerThe version number packed into an integer
strWDL_String to be populated with the version number in MAJOR.MINOR.PATCH format as a string

Definition at line 137 of file IPlugUtilities.h.

References GetVersionParts().

Referenced by IPluginBase::GetHostVersionStr(), IPluginBase::GetPluginVersionStr(), and IPlugAPIBase::SetHost().

◆ Lerp()

template<typename T >
T Lerp ( a,
b,
f 
)
inline

Linear interpolate between values a and b.

Parameters
aLow value
bHigh value
fValue betweeen 0-1 for interpolation

Definition at line 58 of file IPlugUtilities.h.

◆ LookUpHost()

static EHost LookUpHost ( const char *  inHost)
static

Gets the host ID from a human-readable name.

Parameters
inHostHost name to search for
Returns
Identifier of the host (see EHost)

Definition at line 175 of file IPlugUtilities.h.

References ToLower().

Referenced by IPlugAPIBase::SetHost().

◆ MidiNoteName()

static void MidiNoteName ( double  midiPitch,
WDL_String &  noteName,
bool  cents = false,
bool  middleCisC4 = false 
)
static

Converts a MIDI pitch number to a human-readable note name.

Parameters
midiPitchThe MIDI pitch (0-127, fractional values supported)
noteNameOutput string to store the note name
centsIf true, includes cent deviation from the nearest pitch
middleCisC4If true, uses C4 as middle C; if false, uses C3 as middle C

Definition at line 300 of file IPlugUtilities.h.

Referenced by IParam::InitPitch().

◆ ToLower()

static void ToLower ( char *  cDest,
const char *  cSrc 
)
static

Converts a C string to lowercase.

Parameters
cDestDestination buffer for the lowercase string (must be pre-allocated)
cSrcSource string to convert

Definition at line 162 of file IPlugUtilities.h.

Referenced by IGraphicsNanoVG::BitmapExtSupported(), IGraphicsSkia::BitmapExtSupported(), and LookUpHost().

◆ UTF16ToUTF8String() [1/3]

static std::string UTF16ToUTF8String ( char16_t  c)
static

Convert single UTF-16 char16_t to UTF-8 std::string using WDL functions.

Parameters
cUTF-16 encoded char16_t
Returns
UTF-8 encoded std::string

Definition at line 458 of file IPlugUtilities.h.

◆ UTF16ToUTF8String() [2/3]

static std::string UTF16ToUTF8String ( const char16_t *  begin,
const char16_t *  end 
)
static

Convert UTF-16 char16_t pointer range to UTF-8 std::string using WDL functions.

Parameters
beginpointer to start of UTF-16 range
endpointer to end of UTF-16 range
Returns
UTF-8 encoded std::string

Definition at line 469 of file IPlugUtilities.h.

References UTF16ToUTF8String().

◆ UTF16ToUTF8String() [3/3]

static std::string UTF16ToUTF8String ( const std::u16string &  u16str)
static

Convert UTF-16 std::u16string to UTF-8 std::string using WDL functions.

Parameters
u16strUTF-16 encoded std::u16string
Returns
UTF-8 encoded std::string

Definition at line 433 of file IPlugUtilities.h.

Referenced by ITextEntryControl::Draw(), and UTF16ToUTF8String().

◆ UTF8ToUTF16String()

static std::u16string UTF8ToUTF16String ( const char *  utf8)
static

Convert UTF-8 string to UTF-16 std::u16string using WDL functions.

Parameters
utf8UTF-8 encoded C string
Returns
UTF-16 encoded std::u16string

Definition at line 407 of file IPlugUtilities.h.