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_EFFECTCHAIN_H |
22 |
#define LS_EFFECTCHAIN_H |
23 |
|
24 |
#include "Effect.h" |
25 |
|
26 |
namespace LinuxSampler { |
27 |
|
28 |
// just symbol prototyping |
29 |
class AudioOutputDevice; |
30 |
|
31 |
/** |
32 |
* Container for a series of effects. The effects are sequentially processed, |
33 |
* that is the output of the first effect is passed to the input of the next |
34 |
* effect in the chain and so on. |
35 |
*/ |
36 |
class EffectChain { |
37 |
public: |
38 |
/** |
39 |
* Constructor. |
40 |
* |
41 |
* @param pDevice - audio output context for the effects, providing |
42 |
* informations like samplerate |
43 |
*/ |
44 |
EffectChain(AudioOutputDevice* pDevice); |
45 |
|
46 |
/** |
47 |
* Add the given effect to the end of the effect chain. |
48 |
*/ |
49 |
void AppendEffect(Effect* pEffect); |
50 |
|
51 |
/** |
52 |
* Insert the given effect into the position given by @a iChainPos . |
53 |
* |
54 |
* @throw Exception - if given position is invalid |
55 |
*/ |
56 |
void InsertEffect(Effect* pEffect, int iChainPos) throw (Exception); |
57 |
|
58 |
/** |
59 |
* Remove effect at chain position @a iChainPos from the effect chain. |
60 |
* |
61 |
* @throws Exception - if given position is invalid |
62 |
*/ |
63 |
void RemoveEffect(int iChainPos) throw (Exception); |
64 |
|
65 |
/** |
66 |
* Sequentially render the whole effects chain. The final signal |
67 |
* will be available in the output channels of the last effect in |
68 |
* the chain after this call, which then has to be copied to the |
69 |
* desired destination (e.g. the AudioOutputDevice's output channels). |
70 |
*/ |
71 |
void RenderAudio(uint Samples); |
72 |
|
73 |
/** |
74 |
* Returns effect at chain position @a iChainPos . |
75 |
*/ |
76 |
Effect* GetEffect(int iChainPos) const; |
77 |
|
78 |
/** |
79 |
* Returns amount of effects this effect chain currently contains. |
80 |
*/ |
81 |
int EffectCount() const; |
82 |
|
83 |
/** |
84 |
* Enable / disable the given effect. Currently, disabled effects are |
85 |
* automatically bypassed. We might add explicit "bypass" control in |
86 |
* future though. |
87 |
* |
88 |
* @throw Exception - if chain position is invalid |
89 |
*/ |
90 |
void SetEffectActive(int iChainPos, bool bOn) throw (Exception); |
91 |
|
92 |
/** |
93 |
* Whether the given effect is currently enabled. |
94 |
*/ |
95 |
bool IsEffectActive(int iChainPos) const; |
96 |
|
97 |
/** |
98 |
* Clears the audio input and output channels of all effects in the chain. |
99 |
*/ |
100 |
void ClearAllChannels(); |
101 |
|
102 |
private: |
103 |
struct _ChainEntry { |
104 |
Effect* pEffect; |
105 |
bool bActive; |
106 |
}; |
107 |
|
108 |
std::vector<_ChainEntry> vEntries; |
109 |
AudioOutputDevice* pDevice; |
110 |
}; |
111 |
|
112 |
} // namespace LinuxSampler |
113 |
|
114 |
#endif // LS_EFFECTCHAIN_H |