annotate system/System.h @ 823:f0558e69a074

Rename Resampling- to DecodingWavFileReader, and use it whenever we have an audio file that is not quickly seekable using libsndfile. Avoids very slow performance when analysing ogg files.
author Chris Cannam
date Wed, 17 Jul 2013 15:40:01 +0100
parents 001d77a720ce
children 1d439494604c
rev   line source
Chris@150 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@150 2
Chris@150 3 /*
Chris@150 4 Sonic Visualiser
Chris@150 5 An audio file viewer and annotation editor.
Chris@150 6 Centre for Digital Music, Queen Mary, University of London.
Chris@202 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@150 8
Chris@150 9 This program is free software; you can redistribute it and/or
Chris@150 10 modify it under the terms of the GNU General Public License as
Chris@150 11 published by the Free Software Foundation; either version 2 of the
Chris@150 12 License, or (at your option) any later version. See the file
Chris@150 13 COPYING included with this distribution for more information.
Chris@150 14 */
Chris@150 15
Chris@150 16 #ifndef _SYSTEM_H_
Chris@150 17 #define _SYSTEM_H_
Chris@150 18
Chris@687 19 #include "base/Debug.h"
Chris@687 20
Chris@150 21 #ifdef _WIN32
Chris@150 22
Chris@150 23 #include <windows.h>
Chris@150 24 #include <malloc.h>
Chris@150 25 #include <process.h>
Chris@606 26 #include <math.h>
Chris@150 27
Chris@150 28 #define MLOCK(a,b) 1
Chris@150 29 #define MUNLOCK(a,b) 1
Chris@150 30 #define MUNLOCK_SAMPLEBLOCK(a) 1
Chris@368 31 #define MUNLOCKALL() 1
Chris@150 32
Chris@150 33 #define DLOPEN(a,b) LoadLibrary((a).toStdWString().c_str())
Chris@150 34 #define DLSYM(a,b) GetProcAddress((HINSTANCE)(a),(b))
Chris@223 35 #define DLCLOSE(a) (!FreeLibrary((HINSTANCE)(a)))
Chris@150 36 #define DLERROR() ""
Chris@150 37
Chris@150 38 #define PLUGIN_GLOB "*.dll"
Chris@223 39 #define PATH_SEPARATOR ';'
Chris@186 40
Chris@219 41 // The default Vamp plugin path is obtained from a function in the
Chris@219 42 // Vamp SDK (Vamp::PluginHostAdapter::getPluginPath).
Chris@186 43
Chris@219 44 // At the time of writing, at least, the vast majority of LADSPA
Chris@219 45 // plugins on Windows hosts will have been put there for use in
Chris@219 46 // Audacity. It's a bit of a shame that Audacity uses its own Program
Chris@219 47 // Files directory for plugins that any host may want to use... maybe
Chris@219 48 // they were just following the example of VSTs, which are usually
Chris@219 49 // found in Steinberg's Program Files directory. Anyway, we can
Chris@219 50 // greatly increase our chances of picking up some LADSPA plugins by
Chris@219 51 // default if we include the Audacity plugin location as well as an
Chris@219 52 // (imho) more sensible place.
Chris@219 53
Chris@223 54 #define DEFAULT_LADSPA_PATH "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins"
Chris@186 55 #define DEFAULT_DSSI_PATH "%ProgramFiles%\\DSSI Plugins"
Chris@150 56
Chris@150 57 #define getpid _getpid
Chris@150 58
Chris@150 59 extern "C" {
Chris@765 60 /* usleep is now in mingw
Chris@150 61 void usleep(unsigned long usec);
Chris@765 62 */
Chris@501 63 int gettimeofday(struct timeval *p, void *tz);
Chris@150 64 }
Chris@150 65
Chris@765 66 #define ISNAN std::isnan
Chris@765 67 #define ISINF std::isinf
Chris@606 68
Chris@150 69 #else
Chris@150 70
Chris@150 71 #include <sys/mman.h>
Chris@150 72 #include <dlfcn.h>
Chris@602 73 #include <stdio.h> // for perror
Chris@606 74 #include <cmath>
Chris@150 75
Chris@150 76 #define MLOCK(a,b) ::mlock((a),(b))
Chris@150 77 #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
Chris@150 78 #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
Chris@232 79 //#define MLOCK(a,b) 1
Chris@232 80 //#define MUNLOCK(a,b) 1
Chris@232 81 //#define MUNLOCK_SAMPLEBLOCK(a) 1
Chris@150 82
Chris@150 83 #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b))
Chris@150 84 #define DLSYM(a,b) dlsym((a),(b))
Chris@150 85 #define DLCLOSE(a) dlclose((a))
Chris@150 86 #define DLERROR() dlerror()
Chris@150 87
Chris@606 88 #include <cmath>
Chris@606 89 #define ISNAN std::isnan
Chris@606 90 #define ISINF std::isinf
Chris@606 91
Chris@150 92 #ifdef __APPLE__
Chris@150 93
Chris@255 94 #define PLUGIN_GLOB "*.dylib *.so"
Chris@223 95 #define PATH_SEPARATOR ':'
Chris@186 96
Chris@186 97 #define DEFAULT_LADSPA_PATH "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA"
Chris@186 98 #define DEFAULT_DSSI_PATH "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI"
Chris@150 99
Chris@368 100 #define MUNLOCKALL() 1
Chris@368 101
Chris@150 102 #else
Chris@150 103
Chris@606 104 #ifdef sun
Chris@606 105 #undef MLOCK
Chris@606 106 #undef MUNLOCK
Chris@606 107 #define MLOCK(a,b) ::mlock((char *)a,b)
Chris@606 108 #define MUNLOCK(a,b) ::munlock((char *)a,b)
Chris@606 109 #ifdef __SUNPRO_CC
Chris@606 110 #undef ISNAN
Chris@606 111 #undef ISINF
Chris@606 112 #define ISNAN(x) ((x)!=(x))
Chris@606 113 #define ISINF(x) 0
Chris@606 114 #endif
Chris@606 115 #endif
Chris@606 116
Chris@150 117 #define PLUGIN_GLOB "*.so"
Chris@223 118 #define PATH_SEPARATOR ':'
Chris@186 119
Chris@186 120 #define DEFAULT_LADSPA_PATH "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa"
Chris@186 121 #define DEFAULT_DSSI_PATH "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi"
Chris@150 122
Chris@368 123 #define MUNLOCKALL() ::munlockall()
Chris@368 124
Chris@150 125 #endif /* __APPLE__ */
Chris@150 126
Chris@150 127 #endif /* ! _WIN32 */
Chris@150 128
Chris@150 129 enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
Chris@150 130 extern ProcessStatus GetProcessStatus(int pid);
Chris@150 131
Chris@168 132 // Return a vague approximation to the number of free megabytes of real memory.
Chris@168 133 // Return -1 if unknown.
Chris@170 134 extern void GetRealMemoryMBAvailable(int &available, int &total);
Chris@168 135
Chris@168 136 // Return a vague approximation to the number of free megabytes of disc space
Chris@168 137 // on the partition containing the given path. Return -1 if unknown.
Chris@168 138 extern int GetDiscSpaceMBAvailable(const char *path);
Chris@168 139
Chris@303 140 extern void StoreStartupLocale();
Chris@303 141 extern void RestoreStartupLocale();
Chris@303 142
Chris@150 143 #include <cmath>
Chris@150 144
Chris@150 145 extern double mod(double x, double y);
Chris@150 146 extern float modf(float x, float y);
Chris@150 147
Chris@150 148 extern double princarg(double a);
Chris@150 149 extern float princargf(float a);
Chris@150 150
Chris@573 151 #ifdef USE_POW_NO_F
Chris@573 152 #define powf pow
Chris@573 153 #endif
Chris@573 154
Chris@150 155 #endif /* ! _SYSTEM_H_ */
Chris@150 156
Chris@150 157