openshot-audio  0.1.7
Classes | Namespaces | Macros | Typedefs | Functions | Variables
juce_MathsFunctions.h File Reference

Go to the source code of this file.

Classes

struct  TypeHelpers::ParameterType< Type >
 
struct  TypeHelpers::ParameterType< Type & >
 
struct  TypeHelpers::ParameterType< Type * >
 
struct  TypeHelpers::ParameterType< char >
 
struct  TypeHelpers::ParameterType< unsigned char >
 
struct  TypeHelpers::ParameterType< short >
 
struct  TypeHelpers::ParameterType< unsigned short >
 
struct  TypeHelpers::ParameterType< int >
 
struct  TypeHelpers::ParameterType< unsigned int >
 
struct  TypeHelpers::ParameterType< long >
 
struct  TypeHelpers::ParameterType< unsigned long >
 
struct  TypeHelpers::ParameterType< int64 >
 
struct  TypeHelpers::ParameterType< uint64 >
 
struct  TypeHelpers::ParameterType< bool >
 
struct  TypeHelpers::ParameterType< float >
 
struct  TypeHelpers::ParameterType< double >
 
struct  TypeHelpers::SmallestFloatType< Type >
 
struct  TypeHelpers::SmallestFloatType< double >
 

Namespaces

 TypeHelpers
 

Macros

#define JUCE_MATHSFUNCTIONS_H_INCLUDED
 
#define literal64bit(longLiteral)   (longLiteral##LL)
 
#define JUCE_UNDENORMALISE(x)
 
#define PARAMETER_TYPE(a)   typename TypeHelpers::ParameterType<a>::type
 
#define literal64bit(longLiteral)   (longLiteral##LL)
 
#define JUCE_UNDENORMALISE(x)
 
#define PARAMETER_TYPE(a)   typename TypeHelpers::ParameterType<a>::type
 

Typedefs

typedef signed char int8
 
typedef unsigned char uint8
 
typedef signed short int16
 
typedef unsigned short uint16
 
typedef signed int int32
 
typedef unsigned int uint32
 
typedef long long int64
 
typedef unsigned long long uint64
 
typedef int pointer_sized_int
 
typedef unsigned int pointer_sized_uint
 

Functions

template<typename Type >
Type jmax (const Type a, const Type b)
 
template<typename Type >
Type jmax (const Type a, const Type b, const Type c)
 
template<typename Type >
Type jmax (const Type a, const Type b, const Type c, const Type d)
 
template<typename Type >
Type jmin (const Type a, const Type b)
 
template<typename Type >
Type jmin (const Type a, const Type b, const Type c)
 
template<typename Type >
Type jmin (const Type a, const Type b, const Type c, const Type d)
 
template<typename Type >
const Type findMinimum (const Type *data, int numValues)
 
template<typename Type >
const Type findMaximum (const Type *values, int numValues)
 
template<typename Type >
void findMinAndMax (const Type *values, int numValues, Type &lowest, Type &highest)
 
template<typename Type >
Type jlimit (const Type lowerLimit, const Type upperLimit, const Type valueToConstrain) noexcept
 
template<typename Type >
bool isPositiveAndBelow (Type valueToTest, Type upperLimit) noexcept
 
template<>
bool isPositiveAndBelow (const int valueToTest, const int upperLimit) noexcept
 
template<typename Type >
bool isPositiveAndNotGreaterThan (Type valueToTest, Type upperLimit) noexcept
 
template<>
bool isPositiveAndNotGreaterThan (const int valueToTest, const int upperLimit) noexcept
 
template<typename Type >
void swapVariables (Type &variable1, Type &variable2)
 
template<typename Type1 >
void ignoreUnused (const Type1 &) noexcept
 
template<typename Type1 , typename Type2 >
void ignoreUnused (const Type1 &, const Type2 &) noexcept
 
template<typename Type1 , typename Type2 , typename Type3 >
void ignoreUnused (const Type1 &, const Type2 &, const Type3 &) noexcept
 
template<typename Type1 , typename Type2 , typename Type3 , typename Type4 >
void ignoreUnused (const Type1 &, const Type2 &, const Type3 &, const Type4 &) noexcept
 
template<typename Type , int N>
int numElementsInArray (Type(&array)[N])
 
template<typename Type >
Type juce_hypot (Type a, Type b) noexcept
 
template<>
float juce_hypot (float a, float b) noexcept
 
int64 abs64 (const int64 n) noexcept
 
template<typename FloatType >
FloatType degreesToRadians (FloatType degrees) noexcept
 
template<typename FloatType >
FloatType radiansToDegrees (FloatType radians) noexcept
 
template<typename NumericType >
bool juce_isfinite (NumericType) noexcept
 
template<>
bool juce_isfinite (float value) noexcept
 
template<>
bool juce_isfinite (double value) noexcept
 
template<typename FloatType >
int roundToInt (const FloatType value) noexcept
 
int roundToInt (int value) noexcept
 
int roundToIntAccurate (const double value) noexcept
 
int roundDoubleToInt (const double value) noexcept
 
int roundFloatToInt (const float value) noexcept
 
template<typename IntegerType >
bool isPowerOfTwo (IntegerType value)
 
int nextPowerOfTwo (int n) noexcept
 
int countNumberOfBits (uint32 n) noexcept
 
int countNumberOfBits (uint64 n) noexcept
 
template<typename IntegerType >
IntegerType negativeAwareModulo (IntegerType dividend, const IntegerType divisor) noexcept
 
template<typename NumericType >
NumericType square (NumericType n) noexcept
 

Variables

const double double_Pi = 3.1415926535897932384626433832795
 
const float float_Pi = 3.14159265358979323846f
 

Macro Definition Documentation

#define JUCE_MATHSFUNCTIONS_H_INCLUDED

(Deprecated) This was a Windows-specific way of checking for object leaks - now please use the JUCE_LEAK_DETECTOR instead.

#define JUCE_UNDENORMALISE (   x)
#define JUCE_UNDENORMALISE (   x)
#define literal64bit (   longLiteral)    (longLiteral##LL)

A macro for creating 64-bit literals. Historically, this was needed to support portability with MSVC6, and is kept here so that old code will still compile, but nowadays every compiler will support the LL and ULL suffixes, so you should use those in preference to this macro.

#define literal64bit (   longLiteral)    (longLiteral##LL)
#define PARAMETER_TYPE (   a)    typename TypeHelpers::ParameterType<a>::type

A helpful macro to simplify the use of the ParameterType template.

See Also
ParameterType
#define PARAMETER_TYPE (   a)    typename TypeHelpers::ParameterType<a>::type

Typedef Documentation

typedef signed short int16

A platform-independent 16-bit signed integer type.

typedef signed int int32

A platform-independent 32-bit signed integer type.

typedef long long int64

A platform-independent 64-bit integer type.

typedef signed char int8

A platform-independent 8-bit signed integer type.

A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it.

typedef unsigned int pointer_sized_uint

An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it.

typedef unsigned short uint16

A platform-independent 16-bit unsigned integer type.

typedef unsigned int uint32

A platform-independent 32-bit unsigned integer type.

typedef unsigned long long uint64

A platform-independent 64-bit unsigned integer type.

typedef unsigned char uint8

A platform-independent 8-bit unsigned integer type.

Function Documentation

int64 abs64 ( const int64  n)
inlinenoexcept

64-bit abs function.

int countNumberOfBits ( uint32  n)
inlinenoexcept

Returns the number of bits in a 32-bit integer.

int countNumberOfBits ( uint64  n)
inlinenoexcept

Returns the number of bits in a 64-bit integer.

template<typename FloatType >
FloatType degreesToRadians ( FloatType  degrees)
inlinenoexcept

Converts an angle in degrees to radians.

template<typename Type >
const Type findMaximum ( const Type *  values,
int  numValues 
)

Scans an array of values, returning the maximum value that it contains.

template<typename Type >
void findMinAndMax ( const Type *  values,
int  numValues,
Type &  lowest,
Type &  highest 
)

Scans an array of values, returning the minimum and maximum values that it contains.

template<typename Type >
const Type findMinimum ( const Type *  data,
int  numValues 
)

Scans an array of values, returning the minimum value that it contains.

template<typename Type1 >
void ignoreUnused ( const Type1 &  )
noexcept

Handy function for avoiding unused variables warning.

template<typename Type1 , typename Type2 >
void ignoreUnused ( const Type1 &  ,
const Type2 &   
)
noexcept
template<typename Type1 , typename Type2 , typename Type3 >
void ignoreUnused ( const Type1 &  ,
const Type2 &  ,
const Type3 &   
)
noexcept
template<typename Type1 , typename Type2 , typename Type3 , typename Type4 >
void ignoreUnused ( const Type1 &  ,
const Type2 &  ,
const Type3 &  ,
const Type4 &   
)
noexcept
template<typename Type >
bool isPositiveAndBelow ( Type  valueToTest,
Type  upperLimit 
)
inlinenoexcept

Returns true if a value is at least zero, and also below a specified upper limit. This is basically a quicker way to write:

valueToTest >= 0 && valueToTest < upperLimit
template<>
bool isPositiveAndBelow ( const int  valueToTest,
const int  upperLimit 
)
inlinenoexcept
template<typename Type >
bool isPositiveAndNotGreaterThan ( Type  valueToTest,
Type  upperLimit 
)
inlinenoexcept

Returns true if a value is at least zero, and also less than or equal to a specified upper limit. This is basically a quicker way to write:

valueToTest >= 0 && valueToTest <= upperLimit
template<>
bool isPositiveAndNotGreaterThan ( const int  valueToTest,
const int  upperLimit 
)
inlinenoexcept
template<typename IntegerType >
bool isPowerOfTwo ( IntegerType  value)

Returns true if the specified integer is a power-of-two.

template<typename Type >
Type jlimit ( const Type  lowerLimit,
const Type  upperLimit,
const Type  valueToConstrain 
)
inlinenoexcept

Constrains a value to keep it within a given range.

This will check that the specified value lies between the lower and upper bounds specified, and if not, will return the nearest value that would be in-range. Effectively, it's like calling jmax (lowerLimit, jmin (upperLimit, value)).

Note that it expects that lowerLimit <= upperLimit. If this isn't true, the results will be unpredictable.

Parameters
lowerLimitthe minimum value to return
upperLimitthe maximum value to return
valueToConstrainthe value to try to return
Returns
the closest value to valueToConstrain which lies between lowerLimit and upperLimit (inclusive)
See Also
jlimit0To, jmin, jmax
template<typename Type >
Type jmax ( const Type  a,
const Type  b 
)
inline

Returns the larger of two values.

template<typename Type >
Type jmax ( const Type  a,
const Type  b,
const Type  c 
)
inline

Returns the larger of three values.

template<typename Type >
Type jmax ( const Type  a,
const Type  b,
const Type  c,
const Type  d 
)
inline

Returns the larger of four values.

template<typename Type >
Type jmin ( const Type  a,
const Type  b 
)
inline

Returns the smaller of two values.

template<typename Type >
Type jmin ( const Type  a,
const Type  b,
const Type  c 
)
inline

Returns the smaller of three values.

template<typename Type >
Type jmin ( const Type  a,
const Type  b,
const Type  c,
const Type  d 
)
inline

Returns the smaller of four values.

template<typename Type >
Type juce_hypot ( Type  a,
Type  b 
)
inlinenoexcept

Using juce_hypot is easier than dealing with the different types of hypot function that are provided by the various platforms and compilers.

template<>
float juce_hypot ( float  a,
float  b 
)
inlinenoexcept
template<typename NumericType >
bool juce_isfinite ( NumericType  )
inlinenoexcept

The isfinite() method seems to vary between platforms, so this is a platform-independent function for it.

template<>
bool juce_isfinite ( float  value)
inlinenoexcept
template<>
bool juce_isfinite ( double  value)
inlinenoexcept
template<typename IntegerType >
IntegerType negativeAwareModulo ( IntegerType  dividend,
const IntegerType  divisor 
)
noexcept

Performs a modulo operation, but can cope with the dividend being negative. The divisor must be greater than zero.

int nextPowerOfTwo ( int  n)
inlinenoexcept

Returns the smallest power-of-two which is equal to or greater than the given integer.

template<typename Type , int N>
int numElementsInArray ( Type(&)  array[N])
inline

Handy function for getting the number of elements in a simple const C array. E.g.

static int myArray[] = { 1, 2, 3 };
int numElements = numElementsInArray (myArray) // returns 3
template<typename FloatType >
FloatType radiansToDegrees ( FloatType  radians)
inlinenoexcept

Converts an angle in radians to degrees.

int roundDoubleToInt ( const double  value)
inlinenoexcept

Fast floating-point-to-integer conversion.

This is faster than using the normal c++ cast to convert a double to an int, and it will round the value to the nearest integer, rather than rounding it down like the normal cast does.

Note that this routine gets its speed at the expense of some accuracy, and when rounding values whose floating point component is exactly 0.5, odd numbers and even numbers will be rounded up or down differently. For a more accurate conversion, see roundDoubleToIntAccurate().

int roundFloatToInt ( const float  value)
inlinenoexcept

Fast floating-point-to-integer conversion.

This is faster than using the normal c++ cast to convert a float to an int, and it will round the value to the nearest integer, rather than rounding it down like the normal cast does.

Note that this routine gets its speed at the expense of some accuracy, and when rounding values whose floating point component is exactly 0.5, odd numbers and even numbers will be rounded up or down differently.

template<typename FloatType >
int roundToInt ( const FloatType  value)
inlinenoexcept

Fast floating-point-to-integer conversion.

This is faster than using the normal c++ cast to convert a float to an int, and it will round the value to the nearest integer, rather than rounding it down like the normal cast does.

Note that this routine gets its speed at the expense of some accuracy, and when rounding values whose floating point component is exactly 0.5, odd numbers and even numbers will be rounded up or down differently.

int roundToInt ( int  value)
inlinenoexcept
int roundToIntAccurate ( const double  value)
inlinenoexcept

Fast floating-point-to-integer conversion.

This is a slightly slower and slightly more accurate version of roundDoubleToInt(). It works fine for values above zero, but negative numbers are rounded the wrong way.

template<typename NumericType >
NumericType square ( NumericType  n)
noexcept

Returns the square of its argument.

template<typename Type >
void swapVariables ( Type &  variable1,
Type &  variable2 
)
inline

Handy function to swap two values.

Variable Documentation

const double double_Pi = 3.1415926535897932384626433832795

A predefined value for Pi, at double-precision.

See Also
float_Pi
const float float_Pi = 3.14159265358979323846f

A predefined value for Pi, at single-precision.

See Also
double_Pi