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 - 2013 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 * |
30 |
#include "global.h" |
#include "global.h" |
31 |
#include "Exception.h" |
#include "Exception.h" |
32 |
#include <sstream> |
#include <sstream> |
33 |
|
#include <algorithm> |
34 |
|
#include <math.h> |
35 |
|
|
36 |
#if HAVE_CONFIG_H |
#if HAVE_CONFIG_H |
37 |
# include <config.h> |
# include <config.h> |
51 |
// macro to check for a certain version (or newer) of GCC |
// macro to check for a certain version (or newer) of GCC |
52 |
#define GNUC_VERSION_PREREQ(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) |
#define GNUC_VERSION_PREREQ(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))) |
53 |
|
|
54 |
// macro which checks if GCC vector extensions are avialable |
#if ( GNUC_VERSION_PREREQ(3,3) && ( defined(__i386__) || defined(__x86_64__) || defined(_ARCH_PPC) ) ) |
55 |
#define HAVE_GCC_VECTOR_EXTENSIONS ( GNUC_VERSION_PREREQ(3,3) && ( defined(__i386__) || defined(__x86_64__) || defined(_ARCH_PPC) ) ) |
#define HAVE_GCC_VECTOR_EXTENSIONS 1 |
56 |
|
#endif |
57 |
|
|
58 |
#if HAVE_GCC_VECTOR_EXTENSIONS |
#if HAVE_GCC_VECTOR_EXTENSIONS |
59 |
// v4sf is used by some routines that make use of GCC vector extensions (ie AudioChannel.cpp) |
// v4sf is used by some routines that make use of GCC vector extensions (ie AudioChannel.cpp) |
60 |
typedef float v4sf __attribute__ ((vector_size(16))); |
typedef float v4sf __attribute__ ((vector_size(16))); |
61 |
#endif |
#endif |
62 |
|
|
63 |
|
// circumvents a bug in GCC 4.x which causes a sizeof() expression applied |
64 |
|
// on a class member to throw a compiler error, i.e. with GCC 4.4: |
65 |
|
// "object missing in reference to 'LinuxSampler::AbstractEngineChannel::ControllerTable'") |
66 |
|
// or with GCC 4.0: |
67 |
|
// "invalid use of non-static data member 'LinuxSampler::AbstractEngineChannel::ControllerTable'" |
68 |
|
#define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member) |
69 |
|
|
70 |
/** |
/** |
71 |
* Whether a function / method call was successful, or if warnings or even an |
* Whether a function / method call was successful, or if warnings or even an |
72 |
* error occured. |
* error occured. |
107 |
return i; |
return i; |
108 |
} |
} |
109 |
|
|
110 |
|
inline std::string ltrim(std::string s) { |
111 |
|
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace)))); |
112 |
|
return s; |
113 |
|
} |
114 |
|
|
115 |
|
inline std::string rtrim(std::string s) { |
116 |
|
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); |
117 |
|
return s; |
118 |
|
} |
119 |
|
|
120 |
|
inline std::string trim(std::string s) { |
121 |
|
return ltrim(rtrim(s)); |
122 |
|
} |
123 |
|
|
124 |
class Runnable { |
class Runnable { |
125 |
public: |
public: |
126 |
virtual ~Runnable() { } |
virtual ~Runnable() { } |