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@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@368
|
28 #define MUNLOCKALL() 1
|
Chris@150
|
29
|
Chris@150
|
30 #define DLOPEN(a,b) LoadLibrary((a).toStdWString().c_str())
|
Chris@150
|
31 #define DLSYM(a,b) GetProcAddress((HINSTANCE)(a),(b))
|
Chris@223
|
32 #define DLCLOSE(a) (!FreeLibrary((HINSTANCE)(a)))
|
Chris@150
|
33 #define DLERROR() ""
|
Chris@150
|
34
|
Chris@150
|
35 #define PLUGIN_GLOB "*.dll"
|
Chris@223
|
36 #define PATH_SEPARATOR ';'
|
Chris@186
|
37
|
Chris@219
|
38 // The default Vamp plugin path is obtained from a function in the
|
Chris@219
|
39 // Vamp SDK (Vamp::PluginHostAdapter::getPluginPath).
|
Chris@186
|
40
|
Chris@219
|
41 // At the time of writing, at least, the vast majority of LADSPA
|
Chris@219
|
42 // plugins on Windows hosts will have been put there for use in
|
Chris@219
|
43 // Audacity. It's a bit of a shame that Audacity uses its own Program
|
Chris@219
|
44 // Files directory for plugins that any host may want to use... maybe
|
Chris@219
|
45 // they were just following the example of VSTs, which are usually
|
Chris@219
|
46 // found in Steinberg's Program Files directory. Anyway, we can
|
Chris@219
|
47 // greatly increase our chances of picking up some LADSPA plugins by
|
Chris@219
|
48 // default if we include the Audacity plugin location as well as an
|
Chris@219
|
49 // (imho) more sensible place.
|
Chris@219
|
50
|
Chris@223
|
51 #define DEFAULT_LADSPA_PATH "%ProgramFiles%\\LADSPA Plugins;%ProgramFiles%\\Audacity\\Plug-Ins"
|
Chris@186
|
52 #define DEFAULT_DSSI_PATH "%ProgramFiles%\\DSSI Plugins"
|
Chris@150
|
53
|
Chris@150
|
54 #define getpid _getpid
|
Chris@150
|
55
|
Chris@150
|
56 extern "C" {
|
Chris@150
|
57 void usleep(unsigned long usec);
|
Chris@501
|
58 int gettimeofday(struct timeval *p, void *tz);
|
Chris@150
|
59 }
|
Chris@150
|
60
|
Chris@150
|
61 #else
|
Chris@150
|
62
|
Chris@150
|
63 #include <sys/mman.h>
|
Chris@150
|
64 #include <dlfcn.h>
|
Chris@602
|
65 #include <stdio.h> // for perror
|
Chris@150
|
66
|
Chris@150
|
67 #define MLOCK(a,b) ::mlock((a),(b))
|
Chris@150
|
68 #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
|
Chris@150
|
69 #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
|
Chris@232
|
70 //#define MLOCK(a,b) 1
|
Chris@232
|
71 //#define MUNLOCK(a,b) 1
|
Chris@232
|
72 //#define MUNLOCK_SAMPLEBLOCK(a) 1
|
Chris@150
|
73
|
Chris@150
|
74 #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b))
|
Chris@150
|
75 #define DLSYM(a,b) dlsym((a),(b))
|
Chris@150
|
76 #define DLCLOSE(a) dlclose((a))
|
Chris@150
|
77 #define DLERROR() dlerror()
|
Chris@150
|
78
|
Chris@150
|
79 #ifdef __APPLE__
|
Chris@150
|
80
|
Chris@255
|
81 #define PLUGIN_GLOB "*.dylib *.so"
|
Chris@223
|
82 #define PATH_SEPARATOR ':'
|
Chris@186
|
83
|
Chris@186
|
84 #define DEFAULT_LADSPA_PATH "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA"
|
Chris@186
|
85 #define DEFAULT_DSSI_PATH "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI"
|
Chris@150
|
86
|
Chris@368
|
87 #define MUNLOCKALL() 1
|
Chris@368
|
88
|
Chris@150
|
89 #else
|
Chris@150
|
90
|
Chris@150
|
91 #define PLUGIN_GLOB "*.so"
|
Chris@223
|
92 #define PATH_SEPARATOR ':'
|
Chris@186
|
93
|
Chris@186
|
94 #define DEFAULT_LADSPA_PATH "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa"
|
Chris@186
|
95 #define DEFAULT_DSSI_PATH "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi"
|
Chris@150
|
96
|
Chris@368
|
97 #define MUNLOCKALL() ::munlockall()
|
Chris@368
|
98
|
Chris@150
|
99 #endif /* __APPLE__ */
|
Chris@150
|
100
|
Chris@150
|
101 #endif /* ! _WIN32 */
|
Chris@150
|
102
|
Chris@150
|
103 enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
|
Chris@150
|
104 extern ProcessStatus GetProcessStatus(int pid);
|
Chris@150
|
105
|
Chris@168
|
106 // Return a vague approximation to the number of free megabytes of real memory.
|
Chris@168
|
107 // Return -1 if unknown.
|
Chris@170
|
108 extern void GetRealMemoryMBAvailable(int &available, int &total);
|
Chris@168
|
109
|
Chris@168
|
110 // Return a vague approximation to the number of free megabytes of disc space
|
Chris@168
|
111 // on the partition containing the given path. Return -1 if unknown.
|
Chris@168
|
112 extern int GetDiscSpaceMBAvailable(const char *path);
|
Chris@168
|
113
|
Chris@303
|
114 extern void StoreStartupLocale();
|
Chris@303
|
115 extern void RestoreStartupLocale();
|
Chris@303
|
116
|
Chris@150
|
117 #include <cmath>
|
Chris@150
|
118
|
Chris@150
|
119 extern double mod(double x, double y);
|
Chris@150
|
120 extern float modf(float x, float y);
|
Chris@150
|
121
|
Chris@150
|
122 extern double princarg(double a);
|
Chris@150
|
123 extern float princargf(float a);
|
Chris@150
|
124
|
Chris@573
|
125 #ifdef USE_POW_NO_F
|
Chris@573
|
126 #define powf pow
|
Chris@573
|
127 #endif
|
Chris@573
|
128
|
Chris@150
|
129 #endif /* ! _SYSTEM_H_ */
|
Chris@150
|
130
|
Chris@150
|
131
|