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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3052 - (hide annotations) (download) (as text)
Wed Dec 14 17:34:54 2016 UTC (7 years, 5 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5437 byte(s)
- Preparations for Xcode project update.

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

  ViewVC Help
Powered by ViewVC