/[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 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, 2006 Christian Schoenebeck                        *   *   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 150  namespace LinuxSampler { Line 150  namespace LinuxSampler {
150               * Sampler instance.               * Sampler instance.
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               * Registers the specified listener to be notified
162               * 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 174  namespace LinuxSampler {
174              void RemoveAllEngineChangeListeners();              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               * Notifies listeners that the engine
184               * type of this sampler channel is changed.               * type of this sampler channel is changed.
185               */               */
# Line 308  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.
330                 */
331                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.
346                 *
347                 * @param AudioDriver - name of the audio driver
348                 * @param Parameters - eventually needed driver parameters to
349                 *                     create the device
350                 * @returns  pointer to created audio output device
351                 * @throws Exception  if device could not be created
352                 */
353                AudioOutputDevice* CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (Exception);
354    
355                /**
356                 * Create a midi input device.
357                 *
358                 * @param MidiDriver - name of the midi driver
359                 * @param Parameters - eventually needed driver parameters to
360                 *                     create the device
361                 * @returns  pointer to created midi input device
362                 * @throws Exception  if device could not be created
363                 */
364                MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);
365    
366                /**
367                 * Returns the number of all created audio output devices.
368                 */
369                uint AudioOutputDevices();
370    
371                /**
372                 * Returns the number of all created MIDI input devices.
373                 */
374                uint MidiInputDevices();
375    
376                /**
377                 * Returns all created audio output devices.
378                 */
379                std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();
380    
381                /**
382                 * Returns all created MIDI input devices.
383                 */
384                std::map<uint, MidiInputDevice*> GetMidiInputDevices();
385    
386                /**
387                 * Destroy the given audio output device and takes care if there
388                 * are still sampler engines connected to this device, etc.
389                 *
390                 * @throws Exception  if sampler channels are still
391                 *                    connected to the device
392                 */
393                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
410                 * 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 Exception  if sampler channels are still
426                 *                    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                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
444                 * channels, MIDI input devices and audio output devices.
445                 */
446                void Reset();
447    
448                ///////////////////////////////////////////////////////////////
449                // Event Listener methods
450    
451                /**
452               * Registers the specified listener to be notified               * Registers the specified listener to be notified
453               * when the number of sampler chanels is changed.               * when the number of sampler chanels is changed.
454               */               */
# Line 329  namespace LinuxSampler { Line 470  namespace LinuxSampler {
470               */               */
471              void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);              void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);
472    
               
473              /**              /**
474               * Registers the specified listener to be notified               * Registers the specified listener to be notified
475               * when the number of MIDI input devices is changed.               * when the number of MIDI input devices is changed.
# Line 418  namespace LinuxSampler { Line 558  namespace LinuxSampler {
558    
559              /**              /**
560               * Registers the specified listener to be notified when the number               * Registers the specified listener to be notified when the number
561               * of effect sends on a particular sampler channel is changed.               * of total streams is changed.
562               */               */
563              void AddFxSendCountListener(FxSendCountListener* l);              void AddTotalStreamCountListener(TotalStreamCountListener* l);
564    
565              /**              /**
566               * Removes the specified listener.               * Removes the specified listener.
567               */               */
568              void RemoveFxSendCountListener(FxSendCountListener* l);              void RemoveTotalStreamCountListener(TotalStreamCountListener* l);
   
             /**  
              * Returns the names of all available audio output drivers.  
              */  
             std::vector<String> AvailableAudioOutputDrivers();  
   
             /**  
              * Returns the names of all available MIDI input drivers.  
              */  
             std::vector<String> AvailableMidiInputDrivers();  
569    
570              /**              /**
571               * Returns the names of all available sampler engine types.               * Notifies listeners that the total number of total streams changed.
572               * @see SamplerChannel::SetEngineType()               * @param NewCount The new number of total streams.
              */  
             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  
573               */               */
574              MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);              void fireTotalStreamCountChanged(int NewCount);
575    
576              /**              /**
577               * Returns the number of all created audio output devices.               * Registers the specified listener to be notified when the number
578                 * of effect sends on a particular sampler channel is changed.
579               */               */
580              uint AudioOutputDevices();              void AddFxSendCountListener(FxSendCountListener* l);
581    
582              /**              /**
583               * Returns the number of all created MIDI input devices.               * Removes the specified listener.
584               */               */
585              uint MidiInputDevices();              void RemoveFxSendCountListener(FxSendCountListener* l);
586    
587              /**              /**
588               * Returns all created audio output devices.               * 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              std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();              void fireStatistics();
593    
594              /**              ///////////////////////////////////////////////////////////////
595               * Returns all created MIDI input devices.              // system specific methods
              */  
             std::map<uint, MidiInputDevice*> GetMidiInputDevices();  
596    
597              /**              /**
598               * Destroy the given audio output device and takes care if there               * Advise the FPU to treat denormal floating point numbers as
599               * are still sampler angines connected to this device, etc.               * zero, to avoid severe performance penalty when dealing with
600                 * such extreme floating point values.
601               *               *
602               * @throws Exception  if sampler channels are still               * @returns @c true if FPU supports it, @c false otherwise
              *                    connected to the device  
603               */               */
604              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);              static bool EnableDenormalsAreZeroMode();
605    
606    #if defined(WIN32)
607              /**              /**
608               * Destroy the given MIDI input device and takes care if there               * Gets the directory where the liblinuxsampler dll is located.
609               * are still sampler angines connected to this device, etc.               * Note: this method is currently only available for Windows.
610               *               * @returns installation directory
              * @throws Exception  if sampler channels are still  
              *                    connected to the device  
611               */               */
612              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);              static String GetInstallDir();
613    #endif
614            protected:
615              /**              /**
616               * Gets the current number of all active voices.               * Notifies listeners that the number of sampler channels has been changed.
617               * @returns The current number of all active voices.               * @param NewCount The new number of sampler channels.
618               */               */
619              int GetVoiceCount();              void fireChannelCountChanged(int NewCount);
620    
621              /**              /**
622               * Reset the whole sampler. Destroy all engines, sampler               * Notifies listeners that the specified sampler channel has just
623               * channels, MIDI input devices and audio output devices.               * been added.
624                 * @param pChannel The new sampler channel.
625               */               */
626              void Reset();              void fireChannelAdded(SamplerChannel* pChannel);
627    
         protected:  
628              /**              /**
629               * Notifies listeners that the number of sampler channels has been changed.               * Notifies listeners that the specified sampler channel is
630               * @param NewCount The new number of sampler channels.               * going to be removed soon.
631                 * @param pChannel sampler channel to be removed.
632               */               */
633              void fireChannelCountChanged(int NewCount);              void fireChannelToBeRemoved(SamplerChannel* pChannel);
634    
635              /**              /**
636               * 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 645  namespace LinuxSampler {
645              void fireMidiDeviceCountChanged(int NewCount);              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               * Notifies listeners that the number of effect sends
663               * on a particular sampler channel is changed.               * on a particular sampler channel is changed.
664               * @param ChannelId The numerical ID of the sampler channel.               * @param ChannelId The numerical ID of the sampler channel.
# Line 542  namespace LinuxSampler { Line 666  namespace LinuxSampler {
666               */               */
667              void fireFxSendCountChanged(int ChannelId, int NewCount);              void fireFxSendCountChanged(int ChannelId, int NewCount);
668    
             typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;  
             typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;  
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    
# Line 559  namespace LinuxSampler { Line 685  namespace LinuxSampler {
685              ListenerList<VoiceCountListener*> llVoiceCountListeners;              ListenerList<VoiceCountListener*> llVoiceCountListeners;
686              ListenerList<StreamCountListener*> llStreamCountListeners;              ListenerList<StreamCountListener*> llStreamCountListeners;
687              ListenerList<BufferFillListener*> llBufferFillListeners;              ListenerList<BufferFillListener*> llBufferFillListeners;
688                ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners;
689              ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;              ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;
690              ListenerList<FxSendCountListener*> llFxSendCountListeners;              ListenerList<FxSendCountListener*> llFxSendCountListeners;
691    
# Line 567  namespace LinuxSampler { Line 694  namespace LinuxSampler {
694                      void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }                      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                       * Invoked when the engine type of the
705                       * specified sampler channel is changed.                       * specified sampler channel is changed.
706                       * @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.1934

  ViewVC Help
Powered by ViewVC