Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

WaveReader.h

Go to the documentation of this file.
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  * Waveリーダヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef WAVE_READER_H_
00026 #define WAVE_READER_H_
00027 
00028 #include <Sound/Reader/SoundReader.h>
00029 #include <Core/InputOutput/FilePath.h>
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 /**
00035  * Waveリーダ
00036  */
00037 class WaveReader : public SoundReader{
00038 public:
00039     /**
00040      * コンストラクタ
00041      * @param filePath ファイルパス
00042      */
00043     WaveReader(const FilePath& filePath);
00044 
00045     /**
00046      * デストラクタ
00047      */
00048     virtual ~WaveReader();
00049 
00050     //--------------------------------------------------------------------------
00051     /**
00052      * サイズの取得
00053      * @return サイズ
00054      */
00055     virtual u_int getSize() const{
00056         Assert(initialized_);
00057         return size_;
00058     }
00059 
00060     /**
00061      * サンプル数の取得
00062      * @return サンプル数
00063      */
00064     virtual int getSample() const{
00065         Assert(initialized_);
00066         return sample_;
00067     }
00068 
00069     /**
00070      * チャンネル数の取得
00071      * @return チャンネル数
00072      */
00073     virtual int getChannel() const{
00074         Assert(initialized_);
00075         return channel_;
00076     }
00077 
00078     /**
00079      * ビット数の取得
00080      * @return ビット数
00081      */
00082     virtual int getBit() const{
00083         Assert(initialized_);
00084         return bit_;
00085     }
00086 
00087     /**
00088      * コメントの取得
00089      * @return コメント
00090      */
00091     virtual const String& getComment(){
00092         Assert(initialized_);
00093         return comment_;
00094     }
00095 
00096     //--------------------------------------------------------------------------
00097     /**
00098      * 位置の設定
00099      * @param cursor 設定する位置
00100      */
00101     virtual void setCursor(u_int cursor);
00102 
00103     /**
00104      * 位置の取得
00105      * @return 位置
00106      */
00107     virtual u_int getCursor(){ return cursor_; }
00108 
00109     //--------------------------------------------------------------------------
00110     /**
00111      * ヘッダ読み込み
00112      * @return 成功すればtrue
00113      */
00114     virtual bool readHeader();
00115 
00116     /**
00117      * 読み込み
00118      * @param buffer 読み込みバッファ
00119      * @param size 読み込みサイズ
00120      * @return 読み込んだサイズ。終端なら0、失敗すれば-1
00121      */
00122     virtual int read(void* buffer, u_int size);
00123 
00124     //--------------------------------------------------------------------------
00125     /**
00126      * ファイルがWaveファイルか
00127      * @param filePath ファイルパス
00128      * @return Waveファイルならtrue
00129      */
00130     static bool isWaveFileName(const FilePath& filePath){
00131         return filePath.getExtension().equals("wav");
00132     }
00133 
00134 private:
00135     // ファイルパス
00136     FilePath filePath_;
00137     // ファイルハンドル
00138     HMMIO handle_;
00139     // RIFFチャンク
00140     MMCKINFO riffChunk_;
00141     // データチャンク
00142     MMCKINFO dataChunk_;
00143     // コメント
00144     String comment_;
00145     // データオフセット
00146     int dataOffset_;
00147     // 読み込み位置
00148     u_int cursor_;
00149     // サイズ
00150     u_int size_;
00151     // サンプル数
00152     int sample_;
00153     // チャンネル数
00154     int channel_;
00155     // ビット数
00156     int bit_;
00157     // 初期化済みフラグ
00158     bool initialized_;
00159 
00160 };
00161 
00162 //------------------------------------------------------------------------------
00163 } // End of namespace Lamp
00164 #endif // End of WAVE_READER_H_
00165 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:38 2005 for Lamp by doxygen 1.3.2