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_MUSIC_HEADER__ 00022 #define __AUDIO_MUSIC_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 MusicData { 00040 public: 00041 MusicData(const std::string & fname); 00042 ~MusicData(); 00043 00045 std::string filename; 00047 uint8 reference_count; 00049 Mix_Music *music; 00051 bool playing; 00052 00054 bool IsValid(); 00056 void RemoveReference(); 00057 00059 void DEBUG_PrintProperties(); 00060 }; 00061 00062 } // namespace private_audio 00063 00064 class MusicDescriptor { 00065 friend class GameAudio; 00066 public: 00067 MusicDescriptor(); 00068 ~MusicDescriptor(); 00069 00071 const std::string &GetFilename() 00072 { if (_data != NULL) return _data->filename; throw std::runtime_error("MusicDescriptor: Can't get the filename reference!"); } 00073 00077 bool LoadMusic(const std::string & fname); 00082 void FreeMusic(); 00083 00089 void PlayMusic(); 00090 void PauseMusic(); 00091 void ResumeMusic(); 00092 void StopMusic(); 00093 void RewindMusic(); 00094 void SeekMusic(float seconds); 00096 00100 uint8 GetMusicState(); 00101 00103 bool IsPlaying(); 00104 00109 void SetLoopCount(int32 loops) 00110 { _loop_count = loops; } 00111 void SetFadeInTime(uint32 fade_time) 00112 { _fade_in_time = fade_time; } 00113 void SetFadeOutTime(uint32 fade_time) 00114 { _fade_out_time = fade_time; } 00115 void SetPlayTimeout(uint32 timeout) 00116 { _play_timeout = timeout; } 00118 00120 void DEBUG_dataProperties() 00121 { if (_data != NULL) _data->DEBUG_PrintProperties(); } 00122 private: 00124 private_audio::MusicData *_data; 00130 int32 _loop_count; 00134 uint32 _fade_in_time; 00138 uint32 _fade_out_time; 00142 int32 _play_timeout; 00143 }; // class MusicDescriptor 00144 00145 } // namespace hoa_audio 00146 00147 #endif /* #ifndef __AUDIO_MUSIC_HEADER__ */
1.5.1