mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-09 08:14:58 +01:00
new audio engine backend for native CoreAudio audio I/O, and PortMIDI for MIDI.
Code builds, runs and functions. Full code review still pending, and some possibly changes to organization of code within the backend is possible
This commit is contained in:
parent
0a6af1420f
commit
1de00ab6bb
84 changed files with 21936 additions and 0 deletions
122
libs/backends/wavesaudio/wavesapi/miscutils/MinMaxUtilities.h
Normal file
122
libs/backends/wavesaudio/wavesapi/miscutils/MinMaxUtilities.h
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
/*
|
||||
Copyright (C) 2013 Waves Audio Ltd.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
#ifndef __MinMaxUtilities_h__
|
||||
#define __MinMaxUtilities_h__
|
||||
|
||||
/* copy to include
|
||||
#include "MiscUtils/MinMaxUtilities.h"
|
||||
*/
|
||||
|
||||
#include "BasicTypes/WUDefines.h"
|
||||
#include "BasicTypes/WUMathConsts.h"
|
||||
#include "WavesPublicAPI/wstdint.h"
|
||||
|
||||
// New accelerated templates
|
||||
#if defined ( __cplusplus ) && !defined (__WUMinMax)
|
||||
#define __WUMinMax // Also defined in Nativepr.h
|
||||
|
||||
|
||||
template<class T> inline T WUMin(const T &a, const T &b) {return (a < b) ? a : b;} // requires only < to be defined for T
|
||||
template<class T> inline T WUMax(const T &a,const T &b) {return (a < b) ? b : a;} // requires only < to be defined for T
|
||||
template<class T> inline T WUMinMax(const T &Smallest, const T &Biggest, const T &Val) // requires only < to be defined for T
|
||||
{
|
||||
return ((Val < Smallest) ? Smallest : ((Biggest < Val) ? Biggest : Val));
|
||||
}
|
||||
/*
|
||||
// Min and Max
|
||||
template<class T> inline T WUMin(T a,T b) {return (a < b) ? a : b;} // requires only < to be defined for T
|
||||
template<class T> inline T WUMax(T a,T b) {return (a < b) ? b : a;} // requires only < to be defined for T
|
||||
template<class T> inline T WUMinMax(T SMALLEST, T BIGGEST, T X) // requires only < to be defined for T
|
||||
{
|
||||
return ((X < SMALLEST) ? SMALLEST : ((BIGGEST < X) ? BIGGEST : X));
|
||||
}
|
||||
*/
|
||||
// Absolute value
|
||||
#ifdef _WINDOWS
|
||||
#include <math.h>
|
||||
#define __abs(x) abs(x)
|
||||
#define __labs(x) labs(x)
|
||||
#define __fabs(x) fabs(x)
|
||||
#endif
|
||||
#ifdef __GNUC__
|
||||
#include <iostream> // why don't know makes it work need to check
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
|
||||
#define __abs(x) std::abs(x)
|
||||
#define __labs(x) std::labs(x)
|
||||
#define __fabs(x) std::fabs(x)
|
||||
#endif
|
||||
#ifdef __MACOS__
|
||||
#ifdef __GNUC__
|
||||
#include <iostream> // why don't know makes it work need to check
|
||||
#include <cmath>
|
||||
#define __abs(x) std::abs(x)
|
||||
#define __labs(x) std::labs(x)
|
||||
#define __fabs(x) std::fabs(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// log2: on Windows there's no proper definition for log2, whereas on other platform there is.
|
||||
#ifndef WUlog2
|
||||
#if defined(_WINDOWS)
|
||||
#define WUlog2(x) (kdOneOverLog2 * log10((x)))
|
||||
#else
|
||||
#define WUlog2(x) log2(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
template <class T> inline T WUAbs(const T &xA)
|
||||
{
|
||||
return (xA > T(0))? xA: -xA;
|
||||
}
|
||||
|
||||
template <> inline int WUAbs(const int &xA)
|
||||
{
|
||||
return __abs(xA);
|
||||
}
|
||||
|
||||
//template <> inline int32_t WUAbs(const int32_t &xA)// 64BitConversion
|
||||
//{
|
||||
// return __labs(xA);
|
||||
//}
|
||||
|
||||
template <> inline float WUAbs(const float &xA)
|
||||
{
|
||||
return (float) __fabs(xA);
|
||||
}
|
||||
|
||||
template <> inline double WUAbs(const double &xA)
|
||||
{
|
||||
return __fabs(xA);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int32_t DllExport WURand(intptr_t in_Seed);
|
||||
int32_t DllExport WURand();
|
||||
int32_t DllExport rand_gen_formula(int32_t rndSeed);
|
||||
|
||||
template <class T> inline bool WUIsEqualWithTolerance(const T &xA, const T &xB, const T &xTolerance)
|
||||
{
|
||||
return (WUAbs(xA - xB) < xTolerance) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue