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

SoundReader.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  * サウンドリーダヘッダ
00022  * @author Junpee
00023  */
00024 
00025 #ifndef SOUND_READER_H_
00026 #define SOUND_READER_H_
00027 
00028 namespace Lamp{
00029 
00030 //------------------------------------------------------------------------------
00031 /**
00032  * サウンドリーダ
00033  */
00034 class SoundReader{
00035 public:
00036     /**
00037      * コンストラクタ
00038      */
00039     SoundReader(){}
00040 
00041     /**
00042      * デストラクタ
00043      */
00044     virtual ~SoundReader(){}
00045 
00046     //--------------------------------------------------------------------------
00047     /**
00048      * サイズの取得
00049      * @return サイズ
00050      */
00051     virtual u_int getSize() const = 0;
00052 
00053     /**
00054      * サンプル数の取得
00055      * @return サンプル数
00056      */
00057     virtual int getSample() const = 0;
00058 
00059     /**
00060      * チャンネル数の取得
00061      * @return チャンネル数
00062      */
00063     virtual int getChannel() const = 0;
00064 
00065     /**
00066      * ビット数の取得
00067      * @return ビット数
00068      */
00069     virtual int getBit() const = 0;
00070 
00071     /**
00072      * コメントの取得
00073      * @return コメント
00074      */
00075     virtual const String& getComment() = 0;
00076 
00077     //--------------------------------------------------------------------------
00078     /**
00079      * 長さの取得
00080      * @return 秒単位の長さ
00081      */
00082     virtual float getLength() const{ return byteToTime(getSize()); }
00083 
00084     /**
00085      * 1秒のバイト数取得
00086      * @return 1秒のバイト数
00087      */
00088     virtual int getOneSecondBytes() const{
00089         return (getSample() * (getChannel() * getBit() / 8));
00090     }
00091 
00092     /**
00093      * バイト数から時間への変換
00094      * @param byte バイト数
00095      * @return 秒単位の時間
00096      */
00097     virtual float byteToTime(u_int byte) const{
00098         Assert(byte < getSize());
00099         return (float)byte / (float)getOneSecondBytes();
00100     }
00101 
00102     /**
00103      * 時間からバイト数への変換
00104      * @return time 秒単位の時間
00105      * @return バイト数
00106      */
00107     virtual u_int timeToByte(float time) const{
00108         Assert((time >= 0.f) && (time < getLength()));
00109         return (u_int)(time * getOneSecondBytes());
00110     }
00111 
00112     //--------------------------------------------------------------------------
00113     /**
00114      * 位置の設定
00115      * @param cursor 設定する位置
00116      */
00117     virtual void setCursor(u_int cursor) = 0;
00118 
00119     /**
00120      * 位置の取得
00121      * @return 位置
00122      */
00123     virtual u_int getCursor() = 0;
00124 
00125     //--------------------------------------------------------------------------
00126     /**
00127      * ヘッダ読み込み
00128      * @return 成功すればtrue
00129      */
00130     virtual bool readHeader() = 0;
00131 
00132     /**
00133      * 読み込み
00134      * @param buffer 読み込みバッファ
00135      * @param size 読み込みサイズ
00136      * @return 読み込んだサイズ。終端なら0、失敗すれば-1
00137      */
00138     virtual int read(void* buffer, u_int size) = 0;
00139 
00140 private:
00141     // コピーコンストラクタの隠蔽
00142     SoundReader(const SoundReader& copy);
00143 
00144     // 代入コピーの隠蔽
00145     void operator =(const SoundReader& copy);
00146 
00147 };
00148 
00149 //------------------------------------------------------------------------------
00150 } // End of namespace Lamp
00151 #endif // End of SOUND_READER_H_
00152 //------------------------------------------------------------------------------
00153 

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