The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

640 lines
24KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2016 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of the ISC license
  6. http://www.isc.org/downloads/software-support-policy/isc-license/
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted, provided that the above
  9. copyright notice and this permission notice appear in all copies.
  10. THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
  11. TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  12. FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
  13. OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  14. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  15. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  16. OF THIS SOFTWARE.
  17. -----------------------------------------------------------------------------
  18. To release a closed-source product which uses other parts of JUCE not
  19. licensed under the ISC terms, commercial licenses are available: visit
  20. www.juce.com for more information.
  21. ==============================================================================
  22. */
  23. #ifndef JUCE_MATHSFUNCTIONS_H_INCLUDED
  24. #define JUCE_MATHSFUNCTIONS_H_INCLUDED
  25. //==============================================================================
  26. /*
  27. This file sets up some handy mathematical typdefs and functions.
  28. */
  29. //==============================================================================
  30. // Definitions for the int8, int16, int32, int64 and pointer_sized_int types.
  31. /** A platform-independent 8-bit signed integer type. */
  32. typedef signed char int8;
  33. /** A platform-independent 8-bit unsigned integer type. */
  34. typedef unsigned char uint8;
  35. /** A platform-independent 16-bit signed integer type. */
  36. typedef signed short int16;
  37. /** A platform-independent 16-bit unsigned integer type. */
  38. typedef unsigned short uint16;
  39. /** A platform-independent 32-bit signed integer type. */
  40. typedef signed int int32;
  41. /** A platform-independent 32-bit unsigned integer type. */
  42. typedef unsigned int uint32;
  43. #if JUCE_MSVC
  44. /** A platform-independent 64-bit integer type. */
  45. typedef __int64 int64;
  46. /** A platform-independent 64-bit unsigned integer type. */
  47. typedef unsigned __int64 uint64;
  48. #else
  49. /** A platform-independent 64-bit integer type. */
  50. typedef long long int64;
  51. /** A platform-independent 64-bit unsigned integer type. */
  52. typedef unsigned long long uint64;
  53. #endif
  54. #ifndef DOXYGEN
  55. /** A macro for creating 64-bit literals.
  56. Historically, this was needed to support portability with MSVC6, and is kept here
  57. so that old code will still compile, but nowadays every compiler will support the
  58. LL and ULL suffixes, so you should use those in preference to this macro.
  59. */
  60. #define literal64bit(longLiteral) (longLiteral##LL)
  61. #endif
  62. #if JUCE_64BIT
  63. /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  64. typedef int64 pointer_sized_int;
  65. /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  66. typedef uint64 pointer_sized_uint;
  67. #elif JUCE_MSVC
  68. /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  69. typedef _W64 int pointer_sized_int;
  70. /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  71. typedef _W64 unsigned int pointer_sized_uint;
  72. #else
  73. /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  74. typedef int pointer_sized_int;
  75. /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  76. typedef unsigned int pointer_sized_uint;
  77. #endif
  78. #if JUCE_WINDOWS && ! JUCE_MINGW
  79. typedef pointer_sized_int ssize_t;
  80. #endif
  81. //==============================================================================
  82. // Some indispensable min/max functions
  83. /** Returns the larger of two values. */
  84. template <typename Type>
  85. Type jmax (const Type a, const Type b) { return (a < b) ? b : a; }
  86. /** Returns the larger of three values. */
  87. template <typename Type>
  88. Type jmax (const Type a, const Type b, const Type c) { return (a < b) ? ((b < c) ? c : b) : ((a < c) ? c : a); }
  89. /** Returns the larger of four values. */
  90. template <typename Type>
  91. Type jmax (const Type a, const Type b, const Type c, const Type d) { return jmax (a, jmax (b, c, d)); }
  92. /** Returns the smaller of two values. */
  93. template <typename Type>
  94. Type jmin (const Type a, const Type b) { return (b < a) ? b : a; }
  95. /** Returns the smaller of three values. */
  96. template <typename Type>
  97. Type jmin (const Type a, const Type b, const Type c) { return (b < a) ? ((c < b) ? c : b) : ((c < a) ? c : a); }
  98. /** Returns the smaller of four values. */
  99. template <typename Type>
  100. Type jmin (const Type a, const Type b, const Type c, const Type d) { return jmin (a, jmin (b, c, d)); }
  101. /** Remaps a normalised value (between 0 and 1) to a target range.
  102. This effectively returns (targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin)).
  103. */
  104. template <typename Type>
  105. Type jmap (Type value0To1, Type targetRangeMin, Type targetRangeMax)
  106. {
  107. return targetRangeMin + value0To1 * (targetRangeMax - targetRangeMin);
  108. }
  109. /** Remaps a value from a source range to a target range. */
  110. template <typename Type>
  111. Type jmap (Type sourceValue, Type sourceRangeMin, Type sourceRangeMax, Type targetRangeMin, Type targetRangeMax)
  112. {
  113. jassert (sourceRangeMax != sourceRangeMin); // mapping from a range of zero will produce NaN!
  114. return targetRangeMin + ((targetRangeMax - targetRangeMin) * (sourceValue - sourceRangeMin)) / (sourceRangeMax - sourceRangeMin);
  115. }
  116. /** Scans an array of values, returning the minimum value that it contains. */
  117. template <typename Type>
  118. Type findMinimum (const Type* data, int numValues)
  119. {
  120. if (numValues <= 0)
  121. return Type();
  122. Type result (*data++);
  123. while (--numValues > 0) // (> 0 rather than >= 0 because we've already taken the first sample)
  124. {
  125. const Type& v = *data++;
  126. if (v < result) result = v;
  127. }
  128. return result;
  129. }
  130. /** Scans an array of values, returning the maximum value that it contains. */
  131. template <typename Type>
  132. Type findMaximum (const Type* values, int numValues)
  133. {
  134. if (numValues <= 0)
  135. return Type();
  136. Type result (*values++);
  137. while (--numValues > 0) // (> 0 rather than >= 0 because we've already taken the first sample)
  138. {
  139. const Type& v = *values++;
  140. if (result < v) result = v;
  141. }
  142. return result;
  143. }
  144. /** Scans an array of values, returning the minimum and maximum values that it contains. */
  145. template <typename Type>
  146. void findMinAndMax (const Type* values, int numValues, Type& lowest, Type& highest)
  147. {
  148. if (numValues <= 0)
  149. {
  150. lowest = Type();
  151. highest = Type();
  152. }
  153. else
  154. {
  155. Type mn (*values++);
  156. Type mx (mn);
  157. while (--numValues > 0) // (> 0 rather than >= 0 because we've already taken the first sample)
  158. {
  159. const Type& v = *values++;
  160. if (mx < v) mx = v;
  161. if (v < mn) mn = v;
  162. }
  163. lowest = mn;
  164. highest = mx;
  165. }
  166. }
  167. //==============================================================================
  168. /** Constrains a value to keep it within a given range.
  169. This will check that the specified value lies between the lower and upper bounds
  170. specified, and if not, will return the nearest value that would be in-range. Effectively,
  171. it's like calling jmax (lowerLimit, jmin (upperLimit, value)).
  172. Note that it expects that lowerLimit <= upperLimit. If this isn't true,
  173. the results will be unpredictable.
  174. @param lowerLimit the minimum value to return
  175. @param upperLimit the maximum value to return
  176. @param valueToConstrain the value to try to return
  177. @returns the closest value to valueToConstrain which lies between lowerLimit
  178. and upperLimit (inclusive)
  179. @see jmin, jmax, jmap
  180. */
  181. template <typename Type>
  182. Type jlimit (const Type lowerLimit,
  183. const Type upperLimit,
  184. const Type valueToConstrain) noexcept
  185. {
  186. jassert (lowerLimit <= upperLimit); // if these are in the wrong order, results are unpredictable..
  187. return (valueToConstrain < lowerLimit) ? lowerLimit
  188. : ((upperLimit < valueToConstrain) ? upperLimit
  189. : valueToConstrain);
  190. }
  191. /** Returns true if a value is at least zero, and also below a specified upper limit.
  192. This is basically a quicker way to write:
  193. @code valueToTest >= 0 && valueToTest < upperLimit
  194. @endcode
  195. */
  196. template <typename Type>
  197. bool isPositiveAndBelow (Type valueToTest, Type upperLimit) noexcept
  198. {
  199. jassert (Type() <= upperLimit); // makes no sense to call this if the upper limit is itself below zero..
  200. return Type() <= valueToTest && valueToTest < upperLimit;
  201. }
  202. template <>
  203. inline bool isPositiveAndBelow (const int valueToTest, const int upperLimit) noexcept
  204. {
  205. jassert (upperLimit >= 0); // makes no sense to call this if the upper limit is itself below zero..
  206. return static_cast<unsigned int> (valueToTest) < static_cast<unsigned int> (upperLimit);
  207. }
  208. /** Returns true if a value is at least zero, and also less than or equal to a specified upper limit.
  209. This is basically a quicker way to write:
  210. @code valueToTest >= 0 && valueToTest <= upperLimit
  211. @endcode
  212. */
  213. template <typename Type>
  214. bool isPositiveAndNotGreaterThan (Type valueToTest, Type upperLimit) noexcept
  215. {
  216. jassert (Type() <= upperLimit); // makes no sense to call this if the upper limit is itself below zero..
  217. return Type() <= valueToTest && valueToTest <= upperLimit;
  218. }
  219. template <>
  220. inline bool isPositiveAndNotGreaterThan (const int valueToTest, const int upperLimit) noexcept
  221. {
  222. jassert (upperLimit >= 0); // makes no sense to call this if the upper limit is itself below zero..
  223. return static_cast<unsigned int> (valueToTest) <= static_cast<unsigned int> (upperLimit);
  224. }
  225. //==============================================================================
  226. /** Handy function to swap two values. */
  227. template <typename Type>
  228. void swapVariables (Type& variable1, Type& variable2)
  229. {
  230. std::swap (variable1, variable2);
  231. }
  232. /** Handy function for avoiding unused variables warning. */
  233. template <typename Type1>
  234. void ignoreUnused (const Type1&) noexcept {}
  235. template <typename Type1, typename Type2>
  236. void ignoreUnused (const Type1&, const Type2&) noexcept {}
  237. template <typename Type1, typename Type2, typename Type3>
  238. void ignoreUnused (const Type1&, const Type2&, const Type3&) noexcept {}
  239. template <typename Type1, typename Type2, typename Type3, typename Type4>
  240. void ignoreUnused (const Type1&, const Type2&, const Type3&, const Type4&) noexcept {}
  241. /** Handy function for getting the number of elements in a simple const C array.
  242. E.g.
  243. @code
  244. static int myArray[] = { 1, 2, 3 };
  245. int numElements = numElementsInArray (myArray) // returns 3
  246. @endcode
  247. */
  248. template <typename Type, int N>
  249. int numElementsInArray (Type (&array)[N])
  250. {
  251. ignoreUnused (array);
  252. (void) sizeof (0[array]); // This line should cause an error if you pass an object with a user-defined subscript operator
  253. return N;
  254. }
  255. //==============================================================================
  256. // Some useful maths functions that aren't always present with all compilers and build settings.
  257. /** Using juce_hypot is easier than dealing with the different types of hypot function
  258. that are provided by the various platforms and compilers. */
  259. template <typename Type>
  260. Type juce_hypot (Type a, Type b) noexcept
  261. {
  262. #if JUCE_MSVC
  263. return static_cast<Type> (_hypot (a, b));
  264. #else
  265. return static_cast<Type> (hypot (a, b));
  266. #endif
  267. }
  268. #ifndef DOXYGEN
  269. template <>
  270. inline float juce_hypot (float a, float b) noexcept
  271. {
  272. #if JUCE_MSVC
  273. return _hypotf (a, b);
  274. #else
  275. return hypotf (a, b);
  276. #endif
  277. }
  278. #endif
  279. /** 64-bit abs function. */
  280. inline int64 abs64 (const int64 n) noexcept
  281. {
  282. return (n >= 0) ? n : -n;
  283. }
  284. #if JUCE_MSVC && ! defined (DOXYGEN) // The MSVC libraries omit these functions for some reason...
  285. template<typename Type> Type asinh (Type x) { return std::log (x + std::sqrt (x * x + (Type) 1)); }
  286. template<typename Type> Type acosh (Type x) { return std::log (x + std::sqrt (x * x - (Type) 1)); }
  287. template<typename Type> Type atanh (Type x) { return (std::log (x + (Type) 1) - std::log (((Type) 1) - x)) / (Type) 2; }
  288. #endif
  289. //==============================================================================
  290. /** A predefined value for Pi, at double-precision.
  291. @see float_Pi
  292. */
  293. const double double_Pi = 3.1415926535897932384626433832795;
  294. /** A predefined value for Pi, at single-precision.
  295. @see double_Pi
  296. */
  297. const float float_Pi = 3.14159265358979323846f;
  298. /** Converts an angle in degrees to radians. */
  299. inline float degreesToRadians (float degrees) noexcept { return degrees * (float_Pi / 180.0f); }
  300. /** Converts an angle in degrees to radians. */
  301. inline double degreesToRadians (double degrees) noexcept { return degrees * (double_Pi / 180.0); }
  302. /** Converts an angle in radians to degrees. */
  303. inline float radiansToDegrees (float radians) noexcept { return radians * (180.0f / float_Pi); }
  304. /** Converts an angle in radians to degrees. */
  305. inline double radiansToDegrees (double radians) noexcept { return radians * (180.0 / double_Pi); }
  306. //==============================================================================
  307. /** The isfinite() method seems to vary between platforms, so this is a
  308. platform-independent function for it.
  309. */
  310. template <typename NumericType>
  311. bool juce_isfinite (NumericType) noexcept
  312. {
  313. return true; // Integer types are always finite
  314. }
  315. template <>
  316. inline bool juce_isfinite (float value) noexcept
  317. {
  318. #if JUCE_WINDOWS && ! JUCE_MINGW
  319. return _finite (value) != 0;
  320. #else
  321. return std::isfinite (value);
  322. #endif
  323. }
  324. template <>
  325. inline bool juce_isfinite (double value) noexcept
  326. {
  327. #if JUCE_WINDOWS && ! JUCE_MINGW
  328. return _finite (value) != 0;
  329. #else
  330. return std::isfinite (value);
  331. #endif
  332. }
  333. //==============================================================================
  334. #if JUCE_MSVC
  335. #pragma optimize ("t", off)
  336. #ifndef __INTEL_COMPILER
  337. #pragma float_control (precise, on, push)
  338. #endif
  339. #endif
  340. /** Fast floating-point-to-integer conversion.
  341. This is faster than using the normal c++ cast to convert a float to an int, and
  342. it will round the value to the nearest integer, rather than rounding it down
  343. like the normal cast does.
  344. Note that this routine gets its speed at the expense of some accuracy, and when
  345. rounding values whose floating point component is exactly 0.5, odd numbers and
  346. even numbers will be rounded up or down differently.
  347. */
  348. template <typename FloatType>
  349. int roundToInt (const FloatType value) noexcept
  350. {
  351. #ifdef __INTEL_COMPILER
  352. #pragma float_control (precise, on, push)
  353. #endif
  354. union { int asInt[2]; double asDouble; } n;
  355. n.asDouble = ((double) value) + 6755399441055744.0;
  356. #if JUCE_BIG_ENDIAN
  357. return n.asInt [1];
  358. #else
  359. return n.asInt [0];
  360. #endif
  361. }
  362. inline int roundToInt (int value) noexcept
  363. {
  364. return value;
  365. }
  366. #if JUCE_MSVC
  367. #ifndef __INTEL_COMPILER
  368. #pragma float_control (pop)
  369. #endif
  370. #pragma optimize ("", on) // resets optimisations to the project defaults
  371. #endif
  372. /** Fast floating-point-to-integer conversion.
  373. This is a slightly slower and slightly more accurate version of roundDoubleToInt(). It works
  374. fine for values above zero, but negative numbers are rounded the wrong way.
  375. */
  376. inline int roundToIntAccurate (double value) noexcept
  377. {
  378. #ifdef __INTEL_COMPILER
  379. #pragma float_control (pop)
  380. #endif
  381. return roundToInt (value + 1.5e-8);
  382. }
  383. /** Fast floating-point-to-integer conversion.
  384. This is faster than using the normal c++ cast to convert a double to an int, and
  385. it will round the value to the nearest integer, rather than rounding it down
  386. like the normal cast does.
  387. Note that this routine gets its speed at the expense of some accuracy, and when
  388. rounding values whose floating point component is exactly 0.5, odd numbers and
  389. even numbers will be rounded up or down differently. For a more accurate conversion,
  390. see roundDoubleToIntAccurate().
  391. */
  392. inline int roundDoubleToInt (double value) noexcept
  393. {
  394. return roundToInt (value);
  395. }
  396. /** Fast floating-point-to-integer conversion.
  397. This is faster than using the normal c++ cast to convert a float to an int, and
  398. it will round the value to the nearest integer, rather than rounding it down
  399. like the normal cast does.
  400. Note that this routine gets its speed at the expense of some accuracy, and when
  401. rounding values whose floating point component is exactly 0.5, odd numbers and
  402. even numbers will be rounded up or down differently.
  403. */
  404. inline int roundFloatToInt (float value) noexcept
  405. {
  406. return roundToInt (value);
  407. }
  408. //==============================================================================
  409. /** Returns true if the specified integer is a power-of-two. */
  410. template <typename IntegerType>
  411. bool isPowerOfTwo (IntegerType value)
  412. {
  413. return (value & (value - 1)) == 0;
  414. }
  415. /** Returns the smallest power-of-two which is equal to or greater than the given integer. */
  416. inline int nextPowerOfTwo (int n) noexcept
  417. {
  418. --n;
  419. n |= (n >> 1);
  420. n |= (n >> 2);
  421. n |= (n >> 4);
  422. n |= (n >> 8);
  423. n |= (n >> 16);
  424. return n + 1;
  425. }
  426. /** Returns the index of the highest set bit in a (non-zero) number.
  427. So for n=3 this would return 1, for n=7 it returns 2, etc.
  428. An input value of 0 is illegal!
  429. */
  430. int findHighestSetBit (uint32 n) noexcept;
  431. /** Returns the number of bits in a 32-bit integer. */
  432. inline int countNumberOfBits (uint32 n) noexcept
  433. {
  434. n -= ((n >> 1) & 0x55555555);
  435. n = (((n >> 2) & 0x33333333) + (n & 0x33333333));
  436. n = (((n >> 4) + n) & 0x0f0f0f0f);
  437. n += (n >> 8);
  438. n += (n >> 16);
  439. return (int) (n & 0x3f);
  440. }
  441. /** Returns the number of bits in a 64-bit integer. */
  442. inline int countNumberOfBits (uint64 n) noexcept
  443. {
  444. return countNumberOfBits ((uint32) n) + countNumberOfBits ((uint32) (n >> 32));
  445. }
  446. /** Performs a modulo operation, but can cope with the dividend being negative.
  447. The divisor must be greater than zero.
  448. */
  449. template <typename IntegerType>
  450. IntegerType negativeAwareModulo (IntegerType dividend, const IntegerType divisor) noexcept
  451. {
  452. jassert (divisor > 0);
  453. dividend %= divisor;
  454. return (dividend < 0) ? (dividend + divisor) : dividend;
  455. }
  456. /** Returns the square of its argument. */
  457. template <typename NumericType>
  458. NumericType square (NumericType n) noexcept
  459. {
  460. return n * n;
  461. }
  462. //==============================================================================
  463. /** Writes a number of bits into a memory buffer at a given bit index.
  464. The buffer is treated as a sequence of 8-bit bytes, and the value is encoded in little-endian order,
  465. so for example if startBit = 10, and numBits = 11 then the lower 6 bits of the value would be written
  466. into bits 2-8 of targetBuffer[1], and the upper 5 bits of value into bits 0-5 of targetBuffer[2].
  467. @see readLittleEndianBitsInBuffer
  468. */
  469. void writeLittleEndianBitsInBuffer (void* targetBuffer, uint32 startBit, uint32 numBits, uint32 value) noexcept;
  470. /** Reads a number of bits from a buffer at a given bit index.
  471. The buffer is treated as a sequence of 8-bit bytes, and the value is encoded in little-endian order,
  472. so for example if startBit = 10, and numBits = 11 then the lower 6 bits of the result would be read
  473. from bits 2-8 of sourceBuffer[1], and the upper 5 bits of the result from bits 0-5 of sourceBuffer[2].
  474. @see writeLittleEndianBitsInBuffer
  475. */
  476. uint32 readLittleEndianBitsInBuffer (const void* sourceBuffer, uint32 startBit, uint32 numBits) noexcept;
  477. //==============================================================================
  478. #if JUCE_INTEL || defined (DOXYGEN)
  479. /** This macro can be applied to a float variable to check whether it contains a denormalised
  480. value, and to normalise it if necessary.
  481. On CPUs that aren't vulnerable to denormalisation problems, this will have no effect.
  482. */
  483. #define JUCE_UNDENORMALISE(x) { (x) += 0.1f; (x) -= 0.1f; }
  484. #else
  485. #define JUCE_UNDENORMALISE(x)
  486. #endif
  487. //==============================================================================
  488. /** This namespace contains a few template classes for helping work out class type variations.
  489. */
  490. namespace TypeHelpers
  491. {
  492. /** The ParameterType struct is used to find the best type to use when passing some kind
  493. of object as a parameter.
  494. Of course, this is only likely to be useful in certain esoteric template situations.
  495. Because "typename TypeHelpers::ParameterType<SomeClass>::type" is a bit of a mouthful, there's
  496. a PARAMETER_TYPE(SomeClass) macro that you can use to get the same effect.
  497. E.g. "myFunction (PARAMETER_TYPE (int), PARAMETER_TYPE (MyObject))"
  498. would evaluate to "myfunction (int, const MyObject&)", keeping any primitive types as
  499. pass-by-value, but passing objects as a const reference, to avoid copying.
  500. */
  501. template <typename Type> struct ParameterType { typedef const Type& type; };
  502. #if ! DOXYGEN
  503. template <typename Type> struct ParameterType <Type&> { typedef Type& type; };
  504. template <typename Type> struct ParameterType <Type*> { typedef Type* type; };
  505. template <> struct ParameterType <char> { typedef char type; };
  506. template <> struct ParameterType <unsigned char> { typedef unsigned char type; };
  507. template <> struct ParameterType <short> { typedef short type; };
  508. template <> struct ParameterType <unsigned short> { typedef unsigned short type; };
  509. template <> struct ParameterType <int> { typedef int type; };
  510. template <> struct ParameterType <unsigned int> { typedef unsigned int type; };
  511. template <> struct ParameterType <long> { typedef long type; };
  512. template <> struct ParameterType <unsigned long> { typedef unsigned long type; };
  513. template <> struct ParameterType <int64> { typedef int64 type; };
  514. template <> struct ParameterType <uint64> { typedef uint64 type; };
  515. template <> struct ParameterType <bool> { typedef bool type; };
  516. template <> struct ParameterType <float> { typedef float type; };
  517. template <> struct ParameterType <double> { typedef double type; };
  518. #endif
  519. /** A helpful macro to simplify the use of the ParameterType template.
  520. @see ParameterType
  521. */
  522. #define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType<a>::type
  523. /** These templates are designed to take a type, and if it's a double, they return a double
  524. type; for anything else, they return a float type.
  525. */
  526. template <typename Type> struct SmallestFloatType { typedef float type; };
  527. template <> struct SmallestFloatType <double> { typedef double type; };
  528. }
  529. //==============================================================================
  530. #endif // JUCE_MATHSFUNCTIONS_H_INCLUDED