SoundLibrary.Wave.WaveReader.ReadDataChunk C# (CSharp) Method

ReadDataChunk() public static method

Wave ファイルストリームからデータチャンクを探す。 fmt chunk よりも data chunk が後ろにあると言う前提で、 ReadHeader の後に呼び出す。
public static ReadDataChunk ( BinaryReader reader ) : int
reader System.IO.BinaryReader 読み出し元のストリーム
return int
		public static int ReadDataChunk(BinaryReader reader)
		{
			int length = 0;

			while(true)
			{
				byte[] buf = reader.ReadBytes(4);
				length = reader.ReadInt32();

				if(length < 16)
				{
					throw new WaveException("ヘッダ長が短すぎます。");
				}
				if(Util.Equal(buf, Util.DATA))
				{
					break;
				}
				reader.ReadBytes(length);
			}
			return length;
		}

Usage Example

Beispiel #1
0
        }        //Skip

        /// <summary>
        /// ウェーブデータの先頭に戻る。
        /// </summary>
        public void Restart()
        {
            this.reader.BaseStream.Seek(0, SeekOrigin.Begin);
            WaveReader.ReadDataChunk(this.reader);
        }