/[svn]/linuxsampler/trunk/src/Sampler.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/Sampler.h

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

revision 155 by senkov, Mon Jun 28 04:30:11 2004 UTC revision 1789 by iliev, Sat Nov 1 19:01:27 2008 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6     *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   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 25  Line 26 
26    
27  #include <vector>  #include <vector>
28  #include <map>  #include <map>
29    #include "EventListeners.h"
30  #include "common/global.h"  #include "common/global.h"
31  #include "common/LinuxSamplerException.h"  #include "common/Exception.h"
32  #include "engines/common/Engine.h"  #include "engines/EngineChannel.h"
33  #include "mididriver/MidiInputDevice.h"  #include "drivers/midi/MidiInputDevice.h"
34  #include "audiodriver/AudioOutputDevice.h"  #include "drivers/audio/AudioOutputDevice.h"
35    
36  namespace LinuxSampler {  namespace LinuxSampler {
37    
38      // just symbol prototyping      // just symbol prototyping
39      class Sampler;      class Sampler;
40    
41      /** LinuxSampler sampler channel      /** @brief LinuxSampler sampler channel
42       *       *
43       * Encapsulates one sampler engine, one connection to a MIDI input       * Encapsulates a channel of a specific sampler engine type, one
44       * device and one connection to an audio output device. You cannot       * connection to a MIDI input device and one connection to an audio
45       * create an instance of this class on your own, you have to use the       * output device. You cannot create an instance of this class on your
46       * AddSamplerChannel() method of the Sampler object to create a new       * own, you have to use the AddSamplerChannel() method of the Sampler
47       * sampler channel.       * object to create a new sampler channel.
48       */       */
49      class SamplerChannel {      class SamplerChannel {
50          public:          public:
51              /**              /**
52               * Deploy a sampler engine of the given type for this sampler               * Assign a sampler engine type to this sampler channel.
              * channnel. If there was already a sampler engine deployed on  
              * this sampler channel, then the old engine will automatically  
              * be destroyed.  
53               *               *
54               * @param EngineType - type of the engine to deploy               * @param EngineType - type of the engine to use
55                 * @throws Exception - if \a EngineType is invalid
56                 * @see Sampler::AvailableEngineTypes()
57               */               */
58              void LoadEngine(Engine::type_t EngineType); // TODO: to be changed to 'void LoadEngine(String EngineType) throws (LinuxSamplerException);'              void SetEngineType(String EngineType) throw (Exception);
59    
60              /**              /**
61               * Connect this sampler channel to an audio output device, that               * Connect this sampler channel to an audio output device, that
# Line 67  namespace LinuxSampler { Line 68  namespace LinuxSampler {
68              void SetAudioOutputDevice(AudioOutputDevice* pDevice);              void SetAudioOutputDevice(AudioOutputDevice* pDevice);
69    
70              /**              /**
71               * Connect this sampler channel to and MIDI input port               * Connect this sampler channel to a MIDI input device.
72               *               *
73               * @param MidiInputDevice - MIDI input device to connect to               * @param pDevice - MIDI input device to connect to
74               * @param MidiInputPort - MIDI port to connect to               */
75                void SetMidiInputDevice(MidiInputDevice *pDevice);
76    
77                /**
78                 * Connect this sampler channel to a MIDI input port.
79                 *
80                 * @param MidiPort - MIDI port to connect to
81                 */
82                void SetMidiInputPort(int MidiPort);
83    
84                /**
85                 * Define on which MIDI channel(s) this sampler channel should
86                 * listen to. By default, that is after creation of a new
87                 * sampler channel, the sampler channel will listen to all MIDI
88                 * channels.
89                 *
90                 * @param MidiChannel - MIDI channel to listen
91                 */
92                void SetMidiInputChannel(midi_chan_t MidiChannel);
93    
94                /**
95                 * Connect this sampler channel to a MIDI input triplet.
96                 *
97                 * @param pDevice - MIDI input device to connect to
98                 * @param iMidiPort - MIDI port to connect to
99               * @param MidiChannel - optional: MIDI channel on which the               * @param MidiChannel - optional: MIDI channel on which the
100               *                      sampler channel should listen to               *                      sampler channel should listen to
101               *                      (default: listen on all MIDI channels)               *                      (default: listen on all MIDI channels)
102               */               */
103              void SetMidiInputPort(MidiInputDevice* pDevice, int midiPort, MidiInputDevice::MidiInputPort::midi_chan_t MidiChannel = MidiInputDevice::MidiInputPort::midi_chan_all);              void SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all);
104    
105              /**              /**
106               * Returns the engine that was deployed on this sampler channel.               * Returns the EngineChannel object that was deployed on this
107                 * sampler channel appropriate to the given sampler engine type.
108               *               *
109               * @returns  pointer to engine or NULL if no engine deployed               * @returns  pointer to engine or NULL if no engine deployed
110               */               */
111              Engine* GetEngine();              EngineChannel* GetEngineChannel();
112    
113              /**              /**
114               * Returns the MIDI input device to which this sampler channel               * Returns the MIDI input channel to which this sampler
115               * is currently connected to.               * channel is currently connected to.
116               *               *
117               * @returns  pointer to MIDI input device or NULL if not               * @returns  The MIDI input channel on which the sampler
118               *           connected               *           channel is listening to.
119               */               */
120              MidiInputDevice::MidiInputPort* GetMidiInputPort();              midi_chan_t GetMidiInputChannel();
121    
122                /**
123                 * Returns the MIDI input port number to which this sampler
124                 * channel is currently connected to.
125                 *
126                 * @returns  MIDI input port number or -1 if not connected
127                 */
128                int GetMidiInputPort();
129    
130              /**              /**
131               * Returns the audio output device to which this sampler channel               * Returns the audio output device to which this sampler channel
# Line 103  namespace LinuxSampler { Line 137  namespace LinuxSampler {
137              AudioOutputDevice* GetAudioOutputDevice();              AudioOutputDevice* GetAudioOutputDevice();
138    
139              /**              /**
140               * Returns the audio output device to which this sampler channel               * Returns the MIDI input device to which this sampler channel
141               * is currently connected to.               * is currently connected to.
142               *               *
143               * @returns  pointer to audio output device or NULL if not               * @returns  pointer to MIDI input device or NULL if not
144               *           connected               *           connected
145               */               */
146              MidiInputDevice* GetMidiInputDevice();              MidiInputDevice* GetMidiInputDevice();
# Line 117  namespace LinuxSampler { Line 151  namespace LinuxSampler {
151               */               */
152              uint Index();              uint Index();
153    
154              /**              /** Returns the sampler to which this channel belongs */
155               * Returns midi channel              Sampler* GetSampler();
156               */              
157              MidiInputDevice::MidiInputPort::midi_chan_t GetMidiInputChannel() { return midiChannel; }              /**
158                 * Registers the specified listener to be notified
159                 * when the engine type of this sampler channel is changed.
160                 */
161                void AddEngineChangeListener(EngineChangeListener* l);
162    
163                /**
164                 * Removes the specified listener.
165                 */
166                void RemoveEngineChangeListener(EngineChangeListener* l);
167    
168                /**
169                 * Removes the specified listener.
170                 */
171                void RemoveAllEngineChangeListeners();
172    
173                /**
174                 * Notifies listeners that the engine type of this sampler
175                 * channel is going to be changed soon.
176                 */
177                void fireEngineToBeChanged();
178    
179                /**
180                 * Notifies listeners that the engine
181                 * type of this sampler channel is changed.
182                 */
183                void fireEngineChanged();
184    
185    
186          protected:          protected:
187              SamplerChannel(Sampler* pS);              SamplerChannel(Sampler* pS);
188             ~SamplerChannel();              virtual ~SamplerChannel();
189    
190                /** Getting MIDI input device port given its index number. */
191                MidiInputPort* __GetMidiInputDevicePort(int iMidiPort);
192    
193              Sampler*           pSampler;              Sampler*           pSampler;
194              Engine*            pEngine;              EngineChannel*     pEngineChannel;
             MidiInputDevice::MidiInputPort*     pMidiInputPort;  
195              AudioOutputDevice* pAudioOutputDevice;              AudioOutputDevice* pAudioOutputDevice;
196                MidiInputDevice*   pMidiInputDevice;
197              int                iIndex;              int                iIndex;
             MidiInputDevice::MidiInputPort::midi_chan_t midiChannel;  
198    
199              friend class Sampler;              friend class Sampler;
200            private:
201                int                iMidiPort;   ///< Don't access directly, read GetMidiInputPort() instead !
202                midi_chan_t        midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead !
203                ListenerList<EngineChangeListener*> llEngineChangeListeners;
204      };      };
205    
206      /** LinuxSampler main class      /** @brief LinuxSampler main class
207       *       *
208       * This is the toplevel class for a LinuxSampler instance.       * This is the toplevel class for a LinuxSampler instance.
209       *       *
# Line 144  namespace LinuxSampler { Line 211  namespace LinuxSampler {
211       * sampler channel can individually be deployed with it's own sampler       * sampler channel can individually be deployed with it's own sampler
212       * engine, connected to an arbitrary MIDI input device and connected to       * engine, connected to an arbitrary MIDI input device and connected to
213       * an arbitrary audio output device. Here an example setup:       * an arbitrary audio output device. Here an example setup:
214         * @code
215         * S.Channel    MIDI in    S.Engine         Audio out
216         * -------------------------------------------------------------------
217         *   0          Alsa   ->  gig::Engine  ->  Jack
218         *   1          VSTi   ->  Akai::Engine ->  VSTi
219         *   2          Jack   ->  DLS::Engine  ->  Jack
220         *   3          Jack   ->  SF::Engine   ->  Alsa
221       *       *
222       *  S.Channel.      MIDI in         S.Engine                Audio out       * ... (and so on) ...
223       *  -------------------------------------------------------------------       * @endcode
      *  0               Alsa    ->      gig::Engine     ->      Jack  
      *  1               VSTi    ->      Akai::Engine    ->      VSTi  
      *  2               Jack    ->      DLS::Engine     ->      Jack  
      *  3               Jack    ->      SF::Engine      ->      Alsa  
      *  
      *  ... (and so on) ...  
224       *       *
225       * Note that not all audio and MIDI backends and sampler engines listed       * Note that not all audio and MIDI backends and sampler engines listed
226       * in the example above are already implemented!       * in the example above might already been implemented!
227       *       *
228       * As you can see in the example setup, LinuxSampler is capable to use       * As you can see in the example setup, LinuxSampler is capable to use
229       * several, different audio output and MIDI input systems       * several, different audio output and MIDI input systems
230       * simultaniously at the same time. Here the example setup shown in the       * simultaniously at the same time. Here the example setup shown in the
231       * ascpect of MIDI input and audio output devices / drivers:       * aspect of MIDI input and audio output devices / drivers:
232       *       * @code
233       *                            ######################### #########################       *                      ######################### #########################
234       *                            # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #       *                      # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #
235       *                            ######################### #########################       *                      ######################### #########################
236       *                                          ^   ^           ^       *                                        ^   ^           ^
237       *    /------------>|Sampler Channel 0|-----/   |           |       *  /------------>|Sampler Channel 0|-----/   |           |
238       *    |  /--------->|Sampler Channel 1|---------------------/       *  |  /--------->|Sampler Channel 1|---------------------/
239       *    |  |    /---->|Sampler Channel 2|---------/       *  |  |  /------>|Sampler Channel 2|---------/
240       *    |  |    |  /->|Sampler Channel 3|------------>#########################       *  |  |  |  /--->|Sampler Channel 3|------------>#########################
241       *    |  |    |  |  ... (and so on) ...             # AudioOutputDeviceAlsa #       *  |  |  |  |    ... (and so on) ...             # AudioOutputDeviceAlsa #
242       *    |  |    |  |                                  #########################       *  |  |  |  |                                    #########################
243       *    |  |    |  \----------------------------------------------------\       *  |  |  |  \-----------------------------------------------------\
244       *    |  |    \-------------------------------------------\           |       *  |  |  \--------------------------------------------\           |
245       *    |  \--------------------\                           |           |       *  |  \--------------------\                          |           |
246       *    |                       |                           |           |       *  |                       |                          |           |
247       *  ####################### ####################### #######################       * ####################### ####################### #######################
248       *  # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #       * # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #
249       *  ####################### ####################### #######################       * ####################### ####################### #######################
250         * @endcode
251       *       *
252       * As you can see in this example setup, one device (that is midi input       * As you can see in this example setup, one device (that is midi input
253       * driver / audio output driver) can be connected multiple times to       * driver / audio output driver) can be connected multiple times to
254       * different sampler channels.       * different sampler channels.
255         *
256         * It's even possible to create multiple instances of the same driver, for
257         * example multiple instances of the Alsa output driver to use multiple
258         * sound cards at the same time, or multiple instances of the JACK audio
259         * output driver to leverage SMP systems or boxes with several hard discs.
260       */       */
261      class Sampler {      class Sampler {
262          public:          public:
# Line 194  namespace LinuxSampler { Line 268  namespace LinuxSampler {
268              /**              /**
269               * Destructor.               * Destructor.
270               */               */
271             ~Sampler();              virtual ~Sampler();
272    
273              /**              /**
274               * Returns the number of sampler channels currently allocated.               * Returns the number of sampler channels currently allocated.
# Line 202  namespace LinuxSampler { Line 276  namespace LinuxSampler {
276              uint SamplerChannels();              uint SamplerChannels();
277    
278              /**              /**
279               * Create and add a new sampler channel to this Sampler instance.               * Create and add a new sampler channel to this Sampler
280                 * instance. For race condition reasons the new channel will use
281                 * an index past the last already existing sampler channel
282                 * index (in case the index limit was not reached yet, otherwise
283                 * a free index starting from 0 is searched).
284               *               *
285               * @returns  pointer to new sampler channel               * @returns  pointer to new sampler channel
286               */               */
# Line 217  namespace LinuxSampler { Line 295  namespace LinuxSampler {
295              SamplerChannel* GetSamplerChannel(uint uiSamplerChannel);              SamplerChannel* GetSamplerChannel(uint uiSamplerChannel);
296    
297              /**              /**
298                 * Returns all created sampler channels.
299                 */
300                std::map<uint, SamplerChannel*> GetSamplerChannels();
301    
302                /**
303               * Destroy and remove the given sampler channel from this               * Destroy and remove the given sampler channel from this
304               * Sampler instance.               * Sampler instance.
305               *               *
# Line 233  namespace LinuxSampler { Line 316  namespace LinuxSampler {
316               */               */
317              void RemoveSamplerChannel(uint uiSamplerChannel);              void RemoveSamplerChannel(uint uiSamplerChannel);
318    
319                /**
320                 * Registers the specified listener to be notified
321                 * when the number of sampler chanels is changed.
322                 */
323                void AddChannelCountListener(ChannelCountListener* l);
324    
325                /**
326                 * Removes the specified listener.
327                 */
328                void RemoveChannelCountListener(ChannelCountListener* l);
329    
330                /**
331                 * Registers the specified listener to be notified
332                 * when the number of audio output devices is changed.
333                 */
334                void AddAudioDeviceCountListener(AudioDeviceCountListener* l);
335    
336                /**
337                 * Removes the specified listener.
338                 */
339                void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);
340    
341                
342                /**
343                 * Registers the specified listener to be notified
344                 * when the number of MIDI input devices is changed.
345                 */
346                void AddMidiDeviceCountListener(MidiDeviceCountListener* l);
347    
348                /**
349                 * Removes the specified listener.
350                 */
351                void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l);
352    
353                /**
354                 * Registers the specified listener to be notified when the number
355                 * of active voices in a particular sampler channel is changed.
356                 */
357                void AddVoiceCountListener(VoiceCountListener* l);
358    
359                /**
360                 * Removes the specified listener.
361                 */
362                void RemoveVoiceCountListener(VoiceCountListener* l);
363    
364                /**
365                 * Notifies listeners that the number of active voices
366                 * on the specified sampler channel is changed.
367                 * @param ChannelId The numerical ID of the sampler channel.
368                 * @param NewCount The new number of active voices.
369                 */
370                void fireVoiceCountChanged(int ChannelId, int NewCount);
371    
372                /**
373                 * Registers the specified listener to be notified when the number
374                 * of active disk streams in a particular sampler channel is changed.
375                 */
376                void AddStreamCountListener(StreamCountListener* l);
377    
378                /**
379                 * Removes the specified listener.
380                 */
381                void RemoveStreamCountListener(StreamCountListener* l);
382    
383                /**
384                 * Notifies listeners that the number of active disk streams
385                 * on the specified sampler channel is changed.
386                 * @param ChannelId The numerical ID of the sampler channel.
387                 * @param NewCount The new number of active disk streams.
388                 */
389                void fireStreamCountChanged(int ChannelId, int NewCount);
390    
391                /**
392                 * Registers the specified listener to be
393                 * notified when the fill state of the disk stream
394                 * buffers on a specific sampler channel is changed.
395                 */
396                void AddBufferFillListener(BufferFillListener* l);
397    
398                /**
399                 * Removes the specified listener.
400                 */
401                void RemoveBufferFillListener(BufferFillListener* l);
402    
403                /**
404                 * Notifies listeners that the fill state of the disk stream
405                 * buffers on the specified sampler channel is changed.
406                 * @param ChannelId The numerical ID of the sampler channel.
407                 * @param FillData The buffer fill data for the specified sampler channel.
408                 */
409                void fireBufferFillChanged(int ChannelId, String FillData);
410    
411                /**
412                 * Registers the specified listener to be notified
413                 * when total number of active voices is changed.
414                 */
415                void AddTotalVoiceCountListener(TotalVoiceCountListener* l);
416    
417                /**
418                 * Removes the specified listener.
419                 */
420                void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l);
421    
422                /**
423                 * Notifies listeners that the total number of active voices is changed.
424                 * @param NewCount The new number of active voices.
425                 */
426                void fireTotalVoiceCountChanged(int NewCount);
427                
428                void AddTotalStreamCountListener(TotalStreamCountListener* l);
429                void RemoveTotalStreamCountListener(TotalStreamCountListener* l);
430                void fireTotalStreamCountChanged(int NewCount);
431    
432                /**
433                 * Registers the specified listener to be notified when the number
434                 * of effect sends on a particular sampler channel is changed.
435                 */
436                void AddFxSendCountListener(FxSendCountListener* l);
437    
438                /**
439                 * Removes the specified listener.
440                 */
441                void RemoveFxSendCountListener(FxSendCountListener* l);
442    
443                /**
444                 * Returns the names of all available audio output drivers.
445                 */
446              std::vector<String> AvailableAudioOutputDrivers();              std::vector<String> AvailableAudioOutputDrivers();
447    
448              /**              /**
449                 * Returns the names of all available MIDI input drivers.
450                 */
451                std::vector<String> AvailableMidiInputDrivers();
452    
453                /**
454                 * Returns the names of all available sampler engine types.
455                 * @see SamplerChannel::SetEngineType()
456                 */
457                std::vector<String> AvailableEngineTypes();
458    
459                /**
460               * Create an audio output device.               * Create an audio output device.
461               *               *
462               * @param AudioDriver - name of the audio driver               * @param AudioDriver - name of the audio driver
463               * @param Parameters - eventually needed driver parameters to               * @param Parameters - eventually needed driver parameters to
464               *                     create the device               *                     create the device
465               * @returns  pointer to created audio output device               * @returns  pointer to created audio output device
466               * @throws LinuxSamplerException  if device could not be created               * @throws Exception  if device could not be created
467               */               */
468              AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (LinuxSamplerException);              AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception);
469    
470              /**              /**
471               * Create a midi input device.               * Create a midi input device.
# Line 253  namespace LinuxSampler { Line 474  namespace LinuxSampler {
474               * @param Parameters - eventually needed driver parameters to               * @param Parameters - eventually needed driver parameters to
475               *                     create the device               *                     create the device
476               * @returns  pointer to created midi input device               * @returns  pointer to created midi input device
477               * @throws LinuxSamplerException  if device could not be created               * @throws Exception  if device could not be created
478               */               */
479              MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException);              MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);
480    
481                /**
482                 * Returns the number of all created audio output devices.
483                 */
484              uint AudioOutputDevices();              uint AudioOutputDevices();
485    
486                /**
487                 * Returns the number of all created MIDI input devices.
488                 */
489              uint MidiInputDevices();              uint MidiInputDevices();
490    
491                /**
492                 * Returns all created audio output devices.
493                 */
494              std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();              std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();
495    
496                /**
497                 * Returns all created MIDI input devices.
498                 */
499              std::map<uint, MidiInputDevice*> GetMidiInputDevices();              std::map<uint, MidiInputDevice*> GetMidiInputDevices();
500    
501              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (LinuxSamplerException);              /**
502              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException);               * Destroy the given audio output device and takes care if there
503                 * are still sampler angines connected to this device, etc.
504                 *
505                 * @throws Exception  if sampler channels are still
506                 *                    connected to the device
507                 */
508                void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);
509    
510                /**
511                 * Destroy the given MIDI input device and takes care if there
512                 * are still sampler angines connected to this device, etc.
513                 *
514                 * @throws Exception  if sampler channels are still
515                 *                    connected to the device
516                 */
517                void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);
518    
519                 /**
520                 * Gets the current number of all active streams.
521                 * @returns The current number of all active streams.
522                 */
523                int GetDiskStreamCount();
524    
525                /**
526                 * Gets the current number of all active voices.
527                 * @returns The current number of all active voices.
528                 */
529                int GetVoiceCount();
530    
531                /**
532                 * Reset the whole sampler. Destroy all engines, sampler
533                 * channels, MIDI input devices and audio output devices.
534                 */
535                void Reset();
536    
537                /**
538                 * Advise the FPU to treat denormal floating point numbers as
539                 * zero, to avoid severe performance penalty when dealing with
540                 * such extreme floating point values.
541                 *
542                 * @returns @c true if FPU supports it, @c false otherwise
543                 */
544                static bool EnableDenormalsAreZeroMode();
545    
546                /**
547                 * Notifies listeners about the current number of voices,
548                 * streams and total voices, and the current fill state of
549                 * the disk stream buffers.
550                 */
551                void fireStatistics();
552    
553          protected:          protected:
554                /**
555                 * Notifies listeners that the number of sampler channels has been changed.
556                 * @param NewCount The new number of sampler channels.
557                 */
558                void fireChannelCountChanged(int NewCount);
559    
560                /**
561                 * Notifies listeners that the specified sampler channel has just
562                 * been added.
563                 * @param pChannel The new sampler channel.
564                 */
565                void fireChannelAdded(SamplerChannel* pChannel);
566    
567                /**
568                 * Notifies listeners that the specified sampler channel is
569                 * going to be removed soon.
570                 * @param pChannel sampler channel to be removed.
571                 */
572                void fireChannelToBeRemoved(SamplerChannel* pChannel);
573    
574                /**
575                 * Notifies listeners that the number of audio output devices has been changed.
576                 * @param NewCount The new number of audio output devices.
577                 */
578                void fireAudioDeviceCountChanged(int NewCount);
579    
580                /**
581                 * Notifies listeners that the number of MIDI input devices has been changed.
582                 * @param NewCount The new number of MIDI input devices.
583                 */
584                void fireMidiDeviceCountChanged(int NewCount);
585    
586                /**
587                 * Notifies listeners that the supplied MIDI input device is
588                 * going to be destroyed soon.
589                 * @param pDevice MIDI input device to be destroyed
590                 */
591                void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice);
592    
593                /**
594                 * Notifies listeners that the supplied MIDI input device was
595                 * just created.
596                 * @param pDevice new MIDI input device
597                 */
598                void fireMidiDeviceCreated(MidiInputDevice* pDevice);
599    
600                /**
601                 * Notifies listeners that the number of effect sends
602                 * on a particular sampler channel is changed.
603                 * @param ChannelId The numerical ID of the sampler channel.
604                 * @param NewCount The new number of sampler channels.
605                 */
606                void fireFxSendCountChanged(int ChannelId, int NewCount);
607    
608              typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;              typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;
609              typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;              typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;
610                typedef std::map<uint, SamplerChannel*> SamplerChannelMap;
611    
612              std::vector<SamplerChannel*> vSamplerChannels;   ///< contains all created sampler channels              SamplerChannelMap     mSamplerChannels;    ///< contains all created sampler channels
613              AudioOutputDeviceMap         mAudioOutputDevices; ///< contains all created audio output devices              AudioOutputDeviceMap  mAudioOutputDevices; ///< contains all created audio output devices
614              MidiInputDeviceMap           mMidiInputDevices;              MidiInputDeviceMap    mMidiInputDevices;   ///< contains all created MIDI input devices
615    
616              template<class T> inline String ToString(T o) {              // statistics cache
617                  std::stringstream ss;              uint uiOldTotalVoiceCount;
618                  ss << o;              uint uiOldTotalStreamCount;
619                  return ss.str();              std::map<uint, uint> mOldVoiceCounts;
620              }              std::map<uint, uint> mOldStreamCounts;
621    
622              friend class SamplerChannel;              friend class SamplerChannel;
623    
624            private:
625                ListenerList<ChannelCountListener*> llChannelCountListeners;
626                ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners;
627                ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners;
628                ListenerList<VoiceCountListener*> llVoiceCountListeners;
629                ListenerList<StreamCountListener*> llStreamCountListeners;
630                ListenerList<BufferFillListener*> llBufferFillListeners;
631                ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners;
632                ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;
633                ListenerList<FxSendCountListener*> llFxSendCountListeners;
634    
635                class EventHandler : public EngineChangeListener, public FxSendCountListener {
636                    public:
637                        void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }
638    
639                        /**
640                         * Invoked when the engine type of the specified sampler
641                         * channel is going to be changed soon.
642                         * @param ChannelId The numerical ID of the sampler channel
643                         */
644                        virtual void EngineToBeChanged(int ChannelId);
645    
646                        /**
647                         * Invoked when the engine type of the
648                         * specified sampler channel is changed.
649                         * @param ChannelId The numerical ID of the sampler
650                         * channel, which engine type has been changed.
651                         */
652                        virtual void EngineChanged(int ChannelId);
653    
654                        /**
655                         * Invoked when the number of effect sends
656                         * on the specified sampler channel has changed.
657                         * @param ChannelId The numerical ID of the sampler channel.
658                         * @param NewCount The new number of effect sends.
659                         */
660                        virtual void FxSendCountChanged(int ChannelId, int NewCount);
661    
662                    private:
663                        Sampler* pSampler;
664                } eventHandler;
665      };      };
666  }  }
667    

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

  ViewVC Help
Powered by ViewVC