/[svn]/linuxsampler/trunk/src/common/global_private.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/common/global_private.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3561 - (hide annotations) (download) (as text)
Fri Aug 23 11:44:00 2019 UTC (4 years, 8 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5679 byte(s)
NKSP: Added standard units support for numbers and final "!" operator:

* NKSP strictness: Variable names, function names and preprocessor condition
  names must start with a regular character (a-z or A-Z); starting them with
  a digit or underscore is no longer allowed.

* NKSP parser fix: equal comparison operator "=" and not equal comparison
  operator "#" must only accept integer operands.

* NKSP language: Implemented support for standard units like Hertz, seconds,
  Bel including support for metric unit prefixes; so one can now e.g.
  conveniently use numbers in scripts like "5us" meaning "5 microseconds",
  or e.g. "12kHz" meaning "12 kilo Hertz", or e.g. "-14mdB" meaning
  "minus 14 Millidecibel", or e.g. "28c" meaning "28 cents" (for tuning).

* NKSP language: Introduced "final" operator "!" which is specifically
  intended for synthesis parameter values to denote that the synthesis
  parameter value is intended to be the "final" value for that synthesis
  parameter that should explicitly be used by the engine and thus causing
  the sampler engine to ignore all other modulation sources for the same
  synthesis parameter (like e.g. LFO, EG); by simply prefixing a value,
  variable or formula with this new "!" operator the expression is marked as
  being "final".

* Bumped version (2.1.1.svn4).

1 schoenebeck 1424 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 persson 3455 * Copyright (C) 2005 - 2019 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 schoenebeck 2885 #include <algorithm>
34     #include <math.h>
35 schoenebeck 1424
36     #if HAVE_CONFIG_H
37     # include <config.h>
38     #endif
39    
40     #if CONFIG_DEBUG_LEVEL > 0
41     # define dmsg(debuglevel,x) if (CONFIG_DEBUG_LEVEL >= debuglevel) {printf x; fflush(stdout);}
42     #else
43     # define dmsg(debuglevel,x)
44     #endif // CONFIG_DEBUG_LEVEL > 0
45    
46 schoenebeck 3561 #define _strfy(s) #s
47     #define strfy(s) _strfy(s)
48    
49 schoenebeck 1424 #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")
50    
51     /// defines globally the bit depth of used samples
52     typedef int16_t sample_t;
53    
54 senoner 1913 // macro to check for a certain version (or newer) of GCC
55     #define GNUC_VERSION_PREREQ(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
56 schoenebeck 1930
57 persson 3455 #if ( GNUC_VERSION_PREREQ(3,3) && ( defined(__i386__) || defined(__x86_64__) || defined(_ARCH_PPC) ) )
58     #define HAVE_GCC_VECTOR_EXTENSIONS 1
59     #endif
60 schoenebeck 1930
61     #if HAVE_GCC_VECTOR_EXTENSIONS
62 senoner 1913 // v4sf is used by some routines that make use of GCC vector extensions (ie AudioChannel.cpp)
63     typedef float v4sf __attribute__ ((vector_size(16)));
64 schoenebeck 1930 #endif
65 senoner 1913
66 schoenebeck 2600 // circumvents a bug in GCC 4.x which causes a sizeof() expression applied
67     // on a class member to throw a compiler error, i.e. with GCC 4.4:
68     // "object missing in reference to 'LinuxSampler::AbstractEngineChannel::ControllerTable'")
69     // or with GCC 4.0:
70     // "invalid use of non-static data member 'LinuxSampler::AbstractEngineChannel::ControllerTable'"
71     #define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member)
72    
73 schoenebeck 1424 /**
74     * Whether a function / method call was successful, or if warnings or even an
75     * error occured.
76     */
77     enum result_type_t {
78     result_type_success,
79     result_type_warning,
80     result_type_error
81     };
82    
83     /**
84     * Used whenever a detailed description of the result of a function / method
85     * call is needed.
86     */
87     struct result_t {
88     result_type_t type; ///< success, warning or error
89     int code; ///< warning or error code
90     String message; ///< detailed warning or error message
91     };
92    
93     template<class T> inline String ToString(T o) {
94     std::stringstream ss;
95     ss << o;
96     return ss.str();
97     }
98    
99 iliev 1832 inline int ToInt(const std::string& s) throw(LinuxSampler::Exception) {
100     int i;
101     std::istringstream iss(s);
102     if(!(iss >> i)) throw LinuxSampler::Exception("Not an integer");
103     return i;
104     }
105    
106 iliev 2012 inline float ToFloat(const std::string& s) throw(LinuxSampler::Exception) {
107     float i;
108     std::istringstream iss(s);
109     if(!(iss >> i)) throw LinuxSampler::Exception("Not a floating-point number");
110     return i;
111     }
112    
113 schoenebeck 2885 inline std::string ltrim(std::string s) {
114     s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
115     return s;
116     }
117    
118     inline std::string rtrim(std::string s) {
119     s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
120     return s;
121     }
122    
123     inline std::string trim(std::string s) {
124     return ltrim(rtrim(s));
125     }
126    
127 schoenebeck 1424 class Runnable {
128     public:
129     virtual ~Runnable() { }
130     virtual void Run() = 0;
131     };
132    
133     extern double GLOBAL_VOLUME;
134 schoenebeck 1800 extern int GLOBAL_MAX_VOICES;
135     extern int GLOBAL_MAX_STREAMS;
136 schoenebeck 1424
137 schoenebeck 2473 //TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details)
138     #if defined(__APPLE__)
139     extern bool g_mainThreadCallbackSupported;
140     extern void (*g_mainThreadCallback)(void* info);
141     extern void* g_mainThreadCallbackInfo;
142     extern bool g_fireMainThreadCallback;
143     #endif
144    
145 schoenebeck 1424 // I read with some Linux kernel versions (between 2.4.18 and 2.4.21)
146     // sscanf() might be buggy regarding parsing of hex characters, so ...
147     int hexToNumber(char hex_digit);
148     int hexsToNumber(char hex_digit0, char hex_digit1 = '0');
149    
150     #endif // __LS_GLOBAL_PRIVATE_H__

  ViewVC Help
Powered by ViewVC