Mercurial > hg > easaier-soundaccess
view system/System.h @ 282:d9319859a4cf tip
(none)
author | benoitrigolleau |
---|---|
date | Fri, 31 Oct 2008 11:00:24 +0000 |
parents | be6d31baecb9 |
children |
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ /* Sonic Visualiser An audio file viewer and annotation editor. Centre for Digital Music, Queen Mary, University of London. This file copyright 2006 Chris Cannam and QMUL. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information. */ #ifndef _SYSTEM_H_ #define _SYSTEM_H_ //#include <cmath> #ifdef _WIN32 #include <windows.h> #include <malloc.h> #include <process.h> #ifdef USE_VC #include <time.h> #include <io.h> #include <math.h> #include <float.h> #ifndef MIN #define MIN(x, y) min(x, y) #endif #ifndef MAX #define MAX(x, y) max(x, y) #endif #ifndef ISNAN #define ISNAN(x) isnan((x)) #endif #ifndef ISINF #define ISINF(x) isinf((x)) #endif typedef int WINBOOL; typedef signed char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef long ssize_t; typedef unsigned short mode_t; #define _S_IWUSR _S_IWRITE #define _S_IRUSR _S_IREAD #define S_IRUSR _S_IRUSR #define S_IWUSR _S_IWUSR /* If we're not using GNU C, elide __attribute__ */ #ifndef __GNUC__ # define __attribute__(x) /*NOTHING*/ #endif /* Win32 doesn't seem to have these functions. ** Therefore implement inline versions of these functions here. */ __inline long int lrint (double flt) { int intgr; _asm { fld flt fistp intgr } ; return intgr ; } __inline long int lrintf (float flt) { int intgr; _asm { fld flt fistp intgr } ; return intgr ; } __inline double nearbyint(double x) { unsigned int tmpMSW1; unsigned int tmpMSW2; __asm { // get current state fnstcw tmpMSW1 } // set bit 5 tmpMSW2 = tmpMSW1 | 0x00000020; __asm { // and load fldcw tmpMSW2 // do the job fld x frndint // clear exception fclex // restore old state fldcw tmpMSW1 } } #ifndef isinf #define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \ : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0)) #endif /* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */ #ifndef isnan #define isnan(d) (_isnan(d)) #endif #define ftruncate _chsize #else /*USE_VC*/ #include <sys/time.h> #include <stdint.h> #endif /*USE_VC*/ #define MLOCK(a,b) 1 #define MUNLOCK(a,b) 1 #define MUNLOCK_SAMPLEBLOCK(a) 1 #define DLOPEN(a,b) LoadLibrary((a).toStdWString().c_str()) #define DLSYM(a,b) GetProcAddress((HINSTANCE)(a),(b)) #define DLCLOSE(a) (!FreeLibrary((HINSTANCE)(a))) #define DLERROR() "" #define PLUGIN_GLOB "*.dll" #define PATH_SEPARATOR ';' // The default Vamp plugin path is obtained from a function in the // Vamp SDK (Vamp::PluginHostAdapter::getPluginPath). // At the time of writing, at least, the vast majority of LADSPA // plugins on Windows hosts will have been put there for use in // Audacity. It's a bit of a shame that Audacity uses its own Program // Files directory for plugins that any host may want to use... maybe // they were just following the example of VSTs, which are usually // found in Steinberg's Program Files directory. Anyway, we can // greatly increase our chances of picking up some LADSPA plugins by // default if we include the Audacity plugin location as well as an // (imho) more sensible place. #define DEFAULT_LADSPA_PATH "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins" #define DEFAULT_DSSI_PATH "%ProgramFiles%\\DSSI Plugins" #define getpid _getpid extern "C" { void usleep(unsigned long usec); void gettimeofday(struct timeval *p, void *tz); } #else /* ! _WIN32 */ #include <sys/time.h> #include <stdint.h> #include <sys/mman.h> #include <dlfcn.h> #define MLOCK(a,b) ::mlock((a),(b)) #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0) #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0); //#define MLOCK(a,b) 1 //#define MUNLOCK(a,b) 1 //#define MUNLOCK_SAMPLEBLOCK(a) 1 #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b)) #define DLSYM(a,b) dlsym((a),(b)) #define DLCLOSE(a) dlclose((a)) #define DLERROR() dlerror() #ifdef __APPLE__ #define PLUGIN_GLOB "*.dylib *.so" #define PATH_SEPARATOR ':' #define DEFAULT_LADSPA_PATH "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA" #define DEFAULT_DSSI_PATH "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI" #else #define PLUGIN_GLOB "*.so" #define PATH_SEPARATOR ':' #define DEFAULT_LADSPA_PATH "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa" #define DEFAULT_DSSI_PATH "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi" #endif /* __APPLE__ */ #endif /* ! _WIN32 */ #include <cmath> #include <algorithm> #ifdef __GNUC__ #ifndef MIN #define MIN(x, y) std::min(x, y) #endif #ifndef MAX #define MAX(x, y) std::max(x, y) #endif #ifndef ISNAN #define ISNAN(x) std::isnan((x)) #endif #ifndef ISINF #define ISINF(x) std::isinf((x)) #endif #endif /* __GNUC__ */ enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus }; extern ProcessStatus GetProcessStatus(int pid); // Return a vague approximation to the number of free megabytes of real memory. // Return -1 if unknown. extern void GetRealMemoryMBAvailable(int &available, int &total); // Return a vague approximation to the number of free megabytes of disc space // on the partition containing the given path. Return -1 if unknown. extern int GetDiscSpaceMBAvailable(const char *path); //#include <cmath> extern double mod(double x, double y); extern float modf(float x, float y); extern double princarg(double a); extern float princargf(float a); #endif /* ! _SYSTEM_H_ */