michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: /// michael@0: /// Common type definitions for SoundTouch audio processing library. michael@0: /// michael@0: /// Author : Copyright (c) Olli Parviainen michael@0: /// Author e-mail : oparviai 'at' iki.fi michael@0: /// SoundTouch WWW: http://www.surina.net/soundtouch michael@0: /// michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // michael@0: // Last changed : $Date: 2014-04-06 10:57:21 -0500 (Sun, 06 Apr 2014) $ michael@0: // File revision : $Revision: 3 $ michael@0: // michael@0: // $Id: STTypes.h 195 2014-04-06 15:57:21Z oparviai $ michael@0: // michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: // michael@0: // License : michael@0: // michael@0: // SoundTouch audio processing library michael@0: // Copyright (c) Olli Parviainen michael@0: // michael@0: // This library is free software; you can redistribute it and/or michael@0: // modify it under the terms of the GNU Lesser General Public michael@0: // License as published by the Free Software Foundation; either michael@0: // version 2.1 of the License, or (at your option) any later version. michael@0: // michael@0: // This library is distributed in the hope that it will be useful, michael@0: // but WITHOUT ANY WARRANTY; without even the implied warranty of michael@0: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU michael@0: // Lesser General Public License for more details. michael@0: // michael@0: // You should have received a copy of the GNU Lesser General Public michael@0: // License along with this library; if not, write to the Free Software michael@0: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA michael@0: // michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: #ifndef STTypes_H michael@0: #define STTypes_H michael@0: michael@0: typedef unsigned int uint; michael@0: typedef unsigned long ulong; michael@0: michael@0: // Patch for MinGW: on Win64 long is 32-bit michael@0: #ifdef _WIN64 michael@0: typedef unsigned long long ulongptr; michael@0: #else michael@0: typedef ulong ulongptr; michael@0: #endif michael@0: michael@0: michael@0: // Helper macro for aligning pointer up to next 16-byte boundary michael@0: #define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 ) michael@0: michael@0: michael@0: #include "soundtouch_config.h" michael@0: michael@0: #ifdef WIN32 michael@0: #ifdef BUILDING_SOUNDTOUCH michael@0: #define EXPORT __declspec(dllexport) michael@0: #else michael@0: #define EXPORT __declspec(dllimport) michael@0: #endif michael@0: #else michael@0: #define EXPORT michael@0: #endif michael@0: michael@0: namespace soundtouch michael@0: { michael@0: /// Activate these undef's to overrule the possible sampletype michael@0: /// setting inherited from some other header file: michael@0: //#undef SOUNDTOUCH_INTEGER_SAMPLES michael@0: //#undef SOUNDTOUCH_FLOAT_SAMPLES michael@0: michael@0: /// If following flag is defined, always uses multichannel processing michael@0: /// routines also for mono and stero sound. This is for routine testing michael@0: /// purposes; output should be same with either routines, yet disabling michael@0: /// the dedicated mono/stereo processing routines will result in slower michael@0: /// runtime performance so recommendation is to keep this off. michael@0: // #define USE_MULTICH_ALWAYS michael@0: michael@0: #if (defined(__SOFTFP__)) michael@0: // For Android compilation: Force use of Integer samples in case that michael@0: // compilation uses soft-floating point emulation - soft-fp is way too slow michael@0: #undef SOUNDTOUCH_FLOAT_SAMPLES michael@0: #define SOUNDTOUCH_INTEGER_SAMPLES 1 michael@0: #endif michael@0: michael@0: #if !(SOUNDTOUCH_INTEGER_SAMPLES || SOUNDTOUCH_FLOAT_SAMPLES) michael@0: michael@0: /// Choose either 32bit floating point or 16bit integer sampletype michael@0: /// by choosing one of the following defines, unless this selection michael@0: /// has already been done in some other file. michael@0: //// michael@0: /// Notes: michael@0: /// - In Windows environment, choose the sample format with the michael@0: /// following defines. michael@0: /// - In GNU environment, the floating point samples are used by michael@0: /// default, but integer samples can be chosen by giving the michael@0: /// following switch to the configure script: michael@0: /// ./configure --enable-integer-samples michael@0: /// However, if you still prefer to select the sample format here michael@0: /// also in GNU environment, then please #undef the INTEGER_SAMPLE michael@0: /// and FLOAT_SAMPLE defines first as in comments above. michael@0: //#define SOUNDTOUCH_INTEGER_SAMPLES 1 //< 16bit integer samples michael@0: #define SOUNDTOUCH_FLOAT_SAMPLES 1 //< 32bit float samples michael@0: michael@0: #endif michael@0: michael@0: #if (_M_IX86 || __i386__ || __x86_64__ || _M_X64) michael@0: /// Define this to allow X86-specific assembler/intrinsic optimizations. michael@0: /// Notice that library contains also usual C++ versions of each of these michael@0: /// these routines, so if you're having difficulties getting the optimized michael@0: /// routines compiled for whatever reason, you may disable these optimizations michael@0: /// to make the library compile. michael@0: michael@0: #define SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS 1 michael@0: michael@0: /// In GNU environment, allow the user to override this setting by michael@0: /// giving the following switch to the configure script: michael@0: /// ./configure --disable-x86-optimizations michael@0: /// ./configure --enable-x86-optimizations=no michael@0: #ifdef SOUNDTOUCH_DISABLE_X86_OPTIMIZATIONS michael@0: #undef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS michael@0: #endif michael@0: #else michael@0: /// Always disable optimizations when not using a x86 systems. michael@0: #undef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS michael@0: michael@0: #endif michael@0: michael@0: // If defined, allows the SIMD-optimized routines to take minor shortcuts michael@0: // for improved performance. Undefine to require faithfully similar SIMD michael@0: // calculations as in normal C implementation. michael@0: #define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION 1 michael@0: michael@0: michael@0: #ifdef SOUNDTOUCH_INTEGER_SAMPLES michael@0: // 16bit integer sample type michael@0: typedef short SAMPLETYPE; michael@0: // data type for sample accumulation: Use 32bit integer to prevent overflows michael@0: typedef long LONG_SAMPLETYPE; michael@0: michael@0: #ifdef SOUNDTOUCH_FLOAT_SAMPLES michael@0: // check that only one sample type is defined michael@0: #error "conflicting sample types defined" michael@0: #endif // SOUNDTOUCH_FLOAT_SAMPLES michael@0: michael@0: #ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS michael@0: // Allow MMX optimizations michael@0: #define SOUNDTOUCH_ALLOW_MMX 1 michael@0: #endif michael@0: michael@0: #else michael@0: michael@0: // floating point samples michael@0: typedef float SAMPLETYPE; michael@0: // data type for sample accumulation: Use double to utilize full precision. michael@0: typedef double LONG_SAMPLETYPE; michael@0: michael@0: #ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS michael@0: // Allow SSE optimizations michael@0: #define SOUNDTOUCH_ALLOW_SSE 1 michael@0: #endif michael@0: michael@0: #endif // SOUNDTOUCH_INTEGER_SAMPLES michael@0: michael@0: }; michael@0: michael@0: // define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions: michael@0: #define ST_NO_EXCEPTION_HANDLING 1 michael@0: #ifdef ST_NO_EXCEPTION_HANDLING michael@0: // Exceptions disabled. Throw asserts instead if enabled. michael@0: #include michael@0: #define ST_THROW_RT_ERROR(x) {assert((const char *)x);} michael@0: #else michael@0: // use c++ standard exceptions michael@0: #include michael@0: #define ST_THROW_RT_ERROR(x) {throw std::runtime_error(x);} michael@0: #endif michael@0: michael@0: // When this #define is active, eliminates a clicking sound when the "rate" or "pitch" michael@0: // parameter setting crosses from value <1 to >=1 or vice versa during processing. michael@0: // Default is off as such crossover is untypical case and involves a slight sound michael@0: // quality compromise. michael@0: //#define SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER 1 michael@0: michael@0: #endif