3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 Christian Schoenebeck * |
* Copyright (C) 2005 - 2019 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
21 |
* MA 02111-1307 USA * |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
***************************************************************************/ |
23 |
|
|
24 |
// All application global declarations are defined here. |
// All application global declarations that HAVE to be exposed to the C++ |
25 |
|
// API are defined here. |
26 |
|
|
27 |
#ifndef __GLOBAL_H__ |
#ifndef __LS_GLOBAL_H__ |
28 |
#define __GLOBAL_H__ |
#define __LS_GLOBAL_H__ |
29 |
|
|
30 |
#include <stdlib.h> |
#include <stdlib.h> |
31 |
#include <stdint.h> |
#include <stdint.h> |
32 |
#include <stdio.h> |
#include <stdio.h> |
33 |
|
|
34 |
#include <string> |
#include <string> |
|
#include <sstream> |
|
35 |
|
|
36 |
#ifdef HAVE_CONFIG_H |
typedef std::string String; |
|
# include <config.h> |
|
|
#endif |
|
37 |
|
|
38 |
// Make sure all mandatory configuration macros are defined. |
#if defined(WIN32) |
39 |
// We don't care about optional configuration macros though. |
#include <windows.h> |
|
#ifndef CONFIG_MAX_PITCH |
|
|
# error "Configuration macro CONFIG_MAX_PITCH not defined!" |
|
|
#endif // CONFIG_MAX_PITCH |
|
|
#ifndef CONFIG_MAX_EVENTS_PER_FRAGMENT |
|
|
# error "Configuration macro CONFIG_MAX_EVENTS_PER_FRAGMENT not defined!" |
|
|
#endif // CONFIG_MAX_EVENTS_PER_FRAGMENT |
|
|
#ifndef CONFIG_EG_BOTTOM |
|
|
# error "Configuration macro CONFIG_EG_BOTTOM not defined!" |
|
|
#endif // CONFIG_EG_BOTTOM |
|
|
#ifndef CONFIG_EG_MIN_RELEASE_TIME |
|
|
# error "Configuration macro CONFIG_EG_MIN_RELEASE_TIME not defined!" |
|
|
#endif // CONFIG_EG_MIN_RELEASE_TIME |
|
|
#ifndef CONFIG_REFILL_STREAMS_PER_RUN |
|
|
# error "Configuration macro CONFIG_REFILL_STREAMS_PER_RUN not defined!" |
|
|
#endif // CONFIG_REFILL_STREAMS_PER_RUN |
|
|
#ifndef CONFIG_STREAM_MIN_REFILL_SIZE |
|
|
# error "Configuration macro CONFIG_STREAM_MIN_REFILL_SIZE not defined!" |
|
|
#endif // CONFIG_STREAM_MIN_REFILL_SIZE |
|
|
#ifndef CONFIG_STREAM_MAX_REFILL_SIZE |
|
|
# error "Configuration macro CONFIG_STREAM_MAX_REFILL_SIZE not defined!" |
|
|
#endif // CONFIG_STREAM_MAX_REFILL_SIZE |
|
|
#ifndef CONFIG_STREAM_BUFFER_SIZE |
|
|
# error "Configuration macro CONFIG_STREAM_BUFFER_SIZE not defined!" |
|
|
#endif // CONFIG_STREAM_BUFFER_SIZE |
|
|
#ifndef CONFIG_MAX_STREAMS |
|
|
# error "Configuration macro CONFIG_MAX_STREAMS not defined!" |
|
|
#endif // CONFIG_MAX_STREAMS |
|
|
#ifndef CONFIG_MAX_VOICES |
|
|
# error "Configuration macro CONFIG_MAX_VOICES not defined!" |
|
|
#endif // CONFIG_MAX_VOICES |
|
|
#ifndef CONFIG_VOICE_STEAL_ALGO |
|
|
# error "Configuration macro CONFIG_VOICE_STEAL_ALGO not defined!" |
|
|
#endif // CONFIG_VOICE_STEAL_ALGO |
|
|
#ifndef CONFIG_SYSEX_BUFFER_SIZE |
|
|
# error "Configuration macro CONFIG_SYSEX_BUFFER_SIZE not defined!" |
|
|
#endif // CONFIG_SYSEX_BUFFER_SIZE |
|
|
#ifndef CONFIG_FILTER_UPDATE_STEPS |
|
|
# error "Configuration macro CONFIG_FILTER_UPDATE_STEPS not defined!" |
|
|
#endif // CONFIG_FILTER_UPDATE_STEPS |
|
|
#ifndef CONFIG_FILTER_CUTOFF_MIN |
|
|
# error "Configuration macro CONFIG_FILTER_CUTOFF_MIN not defined!" |
|
|
#endif // CONFIG_FILTER_CUTOFF_MIN |
|
|
#ifndef CONFIG_FILTER_CUTOFF_MAX |
|
|
# error "Configuration macro CONFIG_FILTER_CUTOFF_MAX not defined!" |
|
|
#endif // CONFIG_FILTER_CUTOFF_MAX |
|
40 |
|
|
41 |
#if CONFIG_DEBUG_LEVEL > 0 |
// modern MinGW has usleep |
42 |
# define dmsg(debuglevel,x) if (CONFIG_DEBUG_LEVEL >= debuglevel) {printf x; fflush(stdout);} |
#if (__MINGW32_MAJOR_VERSION < 3 || \ |
43 |
#else |
(__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION < 15)) && \ |
44 |
# define dmsg(debuglevel,x) |
!defined(__MINGW64) && !defined(__MINGW64_VERSION_MAJOR) |
45 |
#endif // CONFIG_DEBUG_LEVEL > 0 |
#define usleep(a) Sleep(a/1000) |
46 |
|
#endif |
47 |
|
|
48 |
#define EMMS __asm__ __volatile__ ("emms" ::: "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7") |
#define sleep(a) Sleep(a*1000) |
49 |
|
typedef unsigned int uint; |
50 |
|
// FIXME: define proper functions which do proper alignement under Win32 |
51 |
|
#define alignedMalloc(a,b) malloc(b) |
52 |
|
#define alignedFree(a) free(a) |
53 |
|
#else |
54 |
|
// needed for usleep under POSIX |
55 |
|
#include <stdio.h> |
56 |
|
// for uint |
57 |
|
#include <sys/types.h> |
58 |
|
#endif |
59 |
|
|
60 |
/// defines globally the bit depth of used samples |
#ifdef __GNUC__ |
61 |
typedef int16_t sample_t; |
#define DEPRECATED_API __attribute__ ((deprecated)) |
62 |
|
#else |
63 |
|
#define DEPRECATED_API |
64 |
|
#endif |
65 |
|
|
66 |
typedef std::string String; |
// whether compiler is C++11 standard compliant |
67 |
|
#if defined(__cplusplus) && __cplusplus >= 201103L |
68 |
|
# define IS_CPP11 1 |
69 |
|
#endif |
70 |
|
|
71 |
/** |
// C++ "override" keyword introduced with C++11 standard |
72 |
* Wether a function / method call was successful, or if warnings or even an |
#if IS_CPP11 |
73 |
* error occured. |
# define OVERRIDE override |
74 |
*/ |
# define FINAL final |
75 |
enum result_type_t { |
#else |
76 |
result_type_success, |
# define OVERRIDE |
77 |
result_type_warning, |
# define FINAL |
78 |
result_type_error |
#endif |
|
}; |
|
|
|
|
|
/** |
|
|
* Used whenever a detailed description of the result of a function / method |
|
|
* call is needed. |
|
|
*/ |
|
|
struct result_t { |
|
|
result_type_t type; ///< success, warning or error |
|
|
int code; ///< warning or error code |
|
|
String message; ///< detailed warning or error message |
|
|
}; |
|
|
|
|
|
template<class T> inline String ToString(T o) { |
|
|
std::stringstream ss; |
|
|
ss << o; |
|
|
return ss.str(); |
|
|
} |
|
79 |
|
|
80 |
#endif // __GLOBAL_H__ |
#endif // __LS_GLOBAL_H__ |