annotate system/System.h @ 188:f86b74d1b143

* Simplify maker names in plugin menu * Make sure derived models have a name (based on the transform) * Don't start deriving a model from a derived model until the derived model is ready * Tidy up completion management in writable wave file model * Make writable models save/reload correctly from session file (i.e. regenerating from the original transform) * Same for dense 3d models -- don't save the data, just the transform details * Add a comment describing the SV file format
author Chris Cannam
date Fri, 13 Oct 2006 12:51:05 +0000
parents 06ad01f3e553
children 91fdc752e540
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@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@186 35
Chris@186 36 // The default Vamp plugin path is obtained from a function in the Vamp SDK
Chris@186 37 // (Vamp::PluginHostAdapter::getPluginPath).
Chris@186 38
Chris@186 39 #define DEFAULT_LADSPA_PATH "%ProgramFiles%\\LADSPA Plugins"
Chris@186 40 #define DEFAULT_DSSI_PATH "%ProgramFiles%\\DSSI Plugins"
Chris@150 41
Chris@150 42 #define getpid _getpid
Chris@150 43
Chris@150 44 extern "C" {
Chris@150 45 void usleep(unsigned long usec);
Chris@150 46 void gettimeofday(struct timeval *p, void *tz);
Chris@150 47 }
Chris@150 48
Chris@150 49 #else
Chris@150 50
Chris@150 51 #include <sys/mman.h>
Chris@150 52 #include <dlfcn.h>
Chris@150 53
Chris@150 54 #define MLOCK(a,b) ::mlock((a),(b))
Chris@150 55 #define MUNLOCK(a,b) (::munlock((a),(b)) ? (::perror("munlock failed"), 0) : 0)
Chris@150 56 #define MUNLOCK_SAMPLEBLOCK(a) do { if (!(a).empty()) { const float &b = *(a).begin(); MUNLOCK(&b, (a).capacity() * sizeof(float)); } } while(0);
Chris@150 57
Chris@150 58 #define DLOPEN(a,b) dlopen((a).toStdString().c_str(),(b))
Chris@150 59 #define DLSYM(a,b) dlsym((a),(b))
Chris@150 60 #define DLCLOSE(a) dlclose((a))
Chris@150 61 #define DLERROR() dlerror()
Chris@150 62
Chris@150 63 #ifdef __APPLE__
Chris@150 64
Chris@150 65 #define PLUGIN_GLOB "*.dylib"
Chris@186 66
Chris@186 67 #define DEFAULT_LADSPA_PATH "$HOME/Library/Audio/Plug-Ins/LADSPA:/Library/Audio/Plug-Ins/LADSPA"
Chris@186 68 #define DEFAULT_DSSI_PATH "$HOME/Library/Audio/Plug-Ins/DSSI:/Library/Audio/Plug-Ins/DSSI"
Chris@150 69
Chris@150 70 #else
Chris@150 71
Chris@150 72 #define PLUGIN_GLOB "*.so"
Chris@186 73
Chris@186 74 #define DEFAULT_LADSPA_PATH "$HOME/ladspa:$HOME/.ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa"
Chris@186 75 #define DEFAULT_DSSI_PATH "$HOME/dssi:$HOME/.dssi:/usr/local/lib/dssi:/usr/lib/dssi"
Chris@150 76
Chris@150 77 #endif /* __APPLE__ */
Chris@150 78
Chris@150 79 #endif /* ! _WIN32 */
Chris@150 80
Chris@150 81 enum ProcessStatus { ProcessRunning, ProcessNotRunning, UnknownProcessStatus };
Chris@150 82 extern ProcessStatus GetProcessStatus(int pid);
Chris@150 83
Chris@168 84 // Return a vague approximation to the number of free megabytes of real memory.
Chris@168 85 // Return -1 if unknown.
Chris@170 86 extern void GetRealMemoryMBAvailable(int &available, int &total);
Chris@168 87
Chris@168 88 // Return a vague approximation to the number of free megabytes of disc space
Chris@168 89 // on the partition containing the given path. Return -1 if unknown.
Chris@168 90 extern int GetDiscSpaceMBAvailable(const char *path);
Chris@168 91
Chris@150 92 #include <cmath>
Chris@150 93
Chris@150 94 extern double mod(double x, double y);
Chris@150 95 extern float modf(float x, float y);
Chris@150 96
Chris@150 97 extern double princarg(double a);
Chris@150 98 extern float princargf(float a);
Chris@150 99
Chris@150 100 #endif /* ! _SYSTEM_H_ */
Chris@150 101
Chris@150 102