1 |
/*************************************************************************** |
2 |
* * |
3 |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
10 |
* the Free Software Foundation; either version 2 of the License, or * |
11 |
* (at your option) any later version. * |
12 |
* * |
13 |
* This library is distributed in the hope that it will be useful, * |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
* GNU General Public License for more details. * |
17 |
* * |
18 |
* You should have received a copy of the GNU General Public License * |
19 |
* along with this library; if not, write to the Free Software * |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
23 |
|
24 |
#ifndef LS_FXSEND_H |
25 |
#define LS_FXSEND_H |
26 |
|
27 |
#include "../common/global.h" |
28 |
#include "../drivers/audio/AudioChannel.h" |
29 |
#include "EngineChannel.h" |
30 |
|
31 |
#include <vector> |
32 |
|
33 |
namespace LinuxSampler { |
34 |
|
35 |
// just symbol prototyping |
36 |
class EngineChannel; |
37 |
|
38 |
/** @brief Engine Channel Effect Send |
39 |
* |
40 |
* This class is used to manage effect sends on Engine Channels. An effect |
41 |
* send is used to route sampler channel's audio signals to sampler |
42 |
* external effect processors. Each effect send entity can define an |
43 |
* arbitrary MIDI controller number which can alter the effect send's |
44 |
* send level. |
45 |
* |
46 |
* Note: effect sends cannot be routed to a different AudioOutputDevice |
47 |
* than assigned to the FxSend's EngineChannel. Also note that an effect |
48 |
* send always has as much audio channels as its EngineChannel. |
49 |
*/ |
50 |
class FxSend { |
51 |
public: |
52 |
/** |
53 |
* Constructor. By default all effect send channels are routed to |
54 |
* the @e last available audio channels on the EngineChannel's |
55 |
* AudioOutputDevice. |
56 |
* |
57 |
* @param pEngineChannel - engine channel on which the effect send |
58 |
* is added to |
59 |
* @param MidiCtrl - MIDI controller number which can alter the |
60 |
* effect send level |
61 |
* @param Name - (optional) name for the effect send entity |
62 |
* |
63 |
* @throws Exception - in case no free ID could be found on |
64 |
* given EngineChannel or @a MidiCtrl is |
65 |
* invalid |
66 |
*/ |
67 |
FxSend(EngineChannel* pEngineChannel, uint8_t MidiCtrl, String Name = "") throw (Exception); |
68 |
|
69 |
/** |
70 |
* Returns the audio output device's audio channel to which effect |
71 |
* send's channel \a SrcChan is currently routed to. |
72 |
*/ |
73 |
int DestinationChannel(int SrcChan); |
74 |
|
75 |
/** |
76 |
* Alters the routing of an audio channel. |
77 |
* |
78 |
* @param SrcChan - the effect send's source channel |
79 |
* @param DstChan - the audio output device's destination channel |
80 |
* @throws Exception - in case arguments out of range |
81 |
*/ |
82 |
void SetDestinationChannel(int SrcChan, int DstChan) throw (Exception); |
83 |
|
84 |
/** |
85 |
* Should be called by the engine channel whenever the amount of |
86 |
* audio channel has changed, so the FxSend object can adjust the |
87 |
* amount of channels to that new number and establish default |
88 |
* routings for new channels if needed. |
89 |
*/ |
90 |
void UpdateChannels(); |
91 |
|
92 |
/** |
93 |
* The effect send's current send level ( usually a value between |
94 |
* @c 0.0f and @c 1.0f ). |
95 |
*/ |
96 |
float Level(); |
97 |
|
98 |
/** |
99 |
* Alter the effect send's send level ( usually a value between |
100 |
* @c 0.0f and @c 1.0f ). |
101 |
*/ |
102 |
void SetLevel(float f); |
103 |
|
104 |
/** |
105 |
* Alter the effect send's send level by supplying the MIDI |
106 |
* controller's MIDI value. This method is usually only called |
107 |
* by the engine channel. |
108 |
*/ |
109 |
void SetLevel(uint8_t iMidiValue); |
110 |
|
111 |
/** |
112 |
* Reset send level to the default send level (i.e. due to a |
113 |
* MIDI "reset all controllers" message). |
114 |
*/ |
115 |
void Reset(); |
116 |
|
117 |
/** |
118 |
* Returns the MIDI controller number which can alter the effect |
119 |
* send's send level. |
120 |
*/ |
121 |
uint8_t MidiController(); |
122 |
|
123 |
/** |
124 |
* Alter the MIDI controller number which should alter the effect |
125 |
* send's send level. |
126 |
* |
127 |
* @param MidiCtrl - MIDI controller number |
128 |
* @throws Exception - if MIDI controller number is invalid |
129 |
*/ |
130 |
void SetMidiController(uint8_t MidiCtrl) throw (Exception); |
131 |
|
132 |
/** |
133 |
* Returns the (optional) name of this effect send entity. |
134 |
*/ |
135 |
String Name(); |
136 |
|
137 |
/** |
138 |
* Sets the name of this effect send entity. |
139 |
* @param Name The new name of this effect send entity. |
140 |
*/ |
141 |
void SetName(String Name); |
142 |
|
143 |
/** |
144 |
* Returns the (at least sampler-channel-) unique ID of the |
145 |
* effect send instance. This is actually not used by the engine |
146 |
* at all. It is at the moment only used by the LSCP server to |
147 |
* associate an unique numerical ID with each effect send entity. |
148 |
*/ |
149 |
uint Id(); |
150 |
|
151 |
/** |
152 |
* Determines whether the effect send's settings are changed. |
153 |
*/ |
154 |
bool IsInfoChanged(); |
155 |
|
156 |
/** |
157 |
* Sets whether the effect send's settings are changed. |
158 |
*/ |
159 |
void SetInfoChanged(bool b); |
160 |
|
161 |
protected: |
162 |
EngineChannel* pEngineChannel; |
163 |
std::vector<int> Routing; |
164 |
uint8_t MidiFxSendController; |
165 |
String sName; |
166 |
uint iId; |
167 |
float fLevel; |
168 |
bool bInfoChanged; // Determines whether there are changes to the settings. |
169 |
}; |
170 |
|
171 |
} // namespace LinuxSampler |
172 |
|
173 |
#endif // LS_FXSEND_H |