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 * ストリーム3Dサウンドヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef STREAM_SOUND_3D_H_ 00026 #define STREAM_SOUND_3D_H_ 00027 00028 #include <Sound/3D/Sound3D.h> 00029 00030 namespace Lamp{ 00031 00032 class SoundReader; 00033 class StreamPlayer; 00034 00035 //------------------------------------------------------------------------------ 00036 /** 00037 * ストリーム3Dサウンド 00038 */ 00039 class StreamSound3D : public Sound3D{ 00040 friend class SoundManager; 00041 public: 00042 //-------------------------------------------------------------------------- 00043 // 基本データ取得 00044 //-------------------------------------------------------------------------- 00045 /** 00046 * サウンドリーダの取得 00047 * @return サウンドリーダ 00048 */ 00049 virtual SoundReader* getSoundReader(){ return soundReader_; } 00050 00051 /** 00052 * ストリームプレーヤの取得 00053 * @return ストリームプレーヤ 00054 */ 00055 virtual StreamPlayer* getStreamPlayer(){ return streamPlayer_; } 00056 00057 //-------------------------------------------------------------------------- 00058 /** 00059 * サイズの取得 00060 * @return サイズ 00061 */ 00062 virtual u_int getSize() const; 00063 00064 //-------------------------------------------------------------------------- 00065 // 再生 00066 //-------------------------------------------------------------------------- 00067 /** 00068 * 再生 00069 * @return 正常に再生されればtrue 00070 */ 00071 virtual bool play(){ 00072 Assert((soundReader_ != NULL) && (streamPlayer_ != NULL)); 00073 return Sound3D::play(); 00074 } 00075 00076 /** 00077 * 停止 00078 */ 00079 virtual void stop(); 00080 00081 //-------------------------------------------------------------------------- 00082 // 再生位置 00083 //-------------------------------------------------------------------------- 00084 /** 00085 * 再生位置設定 00086 * @param cursor 再生位置のバイト数 00087 */ 00088 virtual void setCursor(u_int cursor); 00089 00090 /** 00091 * 再生位置取得 00092 * @return 再生位置のバイト数 00093 */ 00094 virtual u_int getCursor() const; 00095 00096 //-------------------------------------------------------------------------- 00097 // ループ 00098 //-------------------------------------------------------------------------- 00099 /** 00100 * ループ位置の設定 00101 * @param loopCursor ループ位置をバイト数で指定 00102 */ 00103 virtual void setLoopCursor(u_int loopCursor); 00104 00105 /** 00106 * ループ位置の取得 00107 * @return ループ位置のバイト数 00108 */ 00109 virtual u_int getLoopCursor() const; 00110 00111 //-------------------------------------------------------------------------- 00112 // RTTI 00113 //-------------------------------------------------------------------------- 00114 /** 00115 * ストリームを使用しているか 00116 * @return ストリームを使用しているtrue 00117 */ 00118 virtual bool useStream() const{ return true; } 00119 00120 /** 00121 * ストリーム3Dサウンドかどうか 00122 * @return ストリーム3Dサウンドならtrue 00123 */ 00124 virtual bool isStreamSound3D() const{ return true; } 00125 00126 protected: 00127 //-------------------------------------------------------------------------- 00128 // 生成、破棄 00129 //-------------------------------------------------------------------------- 00130 /** 00131 * コンストラクタ 00132 * @param soundBuffer サウンドバッファ 00133 */ 00134 StreamSound3D(DirectSoundBuffer* soundBuffer); 00135 00136 /** 00137 * デストラクタ 00138 */ 00139 virtual ~StreamSound3D(); 00140 00141 /** 00142 * サウンドリーダの設定 00143 * @param soundReader サウンドリーダ、ストリーム3Dサウンドによって 00144 * 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_DISTANCE | 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_3D_H_ 00172 //------------------------------------------------------------------------------