/[svn]/linuxsampler/trunk/src/engines/EngineChannel.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/EngineChannel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2330 - (show annotations) (download) (as text)
Mon Mar 12 15:14:31 2012 UTC (12 years, 1 month ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 15142 byte(s)
* Introduced new C++ API method EngineChannel::InstrumentFileName(int index)
  allowing to retrieve the whole list of files used for the loaded
  instrument on an engine channel (a.k.a. part). Some GigaStudio instruments
  for example are splitted over several files like "Foo.gig", "Foo.gx01",
  "Foo.gx02", ...
* Bumped version to 1.0.0.svn18

1 /***************************************************************************
2 * *
3 * Copyright (C) 2005 - 2012 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_ENGINECHANNEL_H__
22 #define __LS_ENGINECHANNEL_H__
23
24 #include "../EventListeners.h"
25 #include "../drivers/audio/AudioOutputDevice.h"
26 #include "../drivers/midi/midi.h"
27 #include "../drivers/midi/MidiInputDevice.h"
28 #include "../drivers/midi/MidiInputPort.h"
29 #include "../drivers/midi/VirtualMidiDevice.h"
30 #include "Engine.h"
31 #include "FxSend.h"
32
33 namespace LinuxSampler {
34
35 // just symbol prototyping
36 class Sampler;
37 class SamplerChannel;
38 class AudioOutputDevice;
39 class MidiInputPort;
40 class FxSend;
41
42
43 /** @brief Channel Interface for LinuxSampler Sampler Engines
44 *
45 * Every sampler engine can be used on several sampler channels and
46 * usually the same Engine instance is used on multiple sampler
47 * channels. For this every sampler engine must also implement a class
48 * which handles all channel dependant parameters and channel
49 * dependant execution code.
50 *
51 * This abstract base interface class defines all mandatory methods
52 * which have to be implemented by all engine channel implementations.
53 */
54 class EngineChannel {
55 public:
56
57 /////////////////////////////////////////////////////////////////
58 // abstract methods
59 // (these have to be implemented by the descendant)
60
61 virtual void PrepareLoadInstrument(const char* FileName, uint Instrument) = 0;
62 virtual void LoadInstrument() = 0;
63 virtual void Reset() = 0;
64 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel) = 0;
65 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel, int32_t FragmentPos) = 0;
66 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel) = 0;
67 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel, int32_t FragmentPos) = 0;
68 virtual void SendPitchbend(int Pitch, uint8_t MidiChannel) = 0;
69 virtual void SendPitchbend(int Pitch, uint8_t MidiChannel, int32_t FragmentPos) = 0;
70 virtual void SendControlChange(uint8_t Controller, uint8_t Value, uint8_t MidiChannel) = 0;
71 virtual void SendControlChange(uint8_t Controller, uint8_t Value, uint8_t MidiChannel, int32_t FragmentPos) = 0;
72 virtual void SendProgramChange(uint8_t Program) = 0;
73 virtual bool StatusChanged(bool bNewStatus = false) = 0;
74 virtual float Volume() = 0;
75 virtual void Volume(float f) = 0;
76 virtual float Pan() = 0;
77 virtual void Pan(float f) = 0;
78 virtual uint Channels() = 0;
79 virtual void Connect(AudioOutputDevice* pAudioOut) = 0;
80 virtual void DisconnectAudioOutputDevice() = 0;
81 virtual AudioOutputDevice* GetAudioOutputDevice() = 0;
82 virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;
83 virtual int OutputChannel(uint EngineAudioChannel) = 0;
84 virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) = 0;
85 virtual void DisconnectMidiInputPort() = 0;
86 virtual MidiInputPort* GetMidiInputPort() = 0;
87 virtual midi_chan_t MidiChannel() = 0;
88 virtual String InstrumentFileName() = 0; ///< Returns the file name of the currently loaded instrument. Equivalent as calling InstrumentFileName(0).
89 virtual String InstrumentFileName(int index);
90 virtual String InstrumentName() = 0;
91 virtual int InstrumentIndex() = 0;
92 virtual int InstrumentStatus() = 0;
93 virtual Engine* GetEngine() = 0;
94 virtual String EngineName() = 0;
95 virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception) = 0;
96 virtual FxSend* GetFxSend(uint FxSendIndex) = 0;
97 virtual uint GetFxSendCount() = 0;
98 virtual void RemoveFxSend(FxSend* pFxSend) = 0;
99 virtual void Connect(VirtualMidiDevice* pDevice) = 0;
100 virtual void Disconnect(VirtualMidiDevice* pDevice) = 0;
101
102
103 /////////////////////////////////////////////////////////////////
104 // normal methods
105 // (usually not to be overridden by descendant)
106
107 /**
108 * Sets the mute state of this channel.
109 *
110 * @param state - specifies the mute state of this sampler channel.
111 * @throws Exception - if state does not contain valid
112 * value.
113 */
114 void SetMute(int state) throw (Exception);
115
116 /**
117 * Determines whether this channel is muted.
118 *
119 * @returns 1 if the channel is muted, 0 if the channel is not muted
120 * and -1 if the channel is muted because of presence of at least
121 * one solo channel.
122 */
123 int GetMute();
124
125 /**
126 * Sets the solo state of this channel.
127 *
128 * @param solo - specifies whether this is a solo channel.
129 */
130 void SetSolo(bool solo);
131
132 /**
133 * Determines whether this is a solo channel.
134 *
135 * @returns true if this is a solo channel, false otherwise.
136 */
137 bool GetSolo();
138
139 /**
140 * Returns current MIDI program (change) number of this
141 * EngineChannel.
142 */
143 uint8_t GetMidiProgram();
144
145 /**
146 * Change EngineChannel's MIDI program.
147 */
148 void SetMidiProgram(uint8_t Program);
149
150 /**
151 * Returns current MIDI bank MSB (coarse) number of this
152 * EngineChannel.
153 */
154 uint8_t GetMidiBankMsb();
155
156 /**
157 * Change current MIDI bank MSB (coarse) number of this
158 * EngineChannel.
159 */
160 void SetMidiBankMsb(uint8_t BankMSB);
161
162 /**
163 * Returns current MIDI bank LSB (fine) number of this
164 * EngineChannel.
165 */
166 uint8_t GetMidiBankLsb();
167
168 /**
169 * Change current MIDI bank LSB (fine) number of this
170 * EngineChannel.
171 */
172 void SetMidiBankLsb(uint8_t BankLSB);
173
174 /**
175 * Returns true if this EngineChannel is using no MIDI
176 * instrument map at all, that is if it will ignore all MIDI
177 * program change messages.
178 *
179 * @see UsesDefaultMidiInstrumentMap()
180 * @see GetMidiInstrumentMap()
181 */
182 bool UsesNoMidiInstrumentMap();
183
184 /**
185 * Returns true if this EngineChannel is using the default MIDI
186 * instrument map for handling MIDI program changes.
187 *
188 * @see UsesNoMidiInstrumentMap()
189 * @see GetMidiInstrumentMap()
190 */
191 bool UsesDefaultMidiInstrumentMap();
192
193 /**
194 * Returns ID of the MIDI instrument map currently used by this
195 * EngineChannel to handle MIDI program changes. You should
196 * always call @c UsesNoMidiInstrumentMap() and
197 * @c UsesDefaultMidiInstrumentMap() before calling this method
198 * to check if this EngineChannel is probably using the default
199 * map or no map at all, because in these two particular cases
200 * this method would throw an exception!
201 *
202 * @throws Exception - if EngineChannel is set to no map at all
203 * or is set to the default map
204 * @see UsesNoMidiInstrumentMap()
205 * @see UsesDefaultMidiInstrumentMap()
206 */
207 int GetMidiInstrumentMap() throw (Exception);
208
209 /**
210 * Let this EngineChannel use no MIDI instrument map at all,
211 * that is to let it ignore all MIDI program change messages.
212 *
213 * @see SetMidiInstrumentMapToDefault()
214 * @see SetMidiInstrumentMap()
215 */
216 void SetMidiInstrumentMapToNone();
217
218 /**
219 * Let this EngineChannel use the default MIDI instrument map to
220 * handle MIDI program changes.
221 *
222 * @see SetMidiInstrumentMapToNone()
223 * @see SetMidiInstrumentMap()
224 */
225 void SetMidiInstrumentMapToDefault();
226
227 /**
228 * Set a specific MIDI instrument map this EngineChannel should
229 * use to handle MIDI program changes.
230 *
231 * @see SetMidiInstrumentMapToNone()
232 * @see SetMidiInstrumentMapToDefault()
233 *
234 * @throws Exception - in case given map does not exist
235 */
236 void SetMidiInstrumentMap(int MidiMap) throw (Exception);
237
238 /**
239 * Set MIDI Registered Parameter Number (RPN) Controller
240 * (upper 8 bits / coarse).
241 */
242 void SetMidiRpnControllerMsb(uint8_t CtrlMSB);
243
244 /**
245 * Set MIDI Registered Parameter Number (RPN) Controller
246 * (lower 8 bits / fine).
247 */
248 void SetMidiRpnControllerLsb(uint8_t CtrlLSB);
249
250 /**
251 * Reset to no RPN controller currently selected.
252 */
253 void ResetMidiRpnController();
254
255 /**
256 * Set MIDI Non-Registered Parameter Number (NRPN) Controller
257 * (upper 8 bits / coarse).
258 */
259 void SetMidiNrpnControllerMsb(uint8_t CtrlMSB);
260
261 /**
262 * Set MIDI Non-Registered Parameter Number (NRPN) Controller
263 * (lower 8 bits / fine).
264 */
265 void SetMidiNrpnControllerLsb(uint8_t CtrlLSB);
266
267 /**
268 * Reset to no NRPN controller currently selected.
269 */
270 void ResetMidiNrpnController();
271
272 /**
273 * Registers the specified listener to be notified when the number
274 * of effect sends on this channel is changed.
275 */
276 void AddFxSendCountListener(FxSendCountListener* l);
277
278 /**
279 * Removes the specified listener.
280 */
281 void RemoveFxSendCountListener(FxSendCountListener* l);
282
283 /**
284 * Removes all listeners.
285 */
286 void RemoveAllFxSendCountListeners();
287
288 /**
289 * Get currently selected MIDI Registered Parameter Number
290 * (RPN) Controller, this method will return the already merged
291 * value (MSB and LSB value).
292 *
293 * @e WARNING: you have to call @c ResetMidiRpnController()
294 * after using this value, otherwise all subsequent MIDI CC #6
295 * (Data) messages are interpreted as RPN controller value
296 * messages.
297 *
298 * @returns currently selected RPN controller number, a negative
299 * value if no RPN controller currently selected
300 */
301 int GetMidiRpnController();
302
303 /**
304 * Get currently selected MIDI Non-Registered Parameter Number
305 * (NRPN) Controller, this method will return the already merged
306 * value (MSB and LSB value).
307 *
308 * @e WARNING: you have to call @c ResetMidiNrpnController()
309 * after using this value, otherwise all subsequent MIDI CC #6
310 * (Data) messages are interpreted as NRPN controller value
311 * messages.
312 *
313 * @returns currently selected NRPN controller number, a negative
314 * value if no NRPN controller currently selected
315 */
316 int GetMidiNrpnController();
317
318 /**
319 * Gets the current number of active voices.
320 */
321 uint GetVoiceCount();
322
323 /**
324 * Sets the current number of active voices.
325 */
326 void SetVoiceCount(uint Voices);
327
328 /**
329 * Gets the current number of active disk streams.
330 */
331 uint GetDiskStreamCount();
332
333 /**
334 * Sets the current number of active disk streams.
335 */
336 void SetDiskStreamCount(uint Streams);
337
338 SamplerChannel* GetSamplerChannel();
339
340 void SetSamplerChannel(SamplerChannel* pChannel);
341
342 /** Returns the sampler to which this channel belongs */
343 Sampler* GetSampler();
344
345 /**
346 * Performs a program change on the channel.
347 *
348 * This method is not real-time safe.
349 */
350 void ExecuteProgramChange(uint32_t Program);
351
352 protected:
353 EngineChannel();
354 virtual ~EngineChannel(); // MUST only be destroyed by EngineChannelFactory
355
356 /**
357 * Notifies listeners that the number of effect sends
358 * on a this channel is changed.
359 * @param ChannelId The numerical ID of the sampler channel.
360 * @param NewCount The new number of sampler channels.
361 */
362 void fireFxSendCountChanged(int ChannelId, int NewCount);
363
364 friend class EngineChannelFactory;
365
366 private:
367 struct private_data_t;
368 private_data_t* const p;
369 };
370
371 } // namespace LinuxSampler
372
373 #endif // __LS_ENGINECHANNEL_H__

  ViewVC Help
Powered by ViewVC