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

Contents of /linuxsampler/trunk/src/engines/common/LFOBase.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 738 - (show annotations) (download) (as text)
Tue Aug 16 17:14:25 2005 UTC (18 years, 8 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5476 byte(s)
* extensive synthesis optimization: reimplementation of EGs and LFO(s),
  removed synthesis parameter prerendering and the synthesis parameter
  matrix in general, splitting each audio fragment into subfragments now
  where each subfragment uses constant synthesis parameters
  (everything's still very buggy ATM)

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_LFOBASE_H__
22 #define __LS_LFOBASE_H__
23
24 #ifdef HAVE_CONFIG_H
25 # include "../../common/global.h"
26 # include "../../common/RTMath.h"
27
28 // IDs of the two possible implementations
29 // we get the implementation to pick from config.h
30 // the implementation IDs should be the same like in benchmarks/triang.cpp !
31 # define INT_MATH_SOLUTION 2
32 # define DI_HARMONIC_SOLUTION 3
33 # define INT_ABS_MATH_SOLUTION 5
34 #else
35 # include <math.h>
36 # include <stdint.h>
37 #endif
38
39 namespace LinuxSampler {
40
41 // *************** types ***************
42 // *
43
44 /**
45 * Whether the LFO should have positive AND negative value range
46 * (signed) or only a positive value range (unsigned).
47 */
48 enum range_type_t {
49 range_signed, ///< LFO's level will wave between -max ... +max
50 range_unsigned ///< LFO's level will wave between 0 ... +max
51 };
52
53 /**
54 * Defines the start level of the LFO wave within the given value range.
55 */
56 enum start_level_t {
57 start_level_max, ///< wave starts from given max. level
58 start_level_mid, ///< wave starts from the middle of the given value range
59 start_level_min ///< wave starts from given min. level
60 };
61
62 /** @brief LFO (abstract base class)
63 *
64 * Abstract base class for all Low Frequency Oscillator implementations.
65 */
66 template<range_type_t RANGE>
67 class LFOBase {
68 public:
69
70 // *************** attributes ***************
71 // *
72
73 uint8_t ExtController; ///< MIDI control change controller number if the LFO is controlled by an external controller, 0 otherwise.
74
75
76 // *************** methods ***************
77 // *
78
79 /**
80 * Constructor
81 *
82 * @param Max - maximum value of the output levels
83 */
84 LFOBase(float Max) {
85 this->ExtController = 0;
86 this->Max = Max;
87 }
88
89 virtual ~LFOBase() {
90 }
91
92 /**
93 * Calculates exactly one sample point of the LFO wave. This
94 * inline method has to be implemented by the descendant.
95 *
96 * @returns next LFO level
97 */
98 //abstract inline float render(); //< what a pity that abstract inliners are not supported by C++98 (probably by upcoming C++0x?)
99
100 /**
101 * Update LFO depth with a new external controller value. This
102 * inline method has to be implemented by the descendant.
103 *
104 * @param ExtControlValue - new external controller value
105 */
106 //abstract inline void update(const uint16_t& ExtControlValue); //< what a pity that abstract inliners are not supported by C++98 (probably by upcoming C++0x?)
107
108 /**
109 * Will be called by the voice when the key / voice was triggered.
110 *
111 * @param Frequency - frequency of the oscillator in Hz
112 * @param StartLevel - on which level the wave should start
113 * @param InternalDepth - firm, internal oscillator amplitude
114 * @param ExtControlDepth - defines how strong the external MIDI
115 * controller has influence on the
116 * oscillator amplitude
117 * @param FlipPhase - inverts the oscillator wave against
118 * a horizontal axis
119 * @param SampleRate - current sample rate of the engines
120 * audio output signal
121 */
122 virtual void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) = 0;
123
124 protected:
125 float Max;
126 float InternalDepth;
127 float ExtControlDepthCoeff;
128 };
129
130 } // namespace LinuxSampler
131
132 #endif // __LS_LFOBASE_H__

  ViewVC Help
Powered by ViewVC