1 /* SoX Resampler Library Copyright (c) 2007-18 robs@users.sourceforge.net 2 * Licence for this file: LGPL v2.1 See LICENCE for details. */ 3 4 /* Common includes etc. for the examples. */ 5 6 #include <assert.h> 7 #include <errno.h> 8 #include <limits.h> 9 #include <math.h> 10 #include <stddef.h> 11 #include <stdio.h> 12 #include <stdlib.h> 13 #include <string.h> 14 15 #ifdef _WIN32 16 /* Work-around for broken file-I/O on MS-Windows: */ 17 #include <io.h> 18 #include <fcntl.h> 19 #define USE_STD_STDIO _setmode(_fileno(stdout), _O_BINARY), \ 20 _setmode(_fileno(stdin ), _O_BINARY) 21 #else 22 #define USE_STD_STDIO 23 #endif 24 25 #undef int16_t 26 #define int16_t short 27 28 #undef int32_t 29 #if LONG_MAX > 2147483647L 30 #define int32_t int 31 #elif LONG_MAX < 2147483647L 32 #error this programme requires that 'long int' has at least 32-bits 33 #else 34 #define int32_t long 35 #endif 36 37 #undef min 38 #define min(x,y) ((x)<(y)?(x):(y)) 39 40 #undef max 41 #define max(x,y) ((x)>(y)?(x):(y)) 42 43 #undef AL 44 #define AL(a) (sizeof(a)/sizeof((a)[0])) /* Array Length */ 45 46 #undef M_PI /* Sometimes missing, so ensure that it is defined: */ 47 #define M_PI 3.14159265358979323846 48