audio_sound.h

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software 
00006 // and you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
00009 
00021 #ifndef __AUDIO_SOUND_HEADER__
00022 #define __AUDIO_SOUND_HEADER__
00023 
00024 #include "utils.h"
00025 #include "defs.h"
00026 #include "audio.h"
00027 
00028 namespace hoa_audio {
00029 
00030 namespace private_audio {
00031 
00039 class SoundData {
00040 public:
00041   SoundData(std::string fname);
00042   ~SoundData();
00043 
00045   std::string filename;
00047   int8 reference_count;
00049   Mix_Chunk *sound;
00050 
00052   bool IsValid();
00054   void RemoveReference();
00056   void DEBUG_PrintProperties();
00057 };
00058 
00059 } // namespace private_audio
00060 
00061 /*!****************************************************************************
00062  * \brief Manages sound data loaded from memory.
00063  *
00064  * The purpose of this class is to provide the API user with an easy-to-use
00065  * interface for manipulating sound data.This class holds all the properties
00066  * about a given sound. Including its location, velocity, whether or not it
00067  * loops, and numerous other properties.
00068  *****************************************************************************/
00069 class SoundDescriptor {
00070   friend class GameAudio;
00071 public:
00072   SoundDescriptor();
00073   ~SoundDescriptor();
00074   
00076   const std::string &GetFilename()
00077     { if (_data != NULL) return _data->filename; }
00082   bool LoadSound(std::string fname);
00087   void FreeSound();
00088 
00094   void PlaySound();
00095   void PauseSound();
00096   void ResumeSound();
00097   void StopSound();
00098   // Rewinding and seeking of sounds is not supported in SDL_mixer
00099 //  void RewindSound();
00100 //  void SeekSound(float seconds);
00102 
00106   uint8 GetSoundState();
00107 
00112   void SetLoopCount(int32 loops)
00113     { _loop_count = loops; }
00114   void SetFadeInTime(uint32 fade_time)
00115     { _fade_in_time = fade_time; }
00116   void SetFadeOutTime(uint32 fade_time)
00117     { _fade_out_time = fade_time; }
00118   void SetPlayTimeout(uint32 timeout)
00119     { _play_timeout = timeout; }
00121 
00126   int32 GetLoopCount()
00127     { return _loop_count; }
00128   uint32 GetFadeInTime()
00129     { return _fade_in_time; }
00130   uint32 GetFadeOutTime()
00131     { return _fade_out_time; }
00132   int32 GetPlayTimeout()
00133     { return _play_timeout; }
00135 
00137   void DEBUG_DataProperties()
00138     { if (_data != NULL) _data->DEBUG_PrintProperties(); }
00139 private:
00141   private_audio::SoundData *_data;
00148   int32 _channel;
00154   int32 _loop_count;
00158   uint32 _fade_in_time;
00162   uint32 _fade_out_time;
00166   int32 _play_timeout;
00167 }; // class SoundDescriptor
00168 
00169 } // namespace hoa_audio
00170 
00171 #endif /* #ifndef __AUDIO_SOUND_HEADER__ */

Generated on Fri Jul 6 23:11:09 2007 for Hero of Allacrost by  doxygen 1.5.1