1 |
/*************************************************************************** |
2 |
* * |
3 |
* Copyright (C) 2005 Christian Schoenebeck * |
4 |
* * |
5 |
* This library is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
7 |
* the Free Software Foundation; either version 2 of the License, or * |
8 |
* (at your option) any later version. * |
9 |
* * |
10 |
* This library is distributed in the hope that it will be useful, * |
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
13 |
* GNU General Public License for more details. * |
14 |
* * |
15 |
* You should have received a copy of the GNU General Public License * |
16 |
* along with this library; if not, write to the Free Software * |
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
18 |
* MA 02111-1307 USA * |
19 |
***************************************************************************/ |
20 |
|
21 |
#ifndef __LS_LFOTRIANGLEINTABSMATH_H__ |
22 |
#define __LS_LFOTRIANGLEINTABSMATH_H__ |
23 |
|
24 |
#include <stdlib.h> |
25 |
#include "LFOTriangleIntMath.h" |
26 |
|
27 |
namespace LinuxSampler { |
28 |
|
29 |
/** @brief Triangle LFO (int math implementation) |
30 |
* |
31 |
* This is a triangle Low Frequency Oscillator which uses pure integer |
32 |
* math (without branches) to synthesize the triangular wave. |
33 |
*/ |
34 |
template<range_type_t RANGE> |
35 |
class LFOTriangleIntAbsMath : public LFOTriangleIntMath<RANGE> { |
36 |
public: |
37 |
/** |
38 |
* Constructor |
39 |
* |
40 |
* @param Max - maximum value of the output levels |
41 |
*/ |
42 |
LFOTriangleIntAbsMath(float Max) : LFOTriangleIntMath<RANGE>::LFOTriangleIntMath(Max) { |
43 |
} |
44 |
|
45 |
/** |
46 |
* Calculates exactly one sample point of the LFO wave. |
47 |
* |
48 |
* @returns next LFO level |
49 |
*/ |
50 |
inline float render() { |
51 |
this->iLevel += this->c; |
52 |
if (RANGE == range_unsigned) |
53 |
return this->normalizer * (float) (abs(this->iLevel)); |
54 |
else /* signed range */ |
55 |
return this->normalizer * (float) (abs(this->iLevel)) + this->offset; |
56 |
} |
57 |
}; |
58 |
|
59 |
} // namespace LinuxSampler |
60 |
|
61 |
#endif // __LS_LFOTRIANGLEINTABSMATH_H__ |