00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * ストリームサウンドヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef STREAM_SOUND_H_ 00026 #define STREAM_SOUND_H_ 00027 00028 #include <Sound/Stereo/StereoSound.h> 00029 #include <Sound/System/SoundDefinition.h> 00030 00031 namespace Lamp{ 00032 00033 class SoundReader; 00034 class StreamPlayer; 00035 00036 //------------------------------------------------------------------------------ 00037 /** 00038 * ストリームサウンド 00039 */ 00040 class StreamSound : public StereoSound{ 00041 friend class SoundManager; 00042 public: 00043 //-------------------------------------------------------------------------- 00044 // 基本データ取得 00045 //-------------------------------------------------------------------------- 00046 /** 00047 * サウンドリーダの取得 00048 * @return サウンドリーダ 00049 */ 00050 virtual SoundReader* getSoundReader(){ return soundReader_; } 00051 00052 /** 00053 * ストリームプレーヤの取得 00054 * @return ストリームプレーヤ 00055 */ 00056 virtual StreamPlayer* getStreamPlayer(){ return streamPlayer_; } 00057 00058 //-------------------------------------------------------------------------- 00059 /** 00060 * サイズの取得 00061 * @return サイズ 00062 */ 00063 virtual u_int getSize() const; 00064 00065 //-------------------------------------------------------------------------- 00066 // 再生 00067 //-------------------------------------------------------------------------- 00068 /** 00069 * 再生 00070 * @return 正常に再生されればtrue 00071 */ 00072 virtual bool play(){ 00073 Assert((soundReader_ != NULL) && (streamPlayer_ != NULL)); 00074 return StereoSound::play(); 00075 } 00076 00077 /** 00078 * 停止 00079 */ 00080 virtual void stop(); 00081 00082 //-------------------------------------------------------------------------- 00083 // 再生位置 00084 //-------------------------------------------------------------------------- 00085 /** 00086 * 再生位置設定 00087 * @param cursor 再生位置のバイト数 00088 */ 00089 virtual void setCursor(u_int cursor); 00090 00091 /** 00092 * 再生位置取得 00093 * @return 再生位置のバイト数 00094 */ 00095 virtual u_int getCursor() const; 00096 00097 //-------------------------------------------------------------------------- 00098 // ループ 00099 //-------------------------------------------------------------------------- 00100 /** 00101 * ループ位置の設定 00102 * @param loopCursor ループ位置をバイト数で指定 00103 */ 00104 virtual void setLoopCursor(u_int loopCursor); 00105 00106 /** 00107 * ループ位置の取得 00108 * @return ループ位置のバイト数 00109 */ 00110 virtual u_int getLoopCursor() const; 00111 00112 //-------------------------------------------------------------------------- 00113 // RTTI 00114 //-------------------------------------------------------------------------- 00115 /** 00116 * ストリームを使用しているか 00117 * @return ストリームを使用しているtrue 00118 */ 00119 virtual bool useStream() const{ return true; } 00120 00121 /** 00122 * ストリームサウンドかどうか 00123 * @return ストリームサウンドならtrue 00124 */ 00125 virtual bool isStreamSound() const{ return true; } 00126 00127 protected: 00128 //-------------------------------------------------------------------------- 00129 // 生成、破棄 00130 //-------------------------------------------------------------------------- 00131 /** 00132 * コンストラクタ 00133 * @param soundBuffer サウンドバッファ 00134 */ 00135 StreamSound(DirectSoundBuffer* soundBuffer); 00136 00137 /** 00138 * デストラクタ 00139 */ 00140 virtual ~StreamSound(); 00141 00142 /** 00143 * サウンドリーダの設定 00144 * @param soundReader サウンドリーダ、ストリームサウンドによってdeleteされる。 00145 */ 00146 virtual void setSoundReader(SoundReader* soundReader); 00147 00148 //-------------------------------------------------------------------------- 00149 /** 00150 * 再生フラグの取得 00151 * @return 再生フラグ 00152 */ 00153 virtual u_int getPlayFlag(){ 00154 // プライオリティ、再生時間による動的ボイス管理、ループ 00155 u_int result = ( 00156 // DSBPLAY_TERMINATEBY_PRIORITY | 00157 // DSBPLAY_TERMINATEBY_TIME | 00158 DSBPLAY_LOOPING); 00159 return result; 00160 } 00161 00162 private: 00163 // サウンドリーダ 00164 SoundReader* soundReader_; 00165 // ストリームプレーヤ 00166 StreamPlayer* streamPlayer_; 00167 }; 00168 00169 //------------------------------------------------------------------------------ 00170 } // End of namespace Lamp 00171 #endif // End of STREAM_SOUND_H_ 00172 //------------------------------------------------------------------------------