Audio plugin host https://kx.studio/carla
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.

227 lines
8.5KB

  1. /*
  2. * Standalone Juce AudioProcessorGraph
  3. * Copyright (C) 2015 ROLI Ltd.
  4. * Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  17. */
  18. #ifndef WATER_H_INCLUDED
  19. #define WATER_H_INCLUDED
  20. #include "CarlaDefines.h"
  21. //==============================================================================
  22. #define jassertfalse carla_safe_assert("jassertfalse triggered", __FILE__, __LINE__);
  23. #define jassert(expression) CARLA_SAFE_ASSERT(expression)
  24. #define static_jassert(expression) static_assert(expression, #expression);
  25. #if defined (__arm__) || defined (__arm64__)
  26. #define JUCE_ARM 1
  27. #else
  28. #define JUCE_INTEL 1
  29. #endif
  30. //==============================================================================
  31. // Compiler support
  32. #if (__cplusplus >= 201103L || defined (__GXX_EXPERIMENTAL_CXX0X__)) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
  33. #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1
  34. #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && ! defined (JUCE_DELETED_FUNCTION)
  35. #define JUCE_DELETED_FUNCTION = delete
  36. #endif
  37. #endif
  38. #if __clang__
  39. #if __has_feature (cxx_rvalue_references)
  40. #define JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS 1
  41. #endif
  42. #if __has_feature (cxx_deleted_functions)
  43. #define JUCE_DELETED_FUNCTION = delete
  44. #endif
  45. #ifndef JUCE_EXCEPTIONS_DISABLED
  46. #if ! __has_feature (cxx_exceptions)
  47. #define JUCE_EXCEPTIONS_DISABLED 1
  48. #endif
  49. #endif
  50. #endif
  51. //==============================================================================
  52. // Declare some fake versions of nullptr and noexcept, for older compilers:
  53. #ifndef JUCE_DELETED_FUNCTION
  54. /** This macro can be placed after a method declaration to allow the use of
  55. the C++11 feature "= delete" on all compilers.
  56. On newer compilers that support it, it does the C++11 "= delete", but on
  57. older ones it's just an empty definition.
  58. */
  59. #define JUCE_DELETED_FUNCTION
  60. #endif
  61. #define JUCE_PREVENT_HEAP_ALLOCATION CARLA_PREVENT_HEAP_ALLOCATION
  62. #define NEEDS_TRANS(x) (x)
  63. //==============================================================================
  64. namespace water
  65. {
  66. class AudioProcessor;
  67. class File;
  68. class FileInputStream;
  69. class FileOutputStream;
  70. class Identifier;
  71. class InputSource;
  72. class InputStream;
  73. class MidiBuffer;
  74. class MidiMessage;
  75. class MemoryBlock;
  76. class MemoryOutputStream;
  77. class NewLine;
  78. class OutputStream;
  79. class Result;
  80. class String;
  81. class StringArray;
  82. class StringRef;
  83. class Time;
  84. class XmlElement;
  85. class var;
  86. //==============================================================================
  87. // Definitions for the int8, int16, int32, int64 and pointer_sized_int types.
  88. /** A platform-independent 8-bit signed integer type. */
  89. typedef signed char int8;
  90. /** A platform-independent 8-bit unsigned integer type. */
  91. typedef unsigned char uint8;
  92. /** A platform-independent 16-bit signed integer type. */
  93. typedef signed short int16;
  94. /** A platform-independent 16-bit unsigned integer type. */
  95. typedef unsigned short uint16;
  96. /** A platform-independent 32-bit signed integer type. */
  97. typedef signed int int32;
  98. /** A platform-independent 32-bit unsigned integer type. */
  99. typedef unsigned int uint32;
  100. /** A platform-independent 64-bit integer type. */
  101. typedef long long int64;
  102. /** A platform-independent 64-bit unsigned integer type. */
  103. typedef unsigned long long uint64;
  104. #ifdef CARLA_64BIT
  105. /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  106. typedef int64 pointer_sized_int;
  107. /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  108. typedef uint64 pointer_sized_uint;
  109. #else
  110. /** A signed integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  111. typedef int pointer_sized_int;
  112. /** An unsigned integer type that's guaranteed to be large enough to hold a pointer without truncating it. */
  113. typedef unsigned int pointer_sized_uint;
  114. #endif
  115. //==============================================================================
  116. namespace NumberToStringConverters
  117. {
  118. enum
  119. {
  120. charsNeededForInt = 32,
  121. charsNeededForDouble = 48
  122. };
  123. template <typename Type>
  124. static char* printDigits (char* t, Type v) noexcept
  125. {
  126. *--t = 0;
  127. do
  128. {
  129. *--t = '0' + (char) (v % 10);
  130. v /= 10;
  131. } while (v > 0);
  132. return t;
  133. }
  134. // pass in a pointer to the END of a buffer..
  135. static char* numberToString (char* t, const int64 n) noexcept
  136. {
  137. if (n >= 0)
  138. return printDigits (t, static_cast<uint64> (n));
  139. // NB: this needs to be careful not to call -std::numeric_limits<int64>::min(),
  140. // which has undefined behaviour
  141. t = printDigits (t, static_cast<uint64> (-(n + 1)) + 1);
  142. *--t = '-';
  143. return t;
  144. }
  145. }
  146. //==============================================================================
  147. /** This namespace contains a few template classes for helping work out class type variations.
  148. */
  149. namespace TypeHelpers
  150. {
  151. /** The ParameterType struct is used to find the best type to use when passing some kind
  152. of object as a parameter.
  153. Of course, this is only likely to be useful in certain esoteric template situations.
  154. Because "typename TypeHelpers::ParameterType<SomeClass>::type" is a bit of a mouthful, there's
  155. a PARAMETER_TYPE(SomeClass) macro that you can use to get the same effect.
  156. E.g. "myFunction (PARAMETER_TYPE (int), PARAMETER_TYPE (MyObject))"
  157. would evaluate to "myfunction (int, const MyObject&)", keeping any primitive types as
  158. pass-by-value, but passing objects as a const reference, to avoid copying.
  159. */
  160. template <typename Type> struct ParameterType { typedef const Type& type; };
  161. template <typename Type> struct ParameterType <Type&> { typedef Type& type; };
  162. template <typename Type> struct ParameterType <Type*> { typedef Type* type; };
  163. template <> struct ParameterType <char> { typedef char type; };
  164. template <> struct ParameterType <unsigned char> { typedef unsigned char type; };
  165. template <> struct ParameterType <short> { typedef short type; };
  166. template <> struct ParameterType <unsigned short> { typedef unsigned short type; };
  167. template <> struct ParameterType <int> { typedef int type; };
  168. template <> struct ParameterType <unsigned int> { typedef unsigned int type; };
  169. template <> struct ParameterType <long> { typedef long type; };
  170. template <> struct ParameterType <unsigned long> { typedef unsigned long type; };
  171. template <> struct ParameterType <int64> { typedef int64 type; };
  172. template <> struct ParameterType <uint64> { typedef uint64 type; };
  173. template <> struct ParameterType <bool> { typedef bool type; };
  174. template <> struct ParameterType <float> { typedef float type; };
  175. template <> struct ParameterType <double> { typedef double type; };
  176. /** A helpful macro to simplify the use of the ParameterType template.
  177. @see ParameterType
  178. */
  179. #define PARAMETER_TYPE(a) typename TypeHelpers::ParameterType<a>::type
  180. /** These templates are designed to take a type, and if it's a double, they return a double
  181. type; for anything else, they return a float type.
  182. */
  183. template <typename Type> struct SmallestFloatType { typedef float type; };
  184. template <> struct SmallestFloatType <double> { typedef double type; };
  185. }
  186. }
  187. #endif // WATER_H_INCLUDED