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