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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 906 by schoenebeck, Sun Jul 23 16:44:08 2006 UTC revision 1789 by iliev, Sat Nov 1 19:01:27 2008 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *
4   *                                                                         *   *                                                                         *
5   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 21  Line 21 
21  #ifndef __LS_ENGINECHANNEL_H__  #ifndef __LS_ENGINECHANNEL_H__
22  #define __LS_ENGINECHANNEL_H__  #define __LS_ENGINECHANNEL_H__
23    
24    #include "../EventListeners.h"
25    #include "../common/atomic.h"
26  #include "../drivers/audio/AudioOutputDevice.h"  #include "../drivers/audio/AudioOutputDevice.h"
27  #include "../drivers/midi/midi.h"  #include "../drivers/midi/midi.h"
28  #include "../drivers/midi/MidiInputDevice.h"  #include "../drivers/midi/MidiInputDevice.h"
29  #include "../drivers/midi/MidiInputPort.h"  #include "../drivers/midi/MidiInputPort.h"
30    #include "../drivers/midi/VirtualMidiDevice.h"
31  #include "Engine.h"  #include "Engine.h"
32    #include "FxSend.h"
33    
34  namespace LinuxSampler {  namespace LinuxSampler {
35    
36      // just symbol prototyping      // just symbol prototyping
37        class Sampler;
38        class SamplerChannel;
39      class AudioOutputDevice;      class AudioOutputDevice;
40      class MidiInputPort;      class MidiInputPort;
41        class FxSend;
42    
43    
44      /** @brief Channel Interface for LinuxSampler Sampler Engines      /** @brief Channel Interface for LinuxSampler Sampler Engines
45       *       *
# Line 65  namespace LinuxSampler { Line 73  namespace LinuxSampler {
73              virtual bool    StatusChanged(bool bNewStatus = false) = 0;              virtual bool    StatusChanged(bool bNewStatus = false) = 0;
74              virtual float   Volume() = 0;              virtual float   Volume() = 0;
75              virtual void    Volume(float f) = 0;              virtual void    Volume(float f) = 0;
76                virtual float   Pan() = 0;
77                virtual void    Pan(float f) = 0;
78              virtual uint    Channels() = 0;              virtual uint    Channels() = 0;
79              virtual void    Connect(AudioOutputDevice* pAudioOut) = 0;              virtual void    Connect(AudioOutputDevice* pAudioOut) = 0;
80              virtual void    DisconnectAudioOutputDevice() = 0;              virtual void    DisconnectAudioOutputDevice() = 0;
81                virtual AudioOutputDevice* GetAudioOutputDevice() = 0;
82              virtual void    SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;              virtual void    SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;
83              virtual int     OutputChannel(uint EngineAudioChannel) = 0;              virtual int     OutputChannel(uint EngineAudioChannel) = 0;
84              virtual void    Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) = 0;              virtual void    Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) = 0;
# Line 80  namespace LinuxSampler { Line 91  namespace LinuxSampler {
91              virtual int     InstrumentStatus() = 0;              virtual int     InstrumentStatus() = 0;
92              virtual Engine* GetEngine() = 0;              virtual Engine* GetEngine() = 0;
93              virtual String  EngineName() = 0;              virtual String  EngineName() = 0;
94                virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception) = 0;
95                virtual FxSend* GetFxSend(uint FxSendIndex) = 0;
96                virtual uint    GetFxSendCount() = 0;
97                virtual void    RemoveFxSend(FxSend* pFxSend) = 0;
98                virtual void    Connect(VirtualMidiDevice* pDevice) = 0;
99                virtual void    Disconnect(VirtualMidiDevice* pDevice) = 0;
100    
101    
102                /////////////////////////////////////////////////////////////////
103                // normal methods
104                //     (usually not to be overridden by descendant)
105    
106              /**              /**
107               * Sets the mute state of this channel.               * Sets the mute state of this channel.
# Line 113  namespace LinuxSampler { Line 135  namespace LinuxSampler {
135               */               */
136              bool GetSolo();              bool GetSolo();
137    
138              int iSamplerChannelIndex; ///< FIXME: nasty hack, might be removed (should be 'virtual EngineChannel* EngineChannel() = 0;', but due to cyclic dependencies only a void* solution would be possible ATM)              /**
139                 * Returns current MIDI program (change) number of this
140                 * EngineChannel.
141                 */
142                uint8_t GetMidiProgram();
143    
144                /**
145                 * Change EngineChannel's MIDI program.
146                 */
147                void SetMidiProgram(uint8_t Program);
148    
149                /**
150                 * Returns current MIDI bank MSB (coarse) number of this
151                 * EngineChannel.
152                 */
153                uint8_t GetMidiBankMsb();
154    
155                /**
156                 * Change current MIDI bank MSB (coarse) number of this
157                 * EngineChannel.
158                 */
159                void SetMidiBankMsb(uint8_t BankMSB);
160    
161                /**
162                 * Returns current MIDI bank LSB (fine) number of this
163                 * EngineChannel.
164                 */
165                uint8_t GetMidiBankLsb();
166    
167                /**
168                 * Change current MIDI bank LSB (fine) number of this
169                 * EngineChannel.
170                 */
171                void SetMidiBankLsb(uint8_t BankLSB);
172    
173                /**
174                 * Returns true if this EngineChannel is using no MIDI
175                 * instrument map at all, that is if it will ignore all MIDI
176                 * program change messages.
177                 *
178                 * @see UsesDefaultMidiInstrumentMap()
179                 * @see GetMidiInstrumentMap()
180                 */
181                bool UsesNoMidiInstrumentMap();
182    
183                /**
184                 * Returns true if this EngineChannel is using the default MIDI
185                 * instrument map for handling MIDI program changes.
186                 *
187                 * @see UsesNoMidiInstrumentMap()
188                 * @see GetMidiInstrumentMap()
189                 */
190                bool UsesDefaultMidiInstrumentMap();
191    
192                /**
193                 * Returns ID of the MIDI instrument map currently used by this
194                 * EngineChannel to handle MIDI program changes. You should
195                 * always call @c UsesNoMidiInstrumentMap() and
196                 * @c UsesDefaultMidiInstrumentMap() before calling this method
197                 * to check if this EngineChannel is probably using the default
198                 * map or no map at all, because in these two particular cases
199                 * this method would throw an exception!
200                 *
201                 * @throws Exception - if EngineChannel is set to no map at all
202                 *                     or is set to the default map
203                 * @see UsesNoMidiInstrumentMap()
204                 * @see UsesDefaultMidiInstrumentMap()
205                 */
206                int GetMidiInstrumentMap() throw (Exception);
207    
208                /**
209                 * Let this EngineChannel use no MIDI instrument map at all,
210                 * that is to let it ignore all MIDI program change messages.
211                 *
212                 * @see SetMidiInstrumentMapToDefault()
213                 * @see SetMidiInstrumentMap()
214                 */
215                void SetMidiInstrumentMapToNone();
216    
217                /**
218                 * Let this EngineChannel use the default MIDI instrument map to
219                 * handle MIDI program changes.
220                 *
221                 * @see SetMidiInstrumentMapToNone()
222                 * @see SetMidiInstrumentMap()
223                 */
224                void SetMidiInstrumentMapToDefault();
225    
226                /**
227                 * Set a specific MIDI instrument map this EngineChannel should
228                 * use to handle MIDI program changes.
229                 *
230                 * @see SetMidiInstrumentMapToNone()
231                 * @see SetMidiInstrumentMapToDefault()
232                 *
233                 * @throws Exception - in case given map does not exist
234                 */
235                void SetMidiInstrumentMap(int MidiMap) throw (Exception);
236    
237                /**
238                 * Set MIDI Registered Parameter Number (RPN) Controller
239                 * (upper 8 bits / coarse).
240                 */
241                void SetMidiRpnControllerMsb(uint8_t CtrlMSB);
242    
243                /**
244                 * Set MIDI Registered Parameter Number (RPN) Controller
245                 * (lower 8 bits / fine).
246                 */
247                void SetMidiRpnControllerLsb(uint8_t CtrlLSB);
248    
249                /**
250                 * Reset to no RPN controller currently selected.
251                 */
252                void ResetMidiRpnController();
253                
254                 /**
255                 * Registers the specified listener to be notified when the number
256                 * of effect sends on this channel is changed.
257                 */
258                void AddFxSendCountListener(FxSendCountListener* l);
259    
260                /**
261                 * Removes the specified listener.
262                 */
263                void RemoveFxSendCountListener(FxSendCountListener* l);
264    
265                /**
266                 * Removes all listeners.
267                 */
268                void RemoveAllFxSendCountListeners();
269    
270                /**
271                 * Get currently selected MIDI Registered Parameter Number
272                 * (RPN) Controller, this method will return the already merged
273                 * value (MSB and LSB value).
274                 *
275                 * @e WARNING: you have to call @c ResetMidiRpnController()
276                 * after using this value, otherwise all subsequent MIDI CC #6
277                 * (Data) messages are interpreted as RPN controller value
278                 * messages.
279                 *
280                 * @returns currently selected RPN controller number, a negative
281                 *          value if no RPN controller currently selected
282                 */
283                int GetMidiRpnController();
284    
285                /**
286                 * Gets the current number of active voices.
287                 */
288                uint GetVoiceCount();
289    
290                /**
291                 * Sets the current number of active voices.
292                 */
293                void SetVoiceCount(uint Voices);
294    
295                /**
296                 * Gets the current number of active disk streams.
297                 */
298                uint GetDiskStreamCount();
299    
300                /**
301                 * Sets the current number of active disk streams.
302                 */
303                void SetDiskStreamCount(uint Streams);
304    
305                SamplerChannel* GetSamplerChannel();
306                
307                void SetSamplerChannel(SamplerChannel* pChannel);
308    
309                /** Returns the sampler to which this channel belongs */
310                Sampler* GetSampler();
311    
312          protected:          protected:
313              EngineChannel();              EngineChannel();
314              virtual ~EngineChannel() {}; // MUST only be destroyed by EngineChannelFactory              virtual ~EngineChannel() {}; // MUST only be destroyed by EngineChannelFactory
315    
316                /**
317                 * Notifies listeners that the number of effect sends
318                 * on a this channel is changed.
319                 * @param ChannelId The numerical ID of the sampler channel.
320                 * @param NewCount The new number of sampler channels.
321                 */
322                void fireFxSendCountChanged(int ChannelId, int NewCount);
323    
324              friend class EngineChannelFactory;              friend class EngineChannelFactory;
325    
326          private:          private:
327              int  iMute;              int     iMute;
328              bool bSolo;              bool    bSolo;
329                uint8_t uiMidiProgram;
330                uint8_t uiMidiBankMsb;
331                uint8_t uiMidiBankLsb;
332                uint8_t uiMidiRpnMsb; ///< MIDI Registered Parameter Number (upper 8 bits / coarse)
333                uint8_t uiMidiRpnLsb; ///< MIDI Registered Parameter Number (lower 8 bits / fine)
334                bool    bMidiBankMsbReceived;
335                bool    bMidiBankLsbReceived;
336                bool    bProgramChangeReceived;
337                bool    bMidiRpnReceived;
338                int     iMidiInstrumentMap;
339                atomic_t voiceCount;
340                atomic_t diskStreamCount;
341                SamplerChannel* pSamplerChannel;
342                ListenerList<FxSendCountListener*> llFxSendCountListeners;
343      };      };
344    
345  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.906  
changed lines
  Added in v.1789

  ViewVC Help
Powered by ViewVC