/[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 221 by schoenebeck, Fri Aug 20 17:25:19 2004 UTC revision 1934 by schoenebeck, Sun Jul 12 10:35:55 2009 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 - 2009 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 "drivers/midi/MidiInputDevice.h"  #include "drivers/midi/MidiInputDevice.h"
34  #include "drivers/audio/AudioOutputDevice.h"  #include "drivers/audio/AudioOutputDevice.h"
35    
# Line 36  namespace LinuxSampler { Line 38  namespace LinuxSampler {
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 device.               * Connect this sampler channel to a MIDI input device.
72               *               *
73               * @param pDevice - MIDI input device to connect to               * @param pDevice - MIDI input device to connect to
74               */               */
75              void SetMidiInputDevice(MidiInputDevice *pDevice);              void SetMidiInputDevice(MidiInputDevice *pDevice);
76    
77              /**              /**
78               * Connect this sampler channel to and MIDI input port.               * Connect this sampler channel to a MIDI input port.
79               *               *
80               * @param MidiPort - MIDI port to connect to               * @param MidiPort - MIDI port to connect to
81               */               */
82              void SetMidiInputPort(int MidiPort);              void SetMidiInputPort(int MidiPort);
83    
84              /**              /**
85               * Connect this sampler channel to and MIDI input channel.               * 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 connect to               * @param MidiChannel - MIDI channel to listen
91               */               */
92              void SetMidiInputChannel(MidiInputPort::midi_chan_t MidiChannel);              void SetMidiInputChannel(midi_chan_t MidiChannel);
93    
94              /**              /**
95               * Connect this sampler channel to a MIDI input triplet.               * Connect this sampler channel to a MIDI input triplet.
# Line 96  namespace LinuxSampler { Line 100  namespace LinuxSampler {
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 SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, MidiInputPort::midi_chan_t MidiChannel = 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 channel to which this sampler               * Returns the MIDI input channel to which this sampler
# Line 112  namespace LinuxSampler { Line 117  namespace LinuxSampler {
117               * @returns  The MIDI input channel on which the sampler               * @returns  The MIDI input channel on which the sampler
118               *           channel is listening to.               *           channel is listening to.
119               */               */
120              MidiInputPort::midi_chan_t GetMidiInputChannel();              midi_chan_t GetMidiInputChannel();
121    
122              /**              /**
123               * Returns the MIDI input port number to which this sampler               * Returns the MIDI input port number to which this sampler
# Line 146  namespace LinuxSampler { Line 151  namespace LinuxSampler {
151               */               */
152              uint Index();              uint Index();
153    
154                /** Returns the sampler to which this channel belongs */
155                Sampler* GetSampler();
156    
157                ///////////////////////////////////////////////////////////////
158                // Event Listener methods
159    
160                /**
161                 * Registers the specified listener to be notified
162                 * when the engine type of this sampler channel is changed.
163                 */
164                void AddEngineChangeListener(EngineChangeListener* l);
165    
166                /**
167                 * Removes the specified listener.
168                 */
169                void RemoveEngineChangeListener(EngineChangeListener* l);
170    
171                /**
172                 * Removes the specified listener.
173                 */
174                void RemoveAllEngineChangeListeners();
175    
176                /**
177                 * Notifies listeners that the engine type of this sampler
178                 * channel is going to be changed soon.
179                 */
180                void fireEngineToBeChanged();
181    
182                /**
183                 * Notifies listeners that the engine
184                 * type of this sampler channel is changed.
185                 */
186                void fireEngineChanged();
187    
188    
189          protected:          protected:
190              SamplerChannel(Sampler* pS);              SamplerChannel(Sampler* pS);
191             ~SamplerChannel();              virtual ~SamplerChannel();
192    
193              /** Getting MIDI input device port given its index number. */              /** Getting MIDI input device port given its index number. */
194              MidiInputPort* GetMidiInputDevicePort(int iMidiPort);              MidiInputPort* __GetMidiInputDevicePort(int iMidiPort);
195    
196              Sampler*           pSampler;              Sampler*           pSampler;
197              Engine*            pEngine;              EngineChannel*     pEngineChannel;
198              AudioOutputDevice* pAudioOutputDevice;              AudioOutputDevice* pAudioOutputDevice;
199              MidiInputDevice*   pMidiInputDevice;              MidiInputDevice*   pMidiInputDevice;
             int                midiPort;  
             MidiInputPort::midi_chan_t midiChannel;  
200              int                iIndex;              int                iIndex;
201    
202              friend class Sampler;              friend class Sampler;
203            private:
204                int                iMidiPort;   ///< Don't access directly, read GetMidiInputPort() instead !
205                midi_chan_t        midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead !
206                ListenerList<EngineChangeListener*> llEngineChangeListeners;
207      };      };
208    
209      /** LinuxSampler main class      /** @brief LinuxSampler main class
210       *       *
211       * This is the toplevel class for a LinuxSampler instance.       * This is the toplevel class for a LinuxSampler instance.
212       *       *
# Line 172  namespace LinuxSampler { Line 214  namespace LinuxSampler {
214       * sampler channel can individually be deployed with it's own sampler       * sampler channel can individually be deployed with it's own sampler
215       * engine, connected to an arbitrary MIDI input device and connected to       * engine, connected to an arbitrary MIDI input device and connected to
216       * an arbitrary audio output device. Here an example setup:       * an arbitrary audio output device. Here an example setup:
217         * @code
218         * S.Channel    MIDI in    S.Engine         Audio out
219         * -------------------------------------------------------------------
220         *   0          Alsa   ->  gig::Engine  ->  Jack
221         *   1          VSTi   ->  Akai::Engine ->  VSTi
222         *   2          Jack   ->  DLS::Engine  ->  Jack
223         *   3          Jack   ->  SF::Engine   ->  Alsa
224       *       *
225       *  S.Channel.      MIDI in         S.Engine                Audio out       * ... (and so on) ...
226       *  -------------------------------------------------------------------       * @endcode
      *  0               Alsa    ->      gig::Engine     ->      Jack  
      *  1               VSTi    ->      Akai::Engine    ->      VSTi  
      *  2               Jack    ->      DLS::Engine     ->      Jack  
      *  3               Jack    ->      SF::Engine      ->      Alsa  
      *  
      *  ... (and so on) ...  
227       *       *
228       * Note that not all audio and MIDI backends and sampler engines listed       * Note that not all audio and MIDI backends and sampler engines listed
229       * in the example above are already implemented!       * in the example above might already been implemented!
230       *       *
231       * 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
232       * several, different audio output and MIDI input systems       * several, different audio output and MIDI input systems
233       * simultaniously at the same time. Here the example setup shown in the       * simultaniously at the same time. Here the example setup shown in the
234       * ascpect of MIDI input and audio output devices / drivers:       * aspect of MIDI input and audio output devices / drivers:
235       *       * @code
236       *                            ######################### #########################       *                      ######################### #########################
237       *                            # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #       *                      # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #
238       *                            ######################### #########################       *                      ######################### #########################
239       *                                          ^   ^           ^       *                                        ^   ^           ^
240       *    /------------>|Sampler Channel 0|-----/   |           |       *  /------------>|Sampler Channel 0|-----/   |           |
241       *    |  /--------->|Sampler Channel 1|---------------------/       *  |  /--------->|Sampler Channel 1|---------------------/
242       *    |  |    /---->|Sampler Channel 2|---------/       *  |  |  /------>|Sampler Channel 2|---------/
243       *    |  |    |  /->|Sampler Channel 3|------------>#########################       *  |  |  |  /--->|Sampler Channel 3|------------>#########################
244       *    |  |    |  |  ... (and so on) ...             # AudioOutputDeviceAlsa #       *  |  |  |  |    ... (and so on) ...             # AudioOutputDeviceAlsa #
245       *    |  |    |  |                                  #########################       *  |  |  |  |                                    #########################
246       *    |  |    |  \----------------------------------------------------\       *  |  |  |  \-----------------------------------------------------\
247       *    |  |    \-------------------------------------------\           |       *  |  |  \--------------------------------------------\           |
248       *    |  \--------------------\                           |           |       *  |  \--------------------\                          |           |
249       *    |                       |                           |           |       *  |                       |                          |           |
250       *  ####################### ####################### #######################       * ####################### ####################### #######################
251       *  # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #       * # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #
252       *  ####################### ####################### #######################       * ####################### ####################### #######################
253         * @endcode
254       *       *
255       * 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
256       * driver / audio output driver) can be connected multiple times to       * driver / audio output driver) can be connected multiple times to
257       * different sampler channels.       * different sampler channels.
258         *
259         * It's even possible to create multiple instances of the same driver, for
260         * example multiple instances of the Alsa output driver to use multiple
261         * sound cards at the same time, or multiple instances of the JACK audio
262         * output driver to leverage SMP systems or boxes with several hard discs.
263       */       */
264      class Sampler {      class Sampler {
265          public:          public:
# Line 222  namespace LinuxSampler { Line 271  namespace LinuxSampler {
271              /**              /**
272               * Destructor.               * Destructor.
273               */               */
274             ~Sampler();              virtual ~Sampler();
275    
276              /**              /**
277               * Returns the number of sampler channels currently allocated.               * Returns the number of sampler channels currently allocated.
# Line 271  namespace LinuxSampler { Line 320  namespace LinuxSampler {
320              void RemoveSamplerChannel(uint uiSamplerChannel);              void RemoveSamplerChannel(uint uiSamplerChannel);
321    
322              /**              /**
323                 * Destroy and remove all sampler channels from this
324                 * Sampler instance.
325                 */
326                void RemoveAllSamplerChannels();
327    
328                /**
329               * Returns the names of all available audio output drivers.               * Returns the names of all available audio output drivers.
330               */               */
331              std::vector<String> AvailableAudioOutputDrivers();              std::vector<String> AvailableAudioOutputDrivers();
332    
333              /**              /**
334                 * Returns the names of all available MIDI input drivers.
335                 */
336                std::vector<String> AvailableMidiInputDrivers();
337    
338                /**
339                 * Returns the names of all available sampler engine types.
340                 * @see SamplerChannel::SetEngineType()
341                 */
342                std::vector<String> AvailableEngineTypes();
343    
344                /**
345               * Create an audio output device.               * Create an audio output device.
346               *               *
347               * @param AudioDriver - name of the audio driver               * @param AudioDriver - name of the audio driver
348               * @param Parameters - eventually needed driver parameters to               * @param Parameters - eventually needed driver parameters to
349               *                     create the device               *                     create the device
350               * @returns  pointer to created audio output device               * @returns  pointer to created audio output device
351               * @throws LinuxSamplerException  if device could not be created               * @throws Exception  if device could not be created
352               */               */
353              AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (LinuxSamplerException);              AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception);
354    
355              /**              /**
356               * Create a midi input device.               * Create a midi input device.
# Line 293  namespace LinuxSampler { Line 359  namespace LinuxSampler {
359               * @param Parameters - eventually needed driver parameters to               * @param Parameters - eventually needed driver parameters to
360               *                     create the device               *                     create the device
361               * @returns  pointer to created midi input device               * @returns  pointer to created midi input device
362               * @throws LinuxSamplerException  if device could not be created               * @throws Exception  if device could not be created
363               */               */
364              MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException);              MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);
365    
366              /**              /**
367               * Returns the number of all created audio output devices.               * Returns the number of all created audio output devices.
# Line 319  namespace LinuxSampler { Line 385  namespace LinuxSampler {
385    
386              /**              /**
387               * Destroy the given audio output device and takes care if there               * Destroy the given audio output device and takes care if there
388               * are still sampler angines connected to this device, etc.               * are still sampler engines connected to this device, etc.
389               *               *
390               * @throws LinuxSamplerException  if sampler channels are still               * @throws Exception  if sampler channels are still
391               *                                connected to the device               *                    connected to the device
392               */               */
393              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (LinuxSamplerException);              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);
394    
395                /**
396                 * Destroy all audio output devices and takes care if there
397                 * are still sampler engines connected to devices, etc.
398                 *
399                 * Note: non-autonomous devices, that is devices associated with
400                 * host plugin instances like VST, AU, DSSI, LV2 are not
401                 * destroyed by this method.
402                 *
403                 * @throws Exception  if sampler channels are still
404                 *                    connected to device
405                 */
406                void DestroyAllAudioOutputDevices() throw (Exception);
407    
408              /**              /**
409               * Destroy the given MIDI input device and takes care if there               * Destroy the given MIDI input device and takes care if there
410               * are still sampler angines connected to this device, etc.               * are still sampler engines connected to this device, etc.
411                 *
412                 * @throws Exception  if sampler channels are still
413                 *                    connected to the device
414                 */
415                void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);
416    
417                /**
418                 * Destroy all MIDI input devices and take care if there
419                 * are still sampler engines connected to device, etc.
420                 *
421                 * Note: non-autonomous devices, that is devices associated with
422                 * host plugin instances like VST, AU, DSSI, LV2 are not
423                 * destroyed by this method.
424               *               *
425               * @throws LinuxSamplerException  if sampler channels are still               * @throws Exception  if sampler channels are still
426               *                                connected to the device               *                    connected to device
427                 */
428                void DestroyAllMidiInputDevices() throw (Exception);
429    
430                 /**
431                 * Gets the current number of all active streams.
432                 * @returns The current number of all active streams.
433               */               */
434              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException);              int GetDiskStreamCount();
435    
436                /**
437                 * Gets the current number of all active voices.
438                 * @returns The current number of all active voices.
439                 */
440                int GetVoiceCount();
441    
442              /**              /**
443               * Reset the whole sampler. Destroy all engines, sampler               * Reset the whole sampler. Destroy all engines, sampler
# Line 341  namespace LinuxSampler { Line 445  namespace LinuxSampler {
445               */               */
446              void Reset();              void Reset();
447    
448                ///////////////////////////////////////////////////////////////
449                // Event Listener methods
450    
451                /**
452                 * Registers the specified listener to be notified
453                 * when the number of sampler chanels is changed.
454                 */
455                void AddChannelCountListener(ChannelCountListener* l);
456    
457                /**
458                 * Removes the specified listener.
459                 */
460                void RemoveChannelCountListener(ChannelCountListener* l);
461    
462                /**
463                 * Registers the specified listener to be notified
464                 * when the number of audio output devices is changed.
465                 */
466                void AddAudioDeviceCountListener(AudioDeviceCountListener* l);
467    
468                /**
469                 * Removes the specified listener.
470                 */
471                void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);
472    
473                /**
474                 * Registers the specified listener to be notified
475                 * when the number of MIDI input devices is changed.
476                 */
477                void AddMidiDeviceCountListener(MidiDeviceCountListener* l);
478    
479                /**
480                 * Removes the specified listener.
481                 */
482                void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l);
483    
484                /**
485                 * Registers the specified listener to be notified when the number
486                 * of active voices in a particular sampler channel is changed.
487                 */
488                void AddVoiceCountListener(VoiceCountListener* l);
489    
490                /**
491                 * Removes the specified listener.
492                 */
493                void RemoveVoiceCountListener(VoiceCountListener* l);
494    
495                /**
496                 * Notifies listeners that the number of active voices
497                 * on the specified sampler channel is changed.
498                 * @param ChannelId The numerical ID of the sampler channel.
499                 * @param NewCount The new number of active voices.
500                 */
501                void fireVoiceCountChanged(int ChannelId, int NewCount);
502    
503                /**
504                 * Registers the specified listener to be notified when the number
505                 * of active disk streams in a particular sampler channel is changed.
506                 */
507                void AddStreamCountListener(StreamCountListener* l);
508    
509                /**
510                 * Removes the specified listener.
511                 */
512                void RemoveStreamCountListener(StreamCountListener* l);
513    
514                /**
515                 * Notifies listeners that the number of active disk streams
516                 * on the specified sampler channel is changed.
517                 * @param ChannelId The numerical ID of the sampler channel.
518                 * @param NewCount The new number of active disk streams.
519                 */
520                void fireStreamCountChanged(int ChannelId, int NewCount);
521    
522                /**
523                 * Registers the specified listener to be
524                 * notified when the fill state of the disk stream
525                 * buffers on a specific sampler channel is changed.
526                 */
527                void AddBufferFillListener(BufferFillListener* l);
528    
529                /**
530                 * Removes the specified listener.
531                 */
532                void RemoveBufferFillListener(BufferFillListener* l);
533    
534                /**
535                 * Notifies listeners that the fill state of the disk stream
536                 * buffers on the specified sampler channel is changed.
537                 * @param ChannelId The numerical ID of the sampler channel.
538                 * @param FillData The buffer fill data for the specified sampler channel.
539                 */
540                void fireBufferFillChanged(int ChannelId, String FillData);
541    
542                /**
543                 * Registers the specified listener to be notified
544                 * when total number of active voices is changed.
545                 */
546                void AddTotalVoiceCountListener(TotalVoiceCountListener* l);
547    
548                /**
549                 * Removes the specified listener.
550                 */
551                void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l);
552    
553                /**
554                 * Notifies listeners that the total number of active voices is changed.
555                 * @param NewCount The new number of active voices.
556                 */
557                void fireTotalVoiceCountChanged(int NewCount);
558    
559                /**
560                 * Registers the specified listener to be notified when the number
561                 * of total streams is changed.
562                 */
563                void AddTotalStreamCountListener(TotalStreamCountListener* l);
564    
565                /**
566                 * Removes the specified listener.
567                 */
568                void RemoveTotalStreamCountListener(TotalStreamCountListener* l);
569    
570                /**
571                 * Notifies listeners that the total number of total streams changed.
572                 * @param NewCount The new number of total streams.
573                 */
574                void fireTotalStreamCountChanged(int NewCount);
575    
576                /**
577                 * Registers the specified listener to be notified when the number
578                 * of effect sends on a particular sampler channel is changed.
579                 */
580                void AddFxSendCountListener(FxSendCountListener* l);
581    
582                /**
583                 * Removes the specified listener.
584                 */
585                void RemoveFxSendCountListener(FxSendCountListener* l);
586    
587                /**
588                 * Notifies listeners about the current number of voices,
589                 * streams and total voices, and the current fill state of
590                 * the disk stream buffers.
591                 */
592                void fireStatistics();
593    
594                ///////////////////////////////////////////////////////////////
595                // system specific methods
596    
597                /**
598                 * Advise the FPU to treat denormal floating point numbers as
599                 * zero, to avoid severe performance penalty when dealing with
600                 * such extreme floating point values.
601                 *
602                 * @returns @c true if FPU supports it, @c false otherwise
603                 */
604                static bool EnableDenormalsAreZeroMode();
605    
606    #if defined(WIN32)
607                /**
608                 * Gets the directory where the liblinuxsampler dll is located.
609                 * Note: this method is currently only available for Windows.
610                 * @returns installation directory
611                 */
612                static String GetInstallDir();
613    #endif
614          protected:          protected:
615              typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;              /**
616              typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;               * Notifies listeners that the number of sampler channels has been changed.
617                 * @param NewCount The new number of sampler channels.
618                 */
619                void fireChannelCountChanged(int NewCount);
620    
621                /**
622                 * Notifies listeners that the specified sampler channel has just
623                 * been added.
624                 * @param pChannel The new sampler channel.
625                 */
626                void fireChannelAdded(SamplerChannel* pChannel);
627    
628                /**
629                 * Notifies listeners that the specified sampler channel is
630                 * going to be removed soon.
631                 * @param pChannel sampler channel to be removed.
632                 */
633                void fireChannelToBeRemoved(SamplerChannel* pChannel);
634    
635                /**
636                 * Notifies listeners that the number of audio output devices has been changed.
637                 * @param NewCount The new number of audio output devices.
638                 */
639                void fireAudioDeviceCountChanged(int NewCount);
640    
641                /**
642                 * Notifies listeners that the number of MIDI input devices has been changed.
643                 * @param NewCount The new number of MIDI input devices.
644                 */
645                void fireMidiDeviceCountChanged(int NewCount);
646    
647                /**
648                 * Notifies listeners that the supplied MIDI input device is
649                 * going to be destroyed soon.
650                 * @param pDevice MIDI input device to be destroyed
651                 */
652                void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice);
653    
654                /**
655                 * Notifies listeners that the supplied MIDI input device was
656                 * just created.
657                 * @param pDevice new MIDI input device
658                 */
659                void fireMidiDeviceCreated(MidiInputDevice* pDevice);
660    
661                /**
662                 * Notifies listeners that the number of effect sends
663                 * on a particular sampler channel is changed.
664                 * @param ChannelId The numerical ID of the sampler channel.
665                 * @param NewCount The new number of sampler channels.
666                 */
667                void fireFxSendCountChanged(int ChannelId, int NewCount);
668    
669              typedef std::map<uint, SamplerChannel*> SamplerChannelMap;              typedef std::map<uint, SamplerChannel*> SamplerChannelMap;
670    
671              SamplerChannelMap     mSamplerChannels;    ///< contains all created sampler channels              SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels
672              AudioOutputDeviceMap  mAudioOutputDevices; ///< contains all created audio output devices  
673              MidiInputDeviceMap    mMidiInputDevices;   ///< contains all created MIDI input devices              // statistics cache
674                uint uiOldTotalVoiceCount;
675                uint uiOldTotalStreamCount;
676                std::map<uint, uint> mOldVoiceCounts;
677                std::map<uint, uint> mOldStreamCounts;
678    
679              friend class SamplerChannel;              friend class SamplerChannel;
680    
681            private:
682                ListenerList<ChannelCountListener*> llChannelCountListeners;
683                ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners;
684                ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners;
685                ListenerList<VoiceCountListener*> llVoiceCountListeners;
686                ListenerList<StreamCountListener*> llStreamCountListeners;
687                ListenerList<BufferFillListener*> llBufferFillListeners;
688                ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners;
689                ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;
690                ListenerList<FxSendCountListener*> llFxSendCountListeners;
691    
692                class EventHandler : public EngineChangeListener, public FxSendCountListener {
693                    public:
694                        void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }
695    
696                        /**
697                         * Invoked when the engine type of the specified sampler
698                         * channel is going to be changed soon.
699                         * @param ChannelId The numerical ID of the sampler channel
700                         */
701                        virtual void EngineToBeChanged(int ChannelId);
702    
703                        /**
704                         * Invoked when the engine type of the
705                         * specified sampler channel is changed.
706                         * @param ChannelId The numerical ID of the sampler
707                         * channel, which engine type has been changed.
708                         */
709                        virtual void EngineChanged(int ChannelId);
710    
711                        /**
712                         * Invoked when the number of effect sends
713                         * on the specified sampler channel has changed.
714                         * @param ChannelId The numerical ID of the sampler channel.
715                         * @param NewCount The new number of effect sends.
716                         */
717                        virtual void FxSendCountChanged(int ChannelId, int NewCount);
718    
719                    private:
720                        Sampler* pSampler;
721                } eventHandler;
722      };      };
723  }  }
724    

Legend:
Removed from v.221  
changed lines
  Added in v.1934

  ViewVC Help
Powered by ViewVC