/[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 898 by schoenebeck, Wed Jul 5 16:29:44 2006 UTC revision 1765 by persson, Sat Sep 6 16:44:42 2008 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 - 2008 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 26  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/Exception.h"  #include "common/Exception.h"
32  #include "engines/EngineChannel.h"  #include "engines/EngineChannel.h"
# Line 52  namespace LinuxSampler { Line 53  namespace LinuxSampler {
53               *               *
54               * @param EngineType - type of the engine to use               * @param EngineType - type of the engine to use
55               * @throws Exception - if \a EngineType is invalid               * @throws Exception - if \a EngineType is invalid
56                 * @see Sampler::AvailableEngineTypes()
57               */               */
58              void SetEngineType(String EngineType) throw (Exception);              void SetEngineType(String EngineType) throw (Exception);
59    
# Line 149  namespace LinuxSampler { Line 151  namespace LinuxSampler {
151               */               */
152              uint Index();              uint Index();
153    
154                /** Returns the sampler to which this channel belongs */
155                Sampler* GetSampler();
156                
157                /**
158                 * Registers the specified listener to be notified
159                 * when the engine type of this sampler channel is changed.
160                 */
161                void AddEngineChangeListener(EngineChangeListener* l);
162    
163                /**
164                 * Removes the specified listener.
165                 */
166                void RemoveEngineChangeListener(EngineChangeListener* l);
167    
168                /**
169                 * Removes the specified listener.
170                 */
171                void RemoveAllEngineChangeListeners();
172    
173                /**
174                 * Notifies listeners that the engine type of this sampler
175                 * channel is going to be changed soon.
176                 */
177                void fireEngineToBeChanged();
178    
179                /**
180                 * Notifies listeners that the engine
181                 * type of this sampler channel is changed.
182                 */
183                void fireEngineChanged();
184    
185    
186          protected:          protected:
187              SamplerChannel(Sampler* pS);              SamplerChannel(Sampler* pS);
188              virtual ~SamplerChannel();              virtual ~SamplerChannel();
# Line 166  namespace LinuxSampler { Line 200  namespace LinuxSampler {
200          private:          private:
201              int                iMidiPort;   ///< Don't access directly, read GetMidiInputPort() instead !              int                iMidiPort;   ///< Don't access directly, read GetMidiInputPort() instead !
202              midi_chan_t        midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead !              midi_chan_t        midiChannel; ///< Don't access directly, read GetMidiInputChannel() instead !
203                ListenerList<EngineChangeListener*> llEngineChangeListeners;
204      };      };
205    
206      /** @brief LinuxSampler main class      /** @brief LinuxSampler main class
# Line 282  namespace LinuxSampler { Line 317  namespace LinuxSampler {
317              void RemoveSamplerChannel(uint uiSamplerChannel);              void RemoveSamplerChannel(uint uiSamplerChannel);
318    
319              /**              /**
320                 * Registers the specified listener to be notified
321                 * when the number of sampler chanels is changed.
322                 */
323                void AddChannelCountListener(ChannelCountListener* l);
324    
325                /**
326                 * Removes the specified listener.
327                 */
328                void RemoveChannelCountListener(ChannelCountListener* l);
329    
330                /**
331                 * Registers the specified listener to be notified
332                 * when the number of audio output devices is changed.
333                 */
334                void AddAudioDeviceCountListener(AudioDeviceCountListener* l);
335    
336                /**
337                 * Removes the specified listener.
338                 */
339                void RemoveAudioDeviceCountListener(AudioDeviceCountListener* l);
340    
341                
342                /**
343                 * Registers the specified listener to be notified
344                 * when the number of MIDI input devices is changed.
345                 */
346                void AddMidiDeviceCountListener(MidiDeviceCountListener* l);
347    
348                /**
349                 * Removes the specified listener.
350                 */
351                void RemoveMidiDeviceCountListener(MidiDeviceCountListener* l);
352    
353                /**
354                 * Registers the specified listener to be notified when the number
355                 * of active voices in a particular sampler channel is changed.
356                 */
357                void AddVoiceCountListener(VoiceCountListener* l);
358    
359                /**
360                 * Removes the specified listener.
361                 */
362                void RemoveVoiceCountListener(VoiceCountListener* l);
363    
364                /**
365                 * Notifies listeners that the number of active voices
366                 * on the specified sampler channel is changed.
367                 * @param ChannelId The numerical ID of the sampler channel.
368                 * @param NewCount The new number of active voices.
369                 */
370                void fireVoiceCountChanged(int ChannelId, int NewCount);
371    
372                /**
373                 * Registers the specified listener to be notified when the number
374                 * of active disk streams in a particular sampler channel is changed.
375                 */
376                void AddStreamCountListener(StreamCountListener* l);
377    
378                /**
379                 * Removes the specified listener.
380                 */
381                void RemoveStreamCountListener(StreamCountListener* l);
382    
383                /**
384                 * Notifies listeners that the number of active disk streams
385                 * on the specified sampler channel is changed.
386                 * @param ChannelId The numerical ID of the sampler channel.
387                 * @param NewCount The new number of active disk streams.
388                 */
389                void fireStreamCountChanged(int ChannelId, int NewCount);
390    
391                /**
392                 * Registers the specified listener to be
393                 * notified when the fill state of the disk stream
394                 * buffers on a specific sampler channel is changed.
395                 */
396                void AddBufferFillListener(BufferFillListener* l);
397    
398                /**
399                 * Removes the specified listener.
400                 */
401                void RemoveBufferFillListener(BufferFillListener* l);
402    
403                /**
404                 * Notifies listeners that the fill state of the disk stream
405                 * buffers on the specified sampler channel is changed.
406                 * @param ChannelId The numerical ID of the sampler channel.
407                 * @param FillData The buffer fill data for the specified sampler channel.
408                 */
409                void fireBufferFillChanged(int ChannelId, String FillData);
410    
411                /**
412                 * Registers the specified listener to be notified
413                 * when total number of active voices is changed.
414                 */
415                void AddTotalVoiceCountListener(TotalVoiceCountListener* l);
416    
417                /**
418                 * Removes the specified listener.
419                 */
420                void RemoveTotalVoiceCountListener(TotalVoiceCountListener* l);
421    
422                /**
423                 * Notifies listeners that the total number of active voices is changed.
424                 * @param NewCount The new number of active voices.
425                 */
426                void fireTotalVoiceCountChanged(int NewCount);
427                
428                void AddTotalStreamCountListener(TotalStreamCountListener* l);
429                void RemoveTotalStreamCountListener(TotalStreamCountListener* l);
430                void fireTotalStreamCountChanged(int NewCount);
431    
432                /**
433                 * Registers the specified listener to be notified when the number
434                 * of effect sends on a particular sampler channel is changed.
435                 */
436                void AddFxSendCountListener(FxSendCountListener* l);
437    
438                /**
439                 * Removes the specified listener.
440                 */
441                void RemoveFxSendCountListener(FxSendCountListener* l);
442    
443                /**
444               * Returns the names of all available audio output drivers.               * Returns the names of all available audio output drivers.
445               */               */
446              std::vector<String> AvailableAudioOutputDrivers();              std::vector<String> AvailableAudioOutputDrivers();
447    
448              /**              /**
449                 * Returns the names of all available MIDI input drivers.
450                 */
451                std::vector<String> AvailableMidiInputDrivers();
452    
453                /**
454                 * Returns the names of all available sampler engine types.
455                 * @see SamplerChannel::SetEngineType()
456                 */
457                std::vector<String> AvailableEngineTypes();
458    
459                /**
460               * Create an audio output device.               * Create an audio output device.
461               *               *
462               * @param AudioDriver - name of the audio driver               * @param AudioDriver - name of the audio driver
# Line 346  namespace LinuxSampler { Line 516  namespace LinuxSampler {
516               */               */
517              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);              void DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (Exception);
518    
519                 /**
520                 * Gets the current number of all active streams.
521                 * @returns The current number of all active streams.
522                 */
523                int GetDiskStreamCount();
524    
525              /**              /**
526               * Gets the current number of all active voices.               * Gets the current number of all active voices.
527               * @returns The current number of all active voices.               * @returns The current number of all active voices.
# Line 358  namespace LinuxSampler { Line 534  namespace LinuxSampler {
534               */               */
535              void Reset();              void Reset();
536    
537                /**
538                 * Advise the FPU to treat denormal floating point numbers as
539                 * zero, to avoid severe performance penalty when dealing with
540                 * such extreme floating point values.
541                 *
542                 * @returns @c true if FPU supports it, @c false otherwise
543                 */
544                static bool EnableDenormalsAreZeroMode();
545    
546                /**
547                 * Notifies listeners about the current number of voices,
548                 * streams and total voices, and the current fill state of
549                 * the disk stream buffers.
550                 */
551                void fireStatistics();
552    
553          protected:          protected:
554                /**
555                 * Notifies listeners that the number of sampler channels has been changed.
556                 * @param NewCount The new number of sampler channels.
557                 */
558                void fireChannelCountChanged(int NewCount);
559    
560                /**
561                 * Notifies listeners that the specified sampler channel has just
562                 * been added.
563                 * @param pChannel The new sampler channel.
564                 */
565                void fireChannelAdded(SamplerChannel* pChannel);
566    
567                /**
568                 * Notifies listeners that the specified sampler channel is
569                 * going to be removed soon.
570                 * @param pChannel sampler channel to be removed.
571                 */
572                void fireChannelToBeRemoved(SamplerChannel* pChannel);
573    
574                /**
575                 * Notifies listeners that the number of audio output devices has been changed.
576                 * @param NewCount The new number of audio output devices.
577                 */
578                void fireAudioDeviceCountChanged(int NewCount);
579    
580                /**
581                 * Notifies listeners that the number of MIDI input devices has been changed.
582                 * @param NewCount The new number of MIDI input devices.
583                 */
584                void fireMidiDeviceCountChanged(int NewCount);
585    
586                /**
587                 * Notifies listeners that the supplied MIDI input device is
588                 * going to be destroyed soon.
589                 * @param pDevice MIDI input device to be destroyed
590                 */
591                void fireMidiDeviceToBeDestroyed(MidiInputDevice* pDevice);
592    
593                /**
594                 * Notifies listeners that the supplied MIDI input device was
595                 * just created.
596                 * @param pDevice new MIDI input device
597                 */
598                void fireMidiDeviceCreated(MidiInputDevice* pDevice);
599    
600                /**
601                 * Notifies listeners that the number of effect sends
602                 * on a particular sampler channel is changed.
603                 * @param ChannelId The numerical ID of the sampler channel.
604                 * @param NewCount The new number of sampler channels.
605                 */
606                void fireFxSendCountChanged(int ChannelId, int NewCount);
607    
608              typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;              typedef std::map<uint, AudioOutputDevice*> AudioOutputDeviceMap;
609              typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;              typedef std::map<uint, MidiInputDevice*> MidiInputDeviceMap;
610              typedef std::map<uint, SamplerChannel*> SamplerChannelMap;              typedef std::map<uint, SamplerChannel*> SamplerChannelMap;
# Line 368  namespace LinuxSampler { Line 614  namespace LinuxSampler {
614              MidiInputDeviceMap    mMidiInputDevices;   ///< contains all created MIDI input devices              MidiInputDeviceMap    mMidiInputDevices;   ///< contains all created MIDI input devices
615    
616              friend class SamplerChannel;              friend class SamplerChannel;
617    
618            private:
619                ListenerList<ChannelCountListener*> llChannelCountListeners;
620                ListenerList<AudioDeviceCountListener*> llAudioDeviceCountListeners;
621                ListenerList<MidiDeviceCountListener*> llMidiDeviceCountListeners;
622                ListenerList<VoiceCountListener*> llVoiceCountListeners;
623                ListenerList<StreamCountListener*> llStreamCountListeners;
624                ListenerList<BufferFillListener*> llBufferFillListeners;
625                ListenerList<TotalStreamCountListener*> llTotalStreamCountListeners;
626                ListenerList<TotalVoiceCountListener*> llTotalVoiceCountListeners;
627                ListenerList<FxSendCountListener*> llFxSendCountListeners;
628    
629                class EventHandler : public EngineChangeListener, public FxSendCountListener {
630                    public:
631                        void SetSampler(Sampler* pSampler) { this->pSampler = pSampler; }
632    
633                        /**
634                         * Invoked when the engine type of the specified sampler
635                         * channel is going to be changed soon.
636                         * @param ChannelId The numerical ID of the sampler channel
637                         */
638                        virtual void EngineToBeChanged(int ChannelId);
639    
640                        /**
641                         * Invoked when the engine type of the
642                         * specified sampler channel is changed.
643                         * @param ChannelId The numerical ID of the sampler
644                         * channel, which engine type has been changed.
645                         */
646                        virtual void EngineChanged(int ChannelId);
647    
648                        /**
649                         * Invoked when the number of effect sends
650                         * on the specified sampler channel has changed.
651                         * @param ChannelId The numerical ID of the sampler channel.
652                         * @param NewCount The new number of effect sends.
653                         */
654                        virtual void FxSendCountChanged(int ChannelId, int NewCount);
655    
656                    private:
657                        Sampler* pSampler;
658                } eventHandler;
659      };      };
660  }  }
661    

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

  ViewVC Help
Powered by ViewVC