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.

217 lines
7.1 KiB

3 years ago
  1. /**********************************************************************
  2. Audacity: A Digital Audio Editor
  3. Audacity(R) is copyright (c) 1999-2015 Audacity Team.
  4. License: GPL v2. See License.txt.
  5. Audacity.h
  6. Dominic Mazzoni
  7. Joshua Haberman
  8. Vaughan Johnson
  9. et alii
  10. ********************************************************************//*!
  11. \file Audacity.h
  12. This is the main include file for Audacity. All files which need
  13. any Audacity-specific \#defines or need to access any of Audacity's
  14. global functions should \#include this file.
  15. *//********************************************************************/
  16. #ifndef __AUDACITY_H__
  17. #define __AUDACITY_H__
  18. // We only do alpha builds, beta builds, and release versions.
  19. // Most of the time we're in development, so AUDACITY_BUILD_LEVEL should be
  20. // defined to 0.
  21. // Its value may be more than 0 for pre-release "Beta" builds that differ only
  22. // in the welcome screen, and hiding of some development menu commands, but
  23. // still link to the alpha manual online.
  24. #define AUDACITY_BUILD_LEVEL 0
  25. // used #ifdef not #if for IS_ALPHA, IS_BETA, IS_RELEASE, USE_ALPHA_MANUAL
  26. #undef IS_ALPHA
  27. #undef IS_BETA
  28. #undef IS_RELEASE
  29. #undef USE_ALPHA_MANUAL
  30. #if AUDACITY_BUILD_LEVEL == 0
  31. #define IS_ALPHA
  32. #define USE_ALPHA_MANUAL
  33. #elif AUDACITY_BUILD_LEVEL == 1
  34. #define IS_BETA
  35. #define USE_ALPHA_MANUAL
  36. #else
  37. #define IS_RELEASE
  38. #endif
  39. // Increment as appropriate every time we release a NEW version.
  40. #define AUDACITY_VERSION 3
  41. #define AUDACITY_RELEASE 0
  42. #define AUDACITY_REVISION 3
  43. #define AUDACITY_MODLEVEL 0
  44. #if defined(IS_BETA)
  45. #define AUDACITY_SUFFIX wxT("-beta-") __TDATE__
  46. #elif defined(IS_ALPHA)
  47. #define AUDACITY_SUFFIX wxT("-alpha-") __TDATE__
  48. #else
  49. #define AUDACITY_SUFFIX wxT("") // for a stable release
  50. //#define AUDACITY_SUFFIX wxT("x ") __TDATE__
  51. #endif
  52. #define AUDACITY_MAKESTR( x ) #x
  53. #define AUDACITY_QUOTE( x ) AUDACITY_MAKESTR( x )
  54. // Version string for visual display
  55. #define AUDACITY_VERSION_STRING wxT( AUDACITY_QUOTE( AUDACITY_VERSION ) ) wxT(".") \
  56. wxT( AUDACITY_QUOTE( AUDACITY_RELEASE ) ) wxT(".") \
  57. wxT( AUDACITY_QUOTE( AUDACITY_REVISION ) ) \
  58. AUDACITY_SUFFIX
  59. // DA: x on end of version string.
  60. #ifdef EXPERIMENTAL_DA
  61. // Version string for file info (under Windows)
  62. #define AUDACITY_FILE_VERSION AUDACITY_QUOTE( AUDACITY_VERSION ) "," \
  63. AUDACITY_QUOTE( AUDACITY_RELEASE ) "," \
  64. AUDACITY_QUOTE( AUDACITY_REVISION ) "," \
  65. AUDACITY_QUOTE( AUDACITY_MODLEVEL ) " x"
  66. #else
  67. #define AUDACITY_FILE_VERSION AUDACITY_QUOTE( AUDACITY_VERSION ) "," \
  68. AUDACITY_QUOTE( AUDACITY_RELEASE ) "," \
  69. AUDACITY_QUOTE( AUDACITY_REVISION ) "," \
  70. AUDACITY_QUOTE( AUDACITY_MODLEVEL )
  71. #endif
  72. // Increment this every time the prefs need to be reset
  73. // the first part (before the r) indicates the version the reset took place
  74. // the second part (after the r) indicates the number of times the prefs have been reset within the same version
  75. #define AUDACITY_PREFS_VERSION_STRING "1.1.1r1"
  76. // Don't change this unless the file format changes
  77. // in an irrevocable way
  78. #define AUDACITY_FILE_FORMAT_VERSION "1.3.0"
  79. class wxWindow;
  80. // Please try to support unlimited path length instead of using PLATFORM_MAX_PATH!
  81. // Define one constant for maximum path value, so we don't have to do
  82. // platform-specific conditionals everywhere we want to check it.
  83. #define PLATFORM_MAX_PATH 260 // Play it safe for default, with same value as Windows' MAX_PATH.
  84. #ifdef __WXMAC__
  85. #include "configmac.h"
  86. #undef PLATFORM_MAX_PATH
  87. #define PLATFORM_MAX_PATH PATH_MAX
  88. #endif
  89. #ifdef __WXGTK__
  90. #ifndef __CONFIG_UNIX_INCLUDED
  91. #define __CONFIG_UNIX_INCLUDED
  92. #include "configunix.h"
  93. #endif
  94. // Some systems do not restrict the path length and therefore PATH_MAX is undefined
  95. #ifdef PATH_MAX
  96. #undef PLATFORM_MAX_PATH
  97. #define PLATFORM_MAX_PATH PATH_MAX
  98. #endif
  99. #endif
  100. #ifdef __WXX11__
  101. #ifndef __CONFIG_UNIX_INCLUDED
  102. #define __CONFIG_UNIX_INCLUDED
  103. #include "configunix.h"
  104. #endif
  105. // wxX11 should also get the platform-specific definition of PLATFORM_MAX_PATH, so do not declare here.
  106. #endif
  107. #ifdef __WXMSW__
  108. #include "configwin.h"
  109. #undef PLATFORM_MAX_PATH
  110. #define PLATFORM_MAX_PATH MAX_PATH
  111. #endif
  112. /* The dynamic library import and export for Microsoft Windows.
  113. * Supported by Visual Studio and for GCC 4+ */
  114. #if defined _WIN32 || (defined __CYGWIN__ && defined __GNUC__)
  115. #ifndef AUDACITY_DLL_API
  116. #ifdef BUILDING_AUDACITY
  117. #define AUDACITY_DLL_API __declspec(dllexport)
  118. #else
  119. #ifdef _DLL
  120. #define AUDACITY_DLL_API __declspec(dllimport)
  121. #else
  122. #define AUDACITY_DLL_API
  123. #endif
  124. #endif
  125. #endif
  126. #endif //_WIN32 || (__CYGWIN__ && __GNUC__)
  127. // Put extra symbol information in the release build, for the purpose of gathering
  128. // profiling information (as from Windows Process Monitor), when there otherwise
  129. // isn't a need for AUDACITY_DLL_API.
  130. #ifdef IS_ALPHA
  131. #define PROFILE_DLL_API AUDACITY_DLL_API
  132. #else
  133. #define PROFILE_DLL_API
  134. #endif
  135. /* The GCC-elf implementation */
  136. #ifdef HAVE_VISIBILITY // this is provided by the configure script, is only
  137. // enabled for suitable GCC versions
  138. /* The incantation is a bit weird here because it uses ELF symbol stuff. If we
  139. * make a symbol "default" it makes it visible (for import or export). Making it
  140. * "hidden" means it is invisible outside the shared object. */
  141. #ifndef AUDACITY_DLL_API
  142. #ifdef BUILDING_AUDACITY
  143. #define AUDACITY_DLL_API __attribute__((visibility("default")))
  144. #else
  145. #define AUDACITY_DLL_API __attribute__((visibility("default")))
  146. #endif
  147. #endif
  148. #endif
  149. // These macros are used widely, so declared here.
  150. #define QUANTIZED_TIME(time, rate) (floor(((double)(time) * (rate)) + 0.5) / (rate))
  151. // dB - linear amplitude conversions
  152. #define DB_TO_LINEAR(x) (pow(10.0, (x) / 20.0))
  153. #define LINEAR_TO_DB(x) (20.0 * log10(x))
  154. #define MAX_AUDIO (1. - 1./(1<<15))
  155. #define JUST_BELOW_MAX_AUDIO (1.f - 1.f/(1<<14))
  156. // This renames a good use of this C++ keyword that we don't need to review when hunting for leaks.
  157. #define PROHIBITED = delete
  158. // Reviewed, certified, non-leaky uses of NEW that immediately entrust their results to RAII objects.
  159. // You may use it in NEW code when constructing a wxWindow subclass with non-NULL parent window.
  160. // You may use it in NEW code when the NEW expression is the constructor argument for a standard smart
  161. // pointer like std::unique_ptr or std::shared_ptr.
  162. #define safenew new
  163. // Right to left languages fail in many wx3 dialogs with missing buttons.
  164. // The workaround is to use LTR in those dialogs.
  165. #ifndef __WXMAC__
  166. #define RTL_WORKAROUND( pWnd ) \
  167. if ( gPrefs->Read( "/GUI/RtlWorkaround", true) ) \
  168. pWnd->SetLayoutDirection(wxLayout_LeftToRight);
  169. #else
  170. #define RTL_WORKAROUND( pWnd )
  171. #endif
  172. // Define/undefine _DEBUG based on the (CMake provided) NDEBUG symbol
  173. #if defined(NDEBUG)
  174. #undef _DEBUG
  175. #else
  176. #define _DEBUG 1
  177. #endif
  178. #endif // __AUDACITY_H__