/[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 1130 by iliev, Sun Mar 25 18:59:14 2007 UTC revision 2375 by schoenebeck, Thu Oct 4 17:45:22 2012 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, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2012 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 64  namespace LinuxSampler { Line 64  namespace LinuxSampler {
64               * the old connection will automatically be removed before.               * the old connection will automatically be removed before.
65               *               *
66               * @param pDevice - audio output device 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(AudioOutputDevice* pDevice);              void SetAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);
73    
74              /**              /**
75               * Connect this sampler channel to a MIDI input device.               * Connect this sampler channel to a MIDI input device.
76               *               *
77               * @param pDevice - MIDI input device 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);              void SetMidiInputDevice(MidiInputDevice *pDevice) throw (Exception);
85    
86              /**              /**
87               * Connect this sampler channel to a MIDI input port.               * Connect this sampler channel to a MIDI input port.
88               *               *
89               * @param MidiPort - MIDI port to connect to               * @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);              void SetMidiInputPort(int MidiPort) throw (Exception);
96    
97              /**              /**
98               * Define on which MIDI channel(s) this sampler channel should               * Define on which MIDI channel(s) this sampler channel should
# Line 99  namespace LinuxSampler { Line 112  namespace LinuxSampler {
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 SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all);              void SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel = midi_chan_all) throw (Exception);
121    
122              /**              /**
123               * Returns the EngineChannel object that was deployed on this               * Returns the EngineChannel object that was deployed on this
# Line 150  namespace LinuxSampler { Line 167  namespace LinuxSampler {
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               * Registers the specified listener to be notified
179               * when the engine type of this sampler channel is changed.               * when the engine type of this sampler channel is changed.
# Line 168  namespace LinuxSampler { Line 191  namespace LinuxSampler {
191              void RemoveAllEngineChangeListeners();              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               * Notifies listeners that the engine
201               * type of this sampler channel is changed.               * type of this sampler channel is changed.
202               */               */
# Line 308  namespace LinuxSampler { Line 337  namespace LinuxSampler {
337              void RemoveSamplerChannel(uint uiSamplerChannel);              void RemoveSamplerChannel(uint uiSamplerChannel);
338    
339              /**              /**
340                 * 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 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
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                std::map<uint, MidiInputDevice*> GetMidiInputDevices();
402    
403                /**
404                 * Destroy the given audio output device and takes care if there
405                 * are still sampler engines connected to this device, etc.
406                 *
407                 * @throws Exception  if sampler channels are still
408                 *                    connected to the device
409                 */
410                void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);
411    
412                /**
413                 * Destroy all audio output devices and takes care if there
414                 * are still sampler engines connected to devices, etc.
415                 *
416                 * Note: non-autonomous devices, that is devices associated with
417                 * 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                void DestroyAllAudioOutputDevices() throw (Exception);
424    
425                /**
426                 * Destroy the given MIDI input device and takes care if there
427                 * are still sampler engines connected to this device, etc.
428                 *
429                 * @throws Exception  if sampler channels are still
430                 *                    connected to the device
431                 */
432                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                 * @see SetGlobalMaxVoices()
461                 */
462                int GetGlobalMaxVoices();
463    
464                /**
465                 * @see SetGlobalMaxStreams()
466                 */
467                int GetGlobalMaxStreams();
468    
469                /**
470                 * Sets the global maximum amount limit of voices.
471                 *
472                 * Note that this voice limit can also be altered for
473                 * each sampler engine instance individually instead.
474                 *
475                 * @throws Exception  if \a n is invalid
476                 */
477                void SetGlobalMaxVoices(int n) throw (Exception);
478    
479                /**
480                 * Sets the global maximum amount limit of disk streams.
481                 *
482                 * Note that this stream limit can also be altered for
483                 * each sampler engine instance individually instead.
484                             *
485                 * @throws Exception  if \a n is invalid
486                 */
487                void SetGlobalMaxStreams(int n) throw (Exception);
488    
489                /**
490                 * Reset the whole sampler. Destroy all engines, sampler
491                 * channels, MIDI input devices and audio output devices.
492                 */
493                void Reset();
494    
495                ///////////////////////////////////////////////////////////////
496                // Event Listener methods
497    
498                /**
499               * Registers the specified listener to be notified               * Registers the specified listener to be notified
500               * when the number of sampler chanels is changed.               * when the number of sampler chanels is changed.
501               */               */
# Line 329  namespace LinuxSampler { Line 517  namespace LinuxSampler {
517               */               */
518              void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);              void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);
519    
               
520              /**              /**
521               * Registers the specified listener to be notified               * Registers the specified listener to be notified
522               * when the number of MIDI input devices is changed.               * when the number of MIDI input devices is changed.
# Line 418  namespace LinuxSampler { Line 605  namespace LinuxSampler {
605    
606              /**              /**
607               * Registers the specified listener to be notified when the number               * Registers the specified listener to be notified when the number
608               * of effect sends on a particular sampler channel is changed.               * of total streams is changed.
609               */               */
610              void AddFxSendCountListener(FxSendCountListener* l);              void AddTotalStreamCountListener(TotalStreamCountListener* l);
611    
612              /**              /**
613               * Removes the specified listener.               * Removes the specified listener.
614               */               */
615              void RemoveFxSendCountListener(FxSendCountListener* l);              void RemoveTotalStreamCountListener(TotalStreamCountListener* l);
616    
617              /**              /**
618               * Returns the names of all available audio output drivers.               * Notifies listeners that the total number of total streams changed.
619               */               * @param NewCount The new number of total streams.
             std::vector<String> AvailableAudioOutputDrivers();  
   
             /**  
              * Returns the names of all available MIDI input drivers.  
              */  
             std::vector<String> AvailableMidiInputDrivers();  
   
             /**  
              * Returns the names of all available sampler engine types.  
              * @see SamplerChannel::SetEngineType()  
              */  
             std::vector<String> AvailableEngineTypes();  
   
             /**  
              * Create an audio output device.  
              *  
              * @param AudioDriver - name of the audio driver  
              * @param Parameters - eventually needed driver parameters to  
              *                     create the device  
              * @returns  pointer to created audio output device  
              * @throws Exception  if device could not be created  
              */  
             AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception);  
   
             /**  
              * Create a midi input device.  
              *  
              * @param MidiDriver - name of the midi driver  
              * @param Parameters - eventually needed driver parameters to  
              *                     create the device  
              * @returns  pointer to created midi input device  
              * @throws Exception  if device could not be created  
620               */               */
621              MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);              void fireTotalStreamCountChanged(int NewCount);
622    
623              /**              /**
624               * Returns the number of all created audio output devices.               * Registers the specified listener to be notified when the number
625                 * of effect sends on a particular sampler channel is changed.
626               */               */
627              uint AudioOutputDevices();              void AddFxSendCountListener(FxSendCountListener* l);
628    
629              /**              /**
630               * Returns the number of all created MIDI input devices.               * Removes the specified listener.
631               */               */
632              uint MidiInputDevices();              void RemoveFxSendCountListener(FxSendCountListener* l);
633    
634              /**              /**
635               * Returns all created audio output devices.               * Notifies listeners about the current number of voices,
636                 * streams and total voices, and the current fill state of
637                 * the disk stream buffers.
638               */               */
639              std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();              void fireStatistics();
640    
641              /**              ///////////////////////////////////////////////////////////////
642               * Returns all created MIDI input devices.              // system specific methods
              */  
             std::map<uint, MidiInputDevice*> GetMidiInputDevices();  
643    
644              /**              /**
645               * Destroy the given audio output device and takes care if there               * Advise the FPU to treat denormal floating point numbers as
646               * are still sampler angines connected to this device, etc.               * zero, to avoid severe performance penalty when dealing with
647                 * such extreme floating point values.
648               *               *
649               * @throws Exception  if sampler channels are still               * @returns @c true if FPU supports it, @c false otherwise
              *                    connected to the device  
650               */               */
651              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);              static bool EnableDenormalsAreZeroMode();
652    
653    #if defined(WIN32)
654              /**              /**
655               * Destroy the given MIDI input device and takes care if there               * Gets the directory where the liblinuxsampler dll is located.
656               * are still sampler angines connected to this device, etc.               * Note: this method is currently only available for Windows.
657               *               * @returns installation directory
              * @throws Exception  if sampler channels are still  
              *                    connected to the device  
658               */               */
659              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);              static String GetInstallDir();
660    #endif
661            protected:
662              /**              /**
663               * Gets the current number of all active voices.               * Notifies listeners that the number of sampler channels has been changed.
664               * @returns The current number of all active voices.               * @param NewCount The new number of sampler channels.
665               */               */
666              int GetVoiceCount();              void fireChannelCountChanged(int NewCount);
667    
668              /**              /**
669               * Reset the whole sampler. Destroy all engines, sampler               * Notifies listeners that the specified sampler channel has just
670               * channels, MIDI input devices and audio output devices.               * been added.
671                 * @param pChannel The new sampler channel.
672               */               */
673              void Reset();              void fireChannelAdded(SamplerChannel* pChannel);
674    
         protected:  
675              /**              /**
676               * Notifies listeners that the number of sampler channels has been changed.               * Notifies listeners that the specified sampler channel is
677               * @param NewCount The new number of sampler channels.               * going to be removed soon.
678                 * @param pChannel sampler channel to be removed.
679               */               */
680              void fireChannelCountChanged(int NewCount);              void fireChannelToBeRemoved(SamplerChannel* pChannel);
681    
682              /**              /**
683               * Notifies listeners that the number of audio output devices has been changed.               * Notifies listeners that the number of audio output devices has been changed.
# Line 535  namespace LinuxSampler { Line 692  namespace LinuxSampler {
692              void fireMidiDeviceCountChanged(int NewCount);              void fireMidiDeviceCountChanged(int NewCount);
693    
694              /**              /**
695                 * Notifies listeners that the supplied MIDI input device is
696                 * going to be destroyed soon.
697                 * @param pDevice MIDI input device to be destroyed
698                 */
699                void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice);
700    
701                /**
702                 * Notifies listeners that the supplied MIDI input device was
703                 * just created.
704                 * @param pDevice new MIDI input device
705                 */
706                void fireMidiDeviceCreated(MidiInputDevice* pDevice);
707    
708                /**
709               * Notifies listeners that the number of effect sends               * Notifies listeners that the number of effect sends
710               * on a particular sampler channel is changed.               * on a particular sampler channel is changed.
711               * @param ChannelId The numerical ID of the sampler channel.               * @param ChannelId The numerical ID of the sampler channel.
# Line 542  namespace LinuxSampler { Line 713  namespace LinuxSampler {
713               */               */
714              void fireFxSendCountChanged(int ChannelId, int NewCount);              void fireFxSendCountChanged(int ChannelId, int NewCount);
715    
             typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;  
             typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;  
716              typedef std::map<uint, SamplerChannel*> SamplerChannelMap;              typedef std::map<uint, SamplerChannel*> SamplerChannelMap;
717    
718              SamplerChannelMap     mSamplerChannels;    ///< contains all created sampler channels              SamplerChannelMap mSamplerChannels; ///< contains all created sampler channels
719              AudioOutputDeviceMap  mAudioOutputDevices; ///< contains all created audio output devices  
720              MidiInputDeviceMap    mMidiInputDevices;   ///< contains all created MIDI input devices              // statistics cache
721                uint uiOldTotalVoiceCount;
722                uint uiOldTotalStreamCount;
723                std::map<uint, uint> mOldVoiceCounts;
724                std::map<uint, uint> mOldStreamCounts;
725    
726              friend class SamplerChannel;              friend class SamplerChannel;
727    
# Line 559  namespace LinuxSampler { Line 732  namespace LinuxSampler {
732              ListenerList<VoiceCountListener*> llVoiceCountListeners;              ListenerList<VoiceCountListener*> llVoiceCountListeners;
733              ListenerList<StreamCountListener*> llStreamCountListeners;              ListenerList<StreamCountListener*> llStreamCountListeners;
734              ListenerList<BufferFillListener*> llBufferFillListeners;              ListenerList<BufferFillListener*> llBufferFillListeners;
735                ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners;
736              ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;              ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;
737              ListenerList<FxSendCountListener*> llFxSendCountListeners;              ListenerList<FxSendCountListener*> llFxSendCountListeners;
738    
# Line 567  namespace LinuxSampler { Line 741  namespace LinuxSampler {
741                      void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }                      void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }
742    
743                      /**                      /**
744                         * Invoked when the engine type of the specified sampler
745                         * channel is going to be changed soon.
746                         * @param ChannelId The numerical ID of the sampler channel
747                         */
748                        virtual void EngineToBeChanged(int ChannelId);
749    
750                        /**
751                       * Invoked when the engine type of the                       * Invoked when the engine type of the
752                       * specified sampler channel is changed.                       * specified sampler channel is changed.
753                       * @param ChannelId The numerical ID of the sampler                       * @param ChannelId The numerical ID of the sampler

Legend:
Removed from v.1130  
changed lines
  Added in v.2375

  ViewVC Help
Powered by ViewVC