Marsyas
0.6.0-alpha
|
00001 #ifndef MARSYAS_COMMONHEADER_H 00002 #define MARSYAS_COMMONHEADER_H 00003 00014 /************************************************************************/ 00015 /* common includes */ 00016 /************************************************************************/ 00017 00018 #include <marsyas/types.h> 00019 #include <marsyas/MrsLog.h> 00020 00021 #include <cstdio> 00022 #include <sys/types.h> 00023 #include <complex> 00024 #include <limits> 00025 #include <cassert> 00026 00027 /************************************************************************/ 00028 /* common constants */ 00029 /************************************************************************/ 00030 namespace Marsyas 00031 { 00032 // constants 00033 const mrs_natural MRS_DEFAULT_SLICE_NSAMPLES = 512; 00034 const mrs_natural MRS_DEFAULT_SLICE_NOBSERVATIONS = 1; 00035 const mrs_real MRS_DEFAULT_SLICE_SRATE = 22050.0; 00036 00037 const mrs_natural FFT_FORWARD = 1; 00038 const mrs_natural FFT_INVERSE = 0; 00039 00040 const mrs_string EMPTYSTRING = "MARSYAS_EMPTY"; 00041 #undef max //WTF?? 00042 #undef min //WTF?? 00043 00044 const mrs_real MAXREAL = std::numeric_limits<mrs_real>::max(); 00045 const mrs_real MINREAL = std::numeric_limits<mrs_real>::min(); 00046 const mrs_natural MAXNATURAL = std::numeric_limits<mrs_natural>::max(); 00047 const mrs_natural MINNATURAL = std::numeric_limits<mrs_natural>::min(); 00048 00049 // double precision 00050 #ifdef PI 00051 #undef PI //to avoid clashes with other macros defined for PI in other libs... 00052 #endif 00053 const mrs_real PI = 3.14159265358979323846; 00054 const mrs_real TWOPI = 6.28318530717958647692; 00055 00056 00057 } //namespace Marsyas 00058 00059 /************************************************************************/ 00060 /* common defines */ 00061 /************************************************************************/ 00062 00063 //used for PCM audio => should not be changed! 00064 #define PCM_MAXSHRT 32767 00065 #define PCM_FMAXSHRT 32767.0f 00066 #define PCM_MAXINT 2147483647 00067 #define PCM_FMAXINT 2147483647.0f 00068 00069 #ifndef NDEBUG 00070 #define MARSYAS_ASSERTS 00071 #endif 00072 00073 #define MRSASSERT(f) assert(f); 00074 00075 #define MRSERR(x) {std::ostringstream oss; MrsLog::mrsErr((std::ostringstream&)(oss << x));} 00076 00077 #define MRSWARN(x) {std::ostringstream oss; MrsLog::mrsWarning((std::ostringstream&)(oss << x));} 00078 00079 #define MRS_WARNINGS_OFF MrsLog::warnings_off_ = true; 00080 #define MRS_WARNINGS_ON MrsLog::warnings_off_ = false; 00081 #define MRS_MESSAGES_OFF MrsLog::messages_off_ = true; 00082 #define MRS_MESSAGES_ON MrsLog::messages_off_ = false; 00083 00084 // Macros for marking functions as deprecated. 00085 // DEPRECATED(void OldFunc(int a, float b)); 00086 00087 #ifdef __GNUC__ 00088 #define DEPRECATED(func) func __attribute__ ((deprecated)) 00089 #elif defined(_MSC_VER) 00090 #define DEPRECATED(func) __declspec(deprecated) func 00091 #else 00092 #pragma message("WARNING: You need to implement DEPRECATED for this compiler") 00093 #define DEPRECATED(func) func 00094 #endif 00095 00096 #if defined(_MSC_VER) 00097 # define MARSYAS_ALIGN(X) __declspec(align(X)) 00098 #elif defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)) 00099 # define MARSYAS_ALIGN(X) __attribute__ ((aligned (X))) 00100 #else 00101 # define MARSYAS_ALIGN(X) alignas(X) 00102 #endif 00103 00104 #endif /* !MARSYAS_COMMONHEADER_H */ 00105