1 |
schoenebeck |
1424 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
schoenebeck |
1800 |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
schoenebeck |
1424 |
* * |
8 |
|
|
* 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 * |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
11 |
|
|
* (at your option) any later version. * |
12 |
|
|
* * |
13 |
|
|
* This program is distributed in the hope that it will be useful, * |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
|
|
* GNU General Public License for more details. * |
17 |
|
|
* * |
18 |
|
|
* You should have received a copy of the GNU General Public License * |
19 |
|
|
* along with this program; if not, write to the Free Software * |
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
|
|
* MA 02111-1307 USA * |
22 |
|
|
***************************************************************************/ |
23 |
|
|
|
24 |
|
|
// All application global declarations, that are not going to be exposed to |
25 |
|
|
// the C++ API are defined here. |
26 |
|
|
|
27 |
|
|
#ifndef __LS_GLOBAL_PRIVATE_H__ |
28 |
|
|
#define __LS_GLOBAL_PRIVATE_H__ |
29 |
|
|
|
30 |
|
|
#include "global.h" |
31 |
iliev |
1832 |
#include "Exception.h" |
32 |
schoenebeck |
1424 |
#include <sstream> |
33 |
|
|
|
34 |
|
|
#if HAVE_CONFIG_H |
35 |
|
|
# include <config.h> |
36 |
|
|
#endif |
37 |
|
|
|
38 |
|
|
#if CONFIG_DEBUG_LEVEL > 0 |
39 |
|
|
# define dmsg(debuglevel,x) if (CONFIG_DEBUG_LEVEL >= debuglevel) {printf x; fflush(stdout);} |
40 |
|
|
#else |
41 |
|
|
# define dmsg(debuglevel,x) |
42 |
|
|
#endif // CONFIG_DEBUG_LEVEL > 0 |
43 |
|
|
|
44 |
|
|
#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") |
45 |
|
|
|
46 |
|
|
/// defines globally the bit depth of used samples |
47 |
|
|
typedef int16_t sample_t; |
48 |
|
|
|
49 |
|
|
/** |
50 |
|
|
* Whether a function / method call was successful, or if warnings or even an |
51 |
|
|
* error occured. |
52 |
|
|
*/ |
53 |
|
|
enum result_type_t { |
54 |
|
|
result_type_success, |
55 |
|
|
result_type_warning, |
56 |
|
|
result_type_error |
57 |
|
|
}; |
58 |
|
|
|
59 |
|
|
/** |
60 |
|
|
* Used whenever a detailed description of the result of a function / method |
61 |
|
|
* call is needed. |
62 |
|
|
*/ |
63 |
|
|
struct result_t { |
64 |
|
|
result_type_t type; ///< success, warning or error |
65 |
|
|
int code; ///< warning or error code |
66 |
|
|
String message; ///< detailed warning or error message |
67 |
|
|
}; |
68 |
|
|
|
69 |
|
|
template<class T> inline String ToString(T o) { |
70 |
|
|
std::stringstream ss; |
71 |
|
|
ss << o; |
72 |
|
|
return ss.str(); |
73 |
|
|
} |
74 |
|
|
|
75 |
iliev |
1832 |
inline int ToInt(const std::string& s) throw(LinuxSampler::Exception) { |
76 |
|
|
int i; |
77 |
|
|
std::istringstream iss(s); |
78 |
|
|
if(!(iss >> i)) throw LinuxSampler::Exception("Not an integer"); |
79 |
|
|
return i; |
80 |
|
|
} |
81 |
|
|
|
82 |
schoenebeck |
1424 |
class Runnable { |
83 |
|
|
public: |
84 |
|
|
virtual ~Runnable() { } |
85 |
|
|
virtual void Run() = 0; |
86 |
|
|
}; |
87 |
|
|
|
88 |
|
|
extern double GLOBAL_VOLUME; |
89 |
schoenebeck |
1800 |
extern int GLOBAL_MAX_VOICES; |
90 |
|
|
extern int GLOBAL_MAX_STREAMS; |
91 |
schoenebeck |
1424 |
|
92 |
|
|
// I read with some Linux kernel versions (between 2.4.18 and 2.4.21) |
93 |
|
|
// sscanf() might be buggy regarding parsing of hex characters, so ... |
94 |
|
|
int hexToNumber(char hex_digit); |
95 |
|
|
int hexsToNumber(char hex_digit0, char hex_digit1 = '0'); |
96 |
|
|
|
97 |
|
|
#endif // __LS_GLOBAL_PRIVATE_H__ |