snd_plib.hh

Go to the documentation of this file.
00001 /*
00008  * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
00009  *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
00010  *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
00011  *****************************************************************************/
00012 
00013 #if SOUND_PLIB
00014 #ifndef SND_PLIB_HH
00015 #define SND_PLIB_HH 1
00016 
00017 class slScheduler;  // alternative to including plib headers here
00018 class smMixer;
00019 class slSample;
00020 
00021 namespace snd {
00022 
00031 class SoundPlib : public SoundAbstract
00032 {
00033 
00034 private:
00035     SoundPlib( void );
00036     ~SoundPlib();
00037 
00038 private:
00042     class Sample : public Shared
00043     {
00044     public:
00045                     Sample( const string& filename, const fp volume = DEFAULT_VOLUME );
00046                     ~Sample();
00047         void        Play( const bool loop, const fp volume );
00048         void        Stop( void );
00049         void        SetVolume( const fp volume );
00050         fp          GetVolume( void );
00051 
00052     private:
00053         fp          mVolume;        
00054         bool        mPlaying;
00055         bool        mLoop;
00056         slSample*   mSLSample;      
00057         string      mBuf;           
00058     };
00059 
00060 //..............................................................................
00061 
00062 public:
00063     CLASS_METHOD SoundPlib& GetInstance( void );
00064     CLASS_METHOD void       Disable( void );
00065     void                    Play( const string& filename, const bool loop, const fp volume = DEFAULT_VOLUME );
00066     void                    Stop( const string& filename );
00067     void                    SetVolume( const string& filename, const fp volume );
00068 
00069 private:
00070     void                    Pulse( void );
00071     void                    EnqueueZombieSample( slSample* zombie );
00072 
00073 private:
00074     // Timer-tick handler.
00075     struct ListenerTick : public Event<gfx::Events::TickInfo>::ListenerFunctor
00076     {
00077         void operator()( gfx::Events::TickInfo tickInfo );
00078     };
00079     friend class ListenerTick;
00080 
00081 private:
00082     typedef map<string,SharedPtr<Sample> > SampleMap;
00083 
00084     CLASS_VAR SoundPlib*    msInstance;
00085     CLASS_VAR bool          msEnabled;          
00086     SampleMap               mSampleMap;         
00087     slScheduler*            mSched;             
00088     smMixer*                mMixer;             
00089     set<slSample*>          mZombieSamples;     
00090 };
00091 
00092 } // namespace snd
00093 
00094 #endif // SND_HH
00095 #endif // SOUND_PLIB
Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:13 2007