/[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 57 by schoenebeck, Sun May 2 17:45:43 2004 UTC revision 1937 by schoenebeck, Sun Jul 12 19:52:20 2009 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003 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 "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    
     /**  
      * Which sampler engine to be used.  
      */  
     enum engine_type_t {  
         engine_type_gig  
     };  
   
     /**  
      * Which audio output system to be used.  
      */  
     enum audio_output_type_t {  
         audio_output_type_alsa,  
         audio_output_type_jack  
     };  
   
     /**  
      * Which MIDI input system to be used.  
      */  
     enum midi_input_type_t {  
         midi_input_type_alsa  
     };  
   
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 you 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);              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
62               * is audio output driver) of the given type. If the audio               * is an instance of an audio output driver. If this sampler
63               * output for the desired audio output system is not yet               * channel was already connected to an audio output device, then
64               * created, then it will be created automatically, but with               * the old connection will automatically be removed before.
              * default settings though. If this sampler channel was already  
              * connected to an audio output device, then the old connection  
              * will automatically be removed before.  
65               *               *
66               * @param AudioType - audio output system to connect to               * @param pDevice - audio output device to connect to
67                 * @throws Exception in case the audio device is tried to be
68                 *                   changed while the sampler channel is used by a
69                 *                   host plugin (e.g. VST, AU, DSSI, LV2) which
70                 *                   don't allow to change the audio output device
71               */               */
72              void SetAudioOutputDevice(audio_output_type_t AudioType);              void SetAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);
73    
74              /**              /**
75               * Connect this sampler channel to and MIDI input device (that               * Connect this sampler channel to a MIDI input device.
              * is MIDI input driver) of the given type. If the MIDI input  
              * driver for the desired MIDI input system is not yet created,  
              * then it will be created automatically, but with default  
              * settings though. If this sampler channel was already  
              * connected to a MIDI input device, then the old connection  
              * will automatically be removed before.  
76               *               *
77               * @param MidiType    - MIDI input system to connect to               * @param pDevice - MIDI input device to connect to
78                 * @throws Exception in case the MIDI device is tried to be changed
79                 *                   while the sampler channel is being used by a
80                 *                   host plugin (e.g. VST, AU, DSSI, LV2) which
81                 *                   don't allow to change the MIDI port or even
82                 *                   device
83                 */
84                void SetMidiInputDevice(MidiInputDevice *pDevice) throw (Exception);
85    
86                /**
87                 * Connect this sampler channel to a MIDI input port.
88                 *
89                 * @param MidiPort - MIDI port to connect to
90                 * @throws Exception in case the MIDI port is tried to be changed
91                 *                   while the sampler channel is being used by a
92                 *                   host plugin (e.g. VST, AU, DSSI, LV2) which
93                 *                   don't allow to change the MIDI port
94                 */
95                void SetMidiInputPort(int MidiPort) throw (Exception);
96    
97                /**
98                 * Define on which MIDI channel(s) this sampler channel should
99                 * listen to. By default, that is after creation of a new
100                 * sampler channel, the sampler channel will listen to all MIDI
101                 * channels.
102                 *
103                 * @param MidiChannel - MIDI channel to listen
104                 */
105                void SetMidiInputChannel(midi_chan_t MidiChannel);
106    
107                /**
108                 * Connect this sampler channel to a MIDI input triplet.
109                 *
110                 * @param pDevice - MIDI input device to connect to
111                 * @param iMidiPort - MIDI port to connect to
112               * @param MidiChannel - optional: MIDI channel on which the               * @param MidiChannel - optional: MIDI channel on which the
113               *                      sampler channel should listen to               *                      sampler channel should listen to
114               *                      (default: listen on all MIDI channels)               *                      (default: listen on all MIDI channels)
115                 * @throws Exception in case the MIDI port is tried to be changed
116                 *                   while the sampler channel is being used by a
117                 *                   host plugin (e.g. VST, AU, DSSI, LV2) which
118                 *                   don't allow to change the MIDI port
119               */               */
120              void SetMidiInputDevice(midi_input_type_t MidiType, MidiInputDevice::midi_chan_t MidiChannel = MidiInputDevice::midi_chan_all);              void SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all) throw (Exception);
121    
122              /**              /**
123               * Returns the engine that was deployed on this sampler channel.               * Returns the EngineChannel object that was deployed on this
124                 * sampler channel appropriate to the given sampler engine type.
125               *               *
126               * @returns  pointer to engine or NULL if no engine deployed               * @returns  pointer to engine or NULL if no engine deployed
127               */               */
128              Engine* GetEngine();              EngineChannel* GetEngineChannel();
129    
130              /**              /**
131               * Returns the MIDI input device to which this sampler channel               * Returns the MIDI input channel to which this sampler
132               * is currently connected to.               * channel is currently connected to.
133               *               *
134               * @returns  pointer to MIDI input device or NULL if not               * @returns  The MIDI input channel on which the sampler
135               *           connected               *           channel is listening to.
136               */               */
137              MidiInputDevice* GetMidiInputDevice();              midi_chan_t GetMidiInputChannel();
138    
139                /**
140                 * Returns the MIDI input port number to which this sampler
141                 * channel is currently connected to.
142                 *
143                 * @returns  MIDI input port number or -1 if not connected
144                 */
145                int GetMidiInputPort();
146    
147              /**              /**
148               * Returns the audio output device to which this sampler channel               * Returns the audio output device to which this sampler channel
# Line 133  namespace LinuxSampler { Line 154  namespace LinuxSampler {
154              AudioOutputDevice* GetAudioOutputDevice();              AudioOutputDevice* GetAudioOutputDevice();
155    
156              /**              /**
157                 * Returns the MIDI input device to which this sampler channel
158                 * is currently connected to.
159                 *
160                 * @returns  pointer to MIDI input device or NULL if not
161                 *           connected
162                 */
163                MidiInputDevice* GetMidiInputDevice();
164    
165                /**
166               * Returns the index number of this sampler channel within the               * Returns the index number of this sampler channel within the
167               * Sampler instance.               * Sampler instance.
168               */               */
169              uint Index();              uint Index();
170    
171                /** Returns the sampler to which this channel belongs */
172                Sampler* GetSampler();
173    
174                ///////////////////////////////////////////////////////////////
175                // Event Listener methods
176    
177                /**
178                 * Registers the specified listener to be notified
179                 * when the engine type of this sampler channel is changed.
180                 */
181                void AddEngineChangeListener(EngineChangeListener* l);
182    
183                /**
184                 * Removes the specified listener.
185                 */
186                void RemoveEngineChangeListener(EngineChangeListener* l);
187    
188                /**
189                 * Removes the specified listener.
190                 */
191                void RemoveAllEngineChangeListeners();
192    
193                /**
194                 * Notifies listeners that the engine type of this sampler
195                 * channel is going to be changed soon.
196                 */
197                void fireEngineToBeChanged();
198    
199                /**
200                 * Notifies listeners that the engine
201                 * type of this sampler channel is changed.
202                 */
203                void fireEngineChanged();
204    
205    
206          protected:          protected:
207              SamplerChannel(Sampler* pS);              SamplerChannel(Sampler* pS);
208             ~SamplerChannel();              virtual ~SamplerChannel();
209    
210                /** Getting MIDI input device port given its index number. */
211                MidiInputPort* __GetMidiInputDevicePort(int iMidiPort);
212    
213              Sampler*           pSampler;              Sampler*           pSampler;
214              Engine*            pEngine;              EngineChannel*     pEngineChannel;
             MidiInputDevice*   pMidiInputDevice;  
215              AudioOutputDevice* pAudioOutputDevice;              AudioOutputDevice* pAudioOutputDevice;
216                MidiInputDevice*   pMidiInputDevice;
217              int                iIndex;              int                iIndex;
218    
219              friend class Sampler;              friend class Sampler;
220            private:
221                int                iMidiPort;   ///< Don't access directly, read GetMidiInputPort() instead !
222                midi_chan_t        midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead !
223                ListenerList<EngineChangeListener*> llEngineChangeListeners;
224      };      };
225    
226      /** LinuxSampler main class      /** @brief LinuxSampler main class
227       *       *
228       * This is the toplevel class for a LinuxSampler instance.       * This is the toplevel class for a LinuxSampler instance.
229       *       *
# Line 159  namespace LinuxSampler { Line 231  namespace LinuxSampler {
231       * sampler channel can individually be deployed with it's own sampler       * sampler channel can individually be deployed with it's own sampler
232       * engine, connected to an arbitrary MIDI input device and connected to       * engine, connected to an arbitrary MIDI input device and connected to
233       * an arbitrary audio output device. Here an example setup:       * an arbitrary audio output device. Here an example setup:
234         * @code
235         * S.Channel    MIDI in    S.Engine         Audio out
236         * -------------------------------------------------------------------
237         *   0          Alsa   ->  gig::Engine  ->  Jack
238         *   1          VSTi   ->  Akai::Engine ->  VSTi
239         *   2          Jack   ->  DLS::Engine  ->  Jack
240         *   3          Jack   ->  SF::Engine   ->  Alsa
241       *       *
242       *  S.Channel.      MIDI in         S.Engine                Audio out       * ... (and so on) ...
243       *  -------------------------------------------------------------------       * @endcode
      *  0               Alsa    ->      gig::Engine     ->      Jack  
      *  1               VSTi    ->      Akai::Engine    ->      VSTi  
      *  2               Jack    ->      DLS::Engine     ->      Jack  
      *  3               Jack    ->      SF::Engine      ->      Alsa  
      *  
      *  ... (and so on) ...  
244       *       *
245       * Note that not all audio and MIDI backends and sampler engines listed       * Note that not all audio and MIDI backends and sampler engines listed
246       * in the example above are already implemented!       * in the example above might already been implemented!
247       *       *
248       * 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
249       * several, different audio output and MIDI input systems       * several, different audio output and MIDI input systems
250       * simultaniously at the same time. Here the example setup shown in the       * simultaniously at the same time. Here the example setup shown in the
251       * ascpect of MIDI input and audio output devices / drivers:       * aspect of MIDI input and audio output devices / drivers:
252       *       * @code
253       *                            ######################### #########################       *                      ######################### #########################
254       *                            # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #       *                      # AudioOutputDeviceJack # # AudioOutputDeviceVSTi #
255       *                            ######################### #########################       *                      ######################### #########################
256       *                                          ^   ^           ^       *                                        ^   ^           ^
257       *    /------------>|Sampler Channel 0|-----/   |           |       *  /------------>|Sampler Channel 0|-----/   |           |
258       *    |  /--------->|Sampler Channel 1|---------------------/       *  |  /--------->|Sampler Channel 1|---------------------/
259       *    |  |    /---->|Sampler Channel 2|---------/       *  |  |  /------>|Sampler Channel 2|---------/
260       *    |  |    |  /->|Sampler Channel 3|------------>#########################       *  |  |  |  /--->|Sampler Channel 3|------------>#########################
261       *    |  |    |  |  ... (and so on) ...             # AudioOutputDeviceAlsa #       *  |  |  |  |    ... (and so on) ...             # AudioOutputDeviceAlsa #
262       *    |  |    |  |                                  #########################       *  |  |  |  |                                    #########################
263       *    |  |    |  \----------------------------------------------------\       *  |  |  |  \-----------------------------------------------------\
264       *    |  |    \-------------------------------------------\           |       *  |  |  \--------------------------------------------\           |
265       *    |  \--------------------\                           |           |       *  |  \--------------------\                          |           |
266       *    |                       |                           |           |       *  |                       |                          |           |
267       *  ####################### ####################### #######################       * ####################### ####################### #######################
268       *  # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #       * # MidiInputDeviceAlsa # # MidiInputDeviceVSTi # # MidiInputDeviceJack #
269       *  ####################### ####################### #######################       * ####################### ####################### #######################
270         * @endcode
271       *       *
272       * 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
273       * driver / audio output driver) can be connected multiple times to       * driver / audio output driver) can be connected multiple times to
274       * different sampler channels.       * different sampler channels.
275         *
276         * It's even possible to create multiple instances of the same driver, for
277         * example multiple instances of the Alsa output driver to use multiple
278         * sound cards at the same time, or multiple instances of the JACK audio
279         * output driver to leverage SMP systems or boxes with several hard discs.
280       */       */
281      class Sampler {      class Sampler {
282          public:          public:
# Line 209  namespace LinuxSampler { Line 288  namespace LinuxSampler {
288              /**              /**
289               * Destructor.               * Destructor.
290               */               */
291             ~Sampler();              virtual ~Sampler();
292    
293              /**              /**
294               * Returns the number of sampler channels currently allocated.               * Returns the number of sampler channels currently allocated.
# Line 217  namespace LinuxSampler { Line 296  namespace LinuxSampler {
296              uint SamplerChannels();              uint SamplerChannels();
297    
298              /**              /**
299               * Create and add a new sampler channel to this Sampler instance.               * Create and add a new sampler channel to this Sampler
300                 * instance. For race condition reasons the new channel will use
301                 * an index past the last already existing sampler channel
302                 * index (in case the index limit was not reached yet, otherwise
303                 * a free index starting from 0 is searched).
304               *               *
305               * @returns  pointer to new sampler channel               * @returns  pointer to new sampler channel
306               */               */
# Line 232  namespace LinuxSampler { Line 315  namespace LinuxSampler {
315              SamplerChannel* GetSamplerChannel(uint uiSamplerChannel);              SamplerChannel* GetSamplerChannel(uint uiSamplerChannel);
316    
317              /**              /**
318                 * Returns all created sampler channels.
319                 */
320                std::map<uint, SamplerChannel*> GetSamplerChannels();
321    
322                /**
323               * Destroy and remove the given sampler channel from this               * Destroy and remove the given sampler channel from this
324               * Sampler instance.               * Sampler instance.
325               *               *
# Line 249  namespace LinuxSampler { Line 337  namespace LinuxSampler {
337              void RemoveSamplerChannel(uint uiSamplerChannel);              void RemoveSamplerChannel(uint uiSamplerChannel);
338    
339              /**              /**
340               * Create an audio output device of the given type.               * Destroy and remove all sampler channels from this
341                 * Sampler instance.
342                 */
343                void RemoveAllSamplerChannels();
344    
345                /**
346                 * Returns the names of all available audio output drivers.
347                 */
348                std::vector<String> AvailableAudioOutputDrivers();
349    
350                /**
351                 * Returns the names of all available MIDI input drivers.
352                 */
353                std::vector<String> AvailableMidiInputDrivers();
354    
355                /**
356                 * Returns the names of all available sampler engine types.
357                 * @see SamplerChannel::SetEngineType()
358                 */
359                std::vector<String> AvailableEngineTypes();
360    
361                /**
362                 * Create an audio output device.
363               *               *
364               * @param AudioType - desired audio output system to use               * @param AudioDriver - name of the audio driver
365                 * @param Parameters - eventually needed driver parameters to
366                 *                     create the device
367               * @returns  pointer to created audio output device               * @returns  pointer to created audio output device
368                 * @throws Exception  if device could not be created
369                 */
370                AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception);
371    
372                /**
373                 * Create a midi input device.
374                 *
375                 * @param MidiDriver - name of the midi driver
376                 * @param Parameters - eventually needed driver parameters to
377                 *                     create the device
378                 * @returns  pointer to created midi input device
379                 * @throws Exception  if device could not be created
380                 */
381                MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);
382    
383                /**
384                 * Returns the number of all created audio output devices.
385                 */
386                uint AudioOutputDevices();
387    
388                /**
389                 * Returns the number of all created MIDI input devices.
390                 */
391                uint MidiInputDevices();
392    
393                /**
394                 * Returns all created audio output devices.
395                 */
396                std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();
397    
398                /**
399                 * Returns all created MIDI input devices.
400               */               */
401              AudioOutputDevice* CreateAudioOutputDevice(audio_output_type_t AudioType);              std::map<uint, MidiInputDevice*> GetMidiInputDevices();
402    
403              /**              /**
404               * Returns the audio output device of the given type.               * Destroy the given audio output device and takes care if there
405                 * are still sampler engines connected to this device, etc.
406               *               *
407               * @param AudioType - desired audio output system to use               * @throws Exception  if sampler channels are still
408               * @returns  pointer to audio output device or NULL if device of               *                    connected to the device
              *           desired type is not yet created  
409               */               */
410              AudioOutputDevice* GetAudioOutputDevice(audio_output_type_t AudioType);              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);
411    
412              /**              /**
413               * Create a MIDI input device of the given type.               * Destroy all audio output devices and takes care if there
414                 * are still sampler engines connected to devices, etc.
415               *               *
416               * @param MidiType - desired MIDI input system to use               * Note: non-autonomous devices, that is devices associated with
417               * @returns  pointer to created MIDI input device               * host plugin instances like VST, AU, DSSI, LV2 are not
418                 * destroyed by this method.
419                 *
420                 * @throws Exception  if sampler channels are still
421                 *                    connected to device
422               */               */
423              MidiInputDevice* CreateMidiInputDevice(midi_input_type_t MidiType);              void DestroyAllAudioOutputDevices() throw (Exception);
424    
425              /**              /**
426               * Returns the MIDI input device of the given type.               * Destroy the given MIDI input device and takes care if there
427                 * are still sampler engines connected to this device, etc.
428               *               *
429               * @param MidiType - desired MIDI input system to use               * @throws Exception  if sampler channels are still
430               * @returns  pointer to MIDI input device or NULL if device of               *                    connected to the device
              *           desired type is not yet created  
431               */               */
432              MidiInputDevice* GetMidiInputDevice(midi_input_type_t MidiType);              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);
433    
434                /**
435                 * Destroy all MIDI input devices and take care if there
436                 * are still sampler engines connected to device, etc.
437                 *
438                 * Note: non-autonomous devices, that is devices associated with
439                 * host plugin instances like VST, AU, DSSI, LV2 are not
440                 * destroyed by this method.
441                 *
442                 * @throws Exception  if sampler channels are still
443                 *                    connected to device
444                 */
445                void DestroyAllMidiInputDevices() throw (Exception);
446    
447                 /**
448                 * Gets the current number of all active streams.
449                 * @returns The current number of all active streams.
450                 */
451                int GetDiskStreamCount();
452    
453                /**
454                 * Gets the current number of all active voices.
455                 * @returns The current number of all active voices.
456                 */
457                int GetVoiceCount();
458    
459                /**
460                 * Reset the whole sampler. Destroy all engines, sampler
461                 * channels, MIDI input devices and audio output devices.
462                 */
463                void Reset();
464    
465                ///////////////////////////////////////////////////////////////
466                // Event Listener methods
467    
468                /**
469                 * Registers the specified listener to be notified
470                 * when the number of sampler chanels is changed.
471                 */
472                void AddChannelCountListener(ChannelCountListener* l);
473    
474                /**
475                 * Removes the specified listener.
476                 */
477                void RemoveChannelCountListener(ChannelCountListener* l);
478    
479                /**
480                 * Registers the specified listener to be notified
481                 * when the number of audio output devices is changed.
482                 */
483                void AddAudioDeviceCountListener(AudioDeviceCountListener* l);
484    
485                /**
486                 * Removes the specified listener.
487                 */
488                void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);
489    
490                /**
491                 * Registers the specified listener to be notified
492                 * when the number of MIDI input devices is changed.
493                 */
494                void AddMidiDeviceCountListener(MidiDeviceCountListener* l);
495    
496                /**
497                 * Removes the specified listener.
498                 */
499                void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l);
500    
501                /**
502                 * Registers the specified listener to be notified when the number
503                 * of active voices in a particular sampler channel is changed.
504                 */
505                void AddVoiceCountListener(VoiceCountListener* l);
506    
507                /**
508                 * Removes the specified listener.
509                 */
510                void RemoveVoiceCountListener(VoiceCountListener* l);
511    
512                /**
513                 * Notifies listeners that the number of active voices
514                 * on the specified sampler channel is changed.
515                 * @param ChannelId The numerical ID of the sampler channel.
516                 * @param NewCount The new number of active voices.
517                 */
518                void fireVoiceCountChanged(int ChannelId, int NewCount);
519    
520                /**
521                 * Registers the specified listener to be notified when the number
522                 * of active disk streams in a particular sampler channel is changed.
523                 */
524                void AddStreamCountListener(StreamCountListener* l);
525    
526                /**
527                 * Removes the specified listener.
528                 */
529                void RemoveStreamCountListener(StreamCountListener* l);
530    
531                /**
532                 * Notifies listeners that the number of active disk streams
533                 * on the specified sampler channel is changed.
534                 * @param ChannelId The numerical ID of the sampler channel.
535                 * @param NewCount The new number of active disk streams.
536                 */
537                void fireStreamCountChanged(int ChannelId, int NewCount);
538    
539                /**
540                 * Registers the specified listener to be
541                 * notified when the fill state of the disk stream
542                 * buffers on a specific sampler channel is changed.
543                 */
544                void AddBufferFillListener(BufferFillListener* l);
545    
546                /**
547                 * Removes the specified listener.
548                 */
549                void RemoveBufferFillListener(BufferFillListener* l);
550    
551                /**
552                 * Notifies listeners that the fill state of the disk stream
553                 * buffers on the specified sampler channel is changed.
554                 * @param ChannelId The numerical ID of the sampler channel.
555                 * @param FillData The buffer fill data for the specified sampler channel.
556                 */
557                void fireBufferFillChanged(int ChannelId, String FillData);
558    
559                /**
560                 * Registers the specified listener to be notified
561                 * when total number of active voices is changed.
562                 */
563                void AddTotalVoiceCountListener(TotalVoiceCountListener* l);
564    
565                /**
566                 * Removes the specified listener.
567                 */
568                void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l);
569    
570                /**
571                 * Notifies listeners that the total number of active voices is changed.
572                 * @param NewCount The new number of active voices.
573                 */
574                void fireTotalVoiceCountChanged(int NewCount);
575    
576                /**
577                 * Registers the specified listener to be notified when the number
578                 * of total streams is changed.
579                 */
580                void AddTotalStreamCountListener(TotalStreamCountListener* l);
581    
582                /**
583                 * Removes the specified listener.
584                 */
585                void RemoveTotalStreamCountListener(TotalStreamCountListener* l);
586    
587                /**
588                 * Notifies listeners that the total number of total streams changed.
589                 * @param NewCount The new number of total streams.
590                 */
591                void fireTotalStreamCountChanged(int NewCount);
592    
593                /**
594                 * Registers the specified listener to be notified when the number
595                 * of effect sends on a particular sampler channel is changed.
596                 */
597                void AddFxSendCountListener(FxSendCountListener* l);
598    
599                /**
600                 * Removes the specified listener.
601                 */
602                void RemoveFxSendCountListener(FxSendCountListener* l);
603    
604                /**
605                 * Notifies listeners about the current number of voices,
606                 * streams and total voices, and the current fill state of
607                 * the disk stream buffers.
608                 */
609                void fireStatistics();
610    
611                ///////////////////////////////////////////////////////////////
612                // system specific methods
613    
614                /**
615                 * Advise the FPU to treat denormal floating point numbers as
616                 * zero, to avoid severe performance penalty when dealing with
617                 * such extreme floating point values.
618                 *
619                 * @returns @c true if FPU supports it, @c false otherwise
620                 */
621                static bool EnableDenormalsAreZeroMode();
622    
623    #if defined(WIN32)
624                /**
625                 * Gets the directory where the liblinuxsampler dll is located.
626                 * Note: this method is currently only available for Windows.
627                 * @returns installation directory
628                 */
629                static String GetInstallDir();
630    #endif
631          protected:          protected:
632              typedef std::map<audio_output_type_t, AudioOutputDevice*> AudioOutputDeviceMap;              /**
633              typedef std::map<midi_input_type_t, MidiInputDevice*> MidiInputDeviceMap;               * Notifies listeners that the number of sampler channels has been changed.
634                 * @param NewCount The new number of sampler channels.
635                 */
636                void fireChannelCountChanged(int NewCount);
637    
638                /**
639                 * Notifies listeners that the specified sampler channel has just
640                 * been added.
641                 * @param pChannel The new sampler channel.
642                 */
643                void fireChannelAdded(SamplerChannel* pChannel);
644    
645                /**
646                 * Notifies listeners that the specified sampler channel is
647                 * going to be removed soon.
648                 * @param pChannel sampler channel to be removed.
649                 */
650                void fireChannelToBeRemoved(SamplerChannel* pChannel);
651    
652                /**
653                 * Notifies listeners that the number of audio output devices has been changed.
654                 * @param NewCount The new number of audio output devices.
655                 */
656                void fireAudioDeviceCountChanged(int NewCount);
657    
658                /**
659                 * Notifies listeners that the number of MIDI input devices has been changed.
660                 * @param NewCount The new number of MIDI input devices.
661                 */
662                void fireMidiDeviceCountChanged(int NewCount);
663    
664              std::vector<SamplerChannel*> vSamplerChannels;   ///< contains all created sampler channels              /**
665              AudioOutputDeviceMap         AudioOutputDevices; ///< contains all created audio output devices               * Notifies listeners that the supplied MIDI input device is
666              MidiInputDeviceMap           MidiInputDevices;               * going to be destroyed soon.
667                 * @param pDevice MIDI input device to be destroyed
668                 */
669                void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice);
670    
671                /**
672                 * Notifies listeners that the supplied MIDI input device was
673                 * just created.
674                 * @param pDevice new MIDI input device
675                 */
676                void fireMidiDeviceCreated(MidiInputDevice* pDevice);
677    
678                /**
679                 * Notifies listeners that the number of effect sends
680                 * on a particular sampler channel is changed.
681                 * @param ChannelId The numerical ID of the sampler channel.
682                 * @param NewCount The new number of sampler channels.
683                 */
684                void fireFxSendCountChanged(int ChannelId, int NewCount);
685    
686                typedef std::map<uint, SamplerChannel*> SamplerChannelMap;
687    
688                SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels
689    
690                // statistics cache
691                uint uiOldTotalVoiceCount;
692                uint uiOldTotalStreamCount;
693                std::map<uint, uint> mOldVoiceCounts;
694                std::map<uint, uint> mOldStreamCounts;
695    
696              friend class SamplerChannel;              friend class SamplerChannel;
697    
698            private:
699                ListenerList<ChannelCountListener*> llChannelCountListeners;
700                ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners;
701                ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners;
702                ListenerList<VoiceCountListener*> llVoiceCountListeners;
703                ListenerList<StreamCountListener*> llStreamCountListeners;
704                ListenerList<BufferFillListener*> llBufferFillListeners;
705                ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners;
706                ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;
707                ListenerList<FxSendCountListener*> llFxSendCountListeners;
708    
709                class EventHandler : public EngineChangeListener, public FxSendCountListener {
710                    public:
711                        void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }
712    
713                        /**
714                         * Invoked when the engine type of the specified sampler
715                         * channel is going to be changed soon.
716                         * @param ChannelId The numerical ID of the sampler channel
717                         */
718                        virtual void EngineToBeChanged(int ChannelId);
719    
720                        /**
721                         * Invoked when the engine type of the
722                         * specified sampler channel is changed.
723                         * @param ChannelId The numerical ID of the sampler
724                         * channel, which engine type has been changed.
725                         */
726                        virtual void EngineChanged(int ChannelId);
727    
728                        /**
729                         * Invoked when the number of effect sends
730                         * on the specified sampler channel has changed.
731                         * @param ChannelId The numerical ID of the sampler channel.
732                         * @param NewCount The new number of effect sends.
733                         */
734                        virtual void FxSendCountChanged(int ChannelId, int NewCount);
735    
736                    private:
737                        Sampler* pSampler;
738                } eventHandler;
739      };      };
740  }  }
741    

Legend:
Removed from v.57  
changed lines
  Added in v.1937

  ViewVC Help
Powered by ViewVC