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