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@150
|
7 This file copyright 2006 Chris Cannam.
|
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@150
|
19 #ifdef _WIN32
|
Chris@150
|
20
|
Chris@150
|
21 #include <windows.h>
|
Chris@150
|
22 #include <malloc.h>
|
Chris@150
|
23 #include <process.h>
|
Chris@150
|
24
|
Chris@150
|
25 #define MLOCK(a,b) 1
|
Chris@150
|
26 #define MUNLOCK(a,b) 1
|
Chris@150
|
27 #define MUNLOCK_SAMPLEBLOCK(a) 1
|
Chris@150
|
28
|
Chris@150
|
29 #define DLOPEN(a,b) LoadLibrary((a).toStdWString().c_str())
|
Chris@150
|
30 #define DLSYM(a,b) GetProcAddress((HINSTANCE)(a),(b))
|
Chris@150
|
31 #define DLCLOSE(a) FreeLibrary((HINSTANCE)(a))
|
Chris@150
|
32 #define DLERROR() ""
|
Chris@150
|
33
|
Chris@150
|
34 #define PLUGIN_GLOB "*.dll"
|
Chris@150
|
35 #define PATH_SEPARATOR ';'
|
Chris@150
|
36 #define DEFAULT_VAMP_PATH "%ProgramFiles%\\Vamp Plugins"
|
Chris@150
|
37
|
Chris@150
|
38 #define getpid _getpid
|
Chris@150
|
39
|
Chris@150
|
40 extern "C" {
|
Chris@150
|
41 void usleep(unsigned long usec);
|
Chris@150
|
42 void gettimeofday(struct timeval *p, void *tz);
|
Chris@150
|
43 }
|
Chris@150
|
44
|
Chris@150
|
45 #else
|
Chris@150
|
46
|
Chris@150
|
47 #include <sys/mman.h>
|
Chris@150
|
48 #include <dlfcn.h>
|
Chris@150
|
49
|
Chris@150
|
50 #define MLOCK(a,b) ::mlock((a),(b))
|
Chris@150
|
51 #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
|
Chris@150
|
52 #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
|
Chris@150
|
53
|
Chris@150
|
54 #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b))
|
Chris@150
|
55 #define DLSYM(a,b) dlsym((a),(b))
|
Chris@150
|
56 #define DLCLOSE(a) dlclose((a))
|
Chris@150
|
57 #define DLERROR() dlerror()
|
Chris@150
|
58
|
Chris@150
|
59 #define PATH_SEPARATOR ':'
|
Chris@150
|
60
|
Chris@150
|
61 #ifdef __APPLE__
|
Chris@150
|
62
|
Chris@150
|
63 #define PLUGIN_GLOB "*.dylib"
|
Chris@150
|
64 #define DEFAULT_VAMP_PATH "/Library/Audio/Plug-Ins/Vamp/:$HOME/Library/Audio/Plug-Ins/Vamp"
|
Chris@150
|
65
|
Chris@150
|
66 #else
|
Chris@150
|
67
|
Chris@150
|
68 #define PLUGIN_GLOB "*.so"
|
Chris@150
|
69 #define DEFAULT_VAMP_PATH "/usr/local/lib/vamp:/usr/lib/vamp:$HOME/vamp:$HOME/.vamp"
|
Chris@150
|
70
|
Chris@150
|
71 #endif /* __APPLE__ */
|
Chris@150
|
72
|
Chris@150
|
73 #endif /* ! _WIN32 */
|
Chris@150
|
74
|
Chris@150
|
75 enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
|
Chris@150
|
76 extern ProcessStatus GetProcessStatus(int pid);
|
Chris@150
|
77
|
Chris@168
|
78 // Return a vague approximation to the number of free megabytes of real memory.
|
Chris@168
|
79 // Return -1 if unknown.
|
Chris@170
|
80 extern void GetRealMemoryMBAvailable(int &available, int &total);
|
Chris@168
|
81
|
Chris@168
|
82 // Return a vague approximation to the number of free megabytes of disc space
|
Chris@168
|
83 // on the partition containing the given path. Return -1 if unknown.
|
Chris@168
|
84 extern int GetDiscSpaceMBAvailable(const char *path);
|
Chris@168
|
85
|
Chris@150
|
86 #include <cmath>
|
Chris@150
|
87
|
Chris@150
|
88 extern double mod(double x, double y);
|
Chris@150
|
89 extern float modf(float x, float y);
|
Chris@150
|
90
|
Chris@150
|
91 extern double princarg(double a);
|
Chris@150
|
92 extern float princargf(float a);
|
Chris@150
|
93
|
Chris@150
|
94 #endif /* ! _SYSTEM_H_ */
|
Chris@150
|
95
|
Chris@150
|
96
|