1 |
schoenebeck |
1722 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
schoenebeck |
2124 |
* Copyright (C) 2008, 2010 Christian Schoenebeck * |
4 |
schoenebeck |
1722 |
* * |
5 |
|
|
* This program 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 program 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 program; 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_EFFECT_H |
22 |
|
|
#define LS_EFFECT_H |
23 |
|
|
|
24 |
|
|
#include <vector> |
25 |
|
|
#include "../drivers/audio/AudioChannel.h" |
26 |
schoenebeck |
2124 |
#include "../common/Exception.h" |
27 |
|
|
#include "EffectControl.h" |
28 |
schoenebeck |
1722 |
|
29 |
|
|
namespace LinuxSampler { |
30 |
|
|
|
31 |
|
|
// just symbol prototyping |
32 |
|
|
class AudioOutputDevice; |
33 |
|
|
|
34 |
|
|
/** |
35 |
|
|
* Abstract base class for sampler internal effects. |
36 |
|
|
*/ |
37 |
|
|
class Effect { |
38 |
|
|
public: |
39 |
|
|
///////////////////////////////////////////////////////////////// |
40 |
|
|
// abstract methods |
41 |
|
|
// (these have to be implemented by the descendant) |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* Use the input audio signal given with @a ppInputChannels, render the |
45 |
|
|
* effect and mix the result into the effect's output channels. |
46 |
|
|
* |
47 |
schoenebeck |
2124 |
* @param Samples - amount of sample points to process |
48 |
schoenebeck |
1722 |
*/ |
49 |
|
|
virtual void RenderAudio(uint Samples) = 0; |
50 |
|
|
|
51 |
|
|
/** |
52 |
|
|
* Will be called by the sampler before using the effect the first time. |
53 |
|
|
* This method can be implemented by the effect to adjust itself to the |
54 |
|
|
* requirements given by the audio output device. |
55 |
|
|
* |
56 |
|
|
* This is the perfect place to create the required audio input and |
57 |
|
|
* output channels! ;-) |
58 |
|
|
* |
59 |
|
|
* @param pDevice - audio output device which is going to play the signal |
60 |
schoenebeck |
2124 |
* @throws Exception - if effect could not be initialized successfully |
61 |
schoenebeck |
1722 |
*/ |
62 |
schoenebeck |
2124 |
virtual void InitEffect(AudioOutputDevice* pDevice) throw (Exception); |
63 |
schoenebeck |
1722 |
|
64 |
|
|
/** |
65 |
|
|
* Destructor, deletes all audio input and output channels. |
66 |
|
|
*/ |
67 |
|
|
virtual ~Effect(); |
68 |
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
///////////////////////////////////////////////////////////////// |
72 |
|
|
// normal methods |
73 |
|
|
// (usually not to be overriden by descendant) |
74 |
|
|
|
75 |
|
|
/** |
76 |
|
|
* Returns audio input channel with index \a ChannelIndex or NULL if |
77 |
|
|
* index out of bounds. |
78 |
|
|
*/ |
79 |
|
|
AudioChannel* InputChannel(uint ChannelIndex) const; |
80 |
|
|
|
81 |
|
|
/** |
82 |
|
|
* Returns the amount of audio input channels the effect is currently |
83 |
|
|
* providing. |
84 |
|
|
*/ |
85 |
|
|
uint InputChannelCount() const; |
86 |
|
|
|
87 |
|
|
/** |
88 |
|
|
* Returns audio output channel with index \a ChannelIndex or NULL if |
89 |
|
|
* index out of bounds. |
90 |
|
|
*/ |
91 |
|
|
AudioChannel* OutputChannel(uint ChannelIndex) const; |
92 |
|
|
|
93 |
|
|
/** |
94 |
|
|
* Returns the amount of audio output channels the effect is currently |
95 |
|
|
* providing. |
96 |
|
|
*/ |
97 |
|
|
uint OutputChannelCount() const; |
98 |
|
|
|
99 |
schoenebeck |
2124 |
/** |
100 |
|
|
* Returns effect parameter with index \a ControlIndex or NULL if index |
101 |
|
|
* out of bounds. |
102 |
|
|
*/ |
103 |
|
|
EffectControl* InputControl(uint ControlIndex) const; |
104 |
|
|
|
105 |
|
|
/** |
106 |
|
|
* Returns the amount of effect parameters the effect provides. |
107 |
|
|
*/ |
108 |
|
|
uint InputControlCount() const; |
109 |
|
|
|
110 |
schoenebeck |
1722 |
protected: |
111 |
|
|
std::vector<AudioChannel*> vInputChannels; |
112 |
|
|
std::vector<AudioChannel*> vOutputChannels; |
113 |
schoenebeck |
2124 |
std::vector<EffectControl*> vInputControls; |
114 |
|
|
std::vector<EffectControl*> vOutputControls; ///< yet unused |
115 |
schoenebeck |
1722 |
}; |
116 |
|
|
|
117 |
|
|
} // namespace LinuxSampler |
118 |
|
|
|
119 |
|
|
#endif // LS_EFFECT_H |