1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* * |
7 |
* This program is free software; you can redistribute it and/or modify * |
8 |
* it under the terms of the GNU General Public License as published by * |
9 |
* the Free Software Foundation; either version 2 of the License, or * |
10 |
* (at your option) any later version. * |
11 |
* * |
12 |
* This program is distributed in the hope that it will be useful, * |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 |
* GNU General Public License for more details. * |
16 |
* * |
17 |
* You should have received a copy of the GNU General Public License * |
18 |
* along with this program; if not, write to the Free Software * |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
20 |
* MA 02111-1307 USA * |
21 |
***************************************************************************/ |
22 |
|
23 |
#ifndef __LS_GIG_MANIPULATOR_H__ |
24 |
#define __LS_GIG_MANIPULATOR_H__ |
25 |
|
26 |
#include "../../common/global.h" |
27 |
#include "Engine.h" |
28 |
|
29 |
namespace LinuxSampler { namespace gig { |
30 |
|
31 |
// The following template classes are used for composition with general |
32 |
// Modulation classes like the LFO template. The modulator calls the |
33 |
// ApplyLevel() method of the respective manipulator when its level has |
34 |
// changed and the manipulator actually decides what to do with the |
35 |
// modulation signal the modulator (e.g. LFO) provides. |
36 |
|
37 |
/** |
38 |
* Abstract base class for all Gig manipulator classes. |
39 |
*/ |
40 |
class BaseManipulator { |
41 |
public: |
42 |
BaseManipulator(gig::Engine* pEngine) { |
43 |
this->pEngine = pEngine; |
44 |
} |
45 |
protected: |
46 |
gig::Engine* pEngine; |
47 |
}; |
48 |
|
49 |
/** Amplification Manipulator |
50 |
* |
51 |
* Specialized manipulator for writing volume parameters to the synthesis |
52 |
* parameter matrix of the Gig Engine. |
53 |
*/ |
54 |
class VCAManipulator : public BaseManipulator { |
55 |
public: |
56 |
VCAManipulator(gig::Engine* pEngine) : BaseManipulator(pEngine) {} |
57 |
inline void ApplyLevel(float& Level, int& iSample) { |
58 |
pEngine->pSynthesisParameters[Event::destination_vca][iSample] *= Level; |
59 |
} |
60 |
}; |
61 |
|
62 |
/** Filter Cutoff Frequency Manipulator |
63 |
* |
64 |
* Specialized manipulator for writing filter cutoff frequency parameters to |
65 |
* the synthesis parameter matrix of the Gig Engine. |
66 |
*/ |
67 |
class VCFCManipulator : public BaseManipulator { |
68 |
public: |
69 |
VCFCManipulator(gig::Engine* pEngine) : BaseManipulator(pEngine) {} |
70 |
inline void ApplyLevel(float& Level, int& iSample) { |
71 |
pEngine->pSynthesisParameters[Event::destination_vcfc][iSample] *= Level; |
72 |
} |
73 |
}; |
74 |
|
75 |
/** Pitch Manipulator |
76 |
* |
77 |
* Specialized manipulator for writing pitch parameters to the synthesis |
78 |
* parameter matrix of the Gig Engine. |
79 |
*/ |
80 |
class VCOManipulator : public BaseManipulator { |
81 |
public: |
82 |
VCOManipulator(gig::Engine* pEngine) : BaseManipulator(pEngine) {} |
83 |
inline void ApplyLevel(float& Level, int& iSample) { |
84 |
pEngine->pSynthesisParameters[Event::destination_vco][iSample] *= RTMath::CentsToFreqRatio(Level); |
85 |
} |
86 |
}; |
87 |
|
88 |
}} // namespace LinuxSampler::gig |
89 |
|
90 |
#endif // __LS_GIG_MANIPULATOR_H__ |