/[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 1765 by persson, Sat Sep 6 16:44:42 2008 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 - 2008 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 153  namespace LinuxSampler { Line 170  namespace LinuxSampler {
170    
171              /** Returns the sampler to which this channel belongs */              /** Returns the sampler to which this channel belongs */
172              Sampler* GetSampler();              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 317  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 338  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 424  namespace LinuxSampler { Line 602  namespace LinuxSampler {
602               * @param NewCount The new number of active voices.               * @param NewCount The new number of active voices.
603               */               */
604              void fireTotalVoiceCountChanged(int NewCount);              void fireTotalVoiceCountChanged(int NewCount);
               
             void AddTotalStreamCountListener(TotalStreamCountListener* l);  
             void RemoveTotalStreamCountListener(TotalStreamCountListener* l);  
             void fireTotalStreamCountChanged(int NewCount);  
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);
   
             /**  
              * 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();  
   
             /**  
              * 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  
              */  
             MidiInputDevice* CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (Exception);  
   
             /**  
              * Returns the number of all created audio output devices.  
              */  
             uint AudioOutputDevices();  
   
             /**  
              * Returns the number of all created MIDI input devices.  
              */  
             uint MidiInputDevices();  
616    
617              /**              /**
618               * Returns all created audio output devices.               * Notifies listeners that the total number of total streams changed.
619                 * @param NewCount The new number of total streams.
620               */               */
621              std::map<uint, AudioOutputDevice*> GetAudioOutputDevices();              void fireTotalStreamCountChanged(int NewCount);
   
             /**  
              * Returns all created MIDI input devices.  
              */  
             std::map<uint, MidiInputDevice*> GetMidiInputDevices();  
622    
623              /**              /**
624               * Destroy the given audio output device and takes care if there               * Registers the specified listener to be notified when the number
625               * are still sampler angines connected to this device, etc.               * of effect sends on a particular sampler channel is changed.
              *  
              * @throws Exception  if sampler channels are still  
              *                    connected to the device  
626               */               */
627              void DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception);              void AddFxSendCountListener(FxSendCountListener* l);
628    
629              /**              /**
630               * Destroy the given MIDI input device and takes care if there               * Removes the specified listener.
              * are still sampler angines connected to this device, etc.  
              *  
              * @throws Exception  if sampler channels are still  
              *                    connected to the device  
              */  
             void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);  
   
              /**  
              * Gets the current number of all active streams.  
              * @returns The current number of all active streams.  
631               */               */
632              int GetDiskStreamCount();              void RemoveFxSendCountListener(FxSendCountListener* l);
633    
634              /**              /**
635               * Gets the current number of all active voices.               * Notifies listeners about the current number of voices,
636               * @returns The current number of all active voices.               * streams and total voices, and the current fill state of
637                 * the disk stream buffers.
638               */               */
639              int GetVoiceCount();              void fireStatistics();
640    
641              /**              ///////////////////////////////////////////////////////////////
642               * Reset the whole sampler. Destroy all engines, sampler              // system specific methods
              * channels, MIDI input devices and audio output devices.  
              */  
             void Reset();  
643    
644              /**              /**
645               * Advise the FPU to treat denormal floating point numbers as               * Advise the FPU to treat denormal floating point numbers as
# Line 543  namespace LinuxSampler { Line 650  namespace LinuxSampler {
650               */               */
651              static bool EnableDenormalsAreZeroMode();              static bool EnableDenormalsAreZeroMode();
652    
653    #if defined(WIN32)
654              /**              /**
655               * Notifies listeners about the current number of voices,               * Gets the directory where the liblinuxsampler dll is located.
656               * streams and total voices, and the current fill state of               * Note: this method is currently only available for Windows.
657               * the disk stream buffers.               * @returns installation directory
658               */               */
659              void fireStatistics();              static String GetInstallDir();
660    #endif
661          protected:          protected:
662              /**              /**
663               * Notifies listeners that the number of sampler channels has been changed.               * Notifies listeners that the number of sampler channels has been changed.
# Line 605  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    

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

  ViewVC Help
Powered by ViewVC