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

Utility functions and macros. More...

Classes

class  IMidiQueue
 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)
 

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)
 
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)
 
static FILE * fopenUTF8 (const char *path, const char *mode)
 

Detailed Description

Utility functions and macros.

Macro Definition Documentation

◆ GET_PARAM_FROM_VARARG

#define GET_PARAM_FROM_VARARG (   paramType,
  vp,
 
)

Definition at line 64 of file IPlugUtilities.h.

◆ MAKE_QUOTE

#define MAKE_QUOTE (   str)    #str

Definition at line 60 of file IPlugUtilities.h.

◆ MAKE_STR

#define MAKE_STR (   str)    MAKE_QUOTE(str)

Definition at line 61 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 105 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 149 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 58 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 97 of file IPlugUtilities.h.

References IAMP_DB.

◆ fopenUTF8()

static FILE * fopenUTF8 ( const char *  path,
const char *  mode 
)
static

Definition at line 412 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 125 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 238 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 115 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 135 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 56 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 173 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
Todo:
Parameters
midiPitch
Todo:
Parameters
noteName
Todo:
Parameters
cents
Todo:
Parameters
middleCisC4
Todo:

Definition at line 298 of file IPlugUtilities.h.

Referenced by IParam::InitPitch().

◆ ToLower()

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