Beispiel #1
0
        public RIFFHeader ReadHeader()
        {
            RIFFHeader header = new RIFFHeader();
            header.sGroupID = ReadFourCC();
            header.dwFileLength = fReader.ReadUInt32();
            header.sRiffType = ReadFourCC();

            return header;
        }
Beispiel #2
0
        public WaveFile(string filename)
        {
            fFileName = filename;
            RIFFStreamReader fReader = new RIFFStreamReader(filename);
            fBinaryReader = fReader.BinaryReader;
            fHeader = fReader.ReadHeader();

            // Read the chunks from the file
            uint chunkName = 0;
            while (fReader.Position < (long) fHeader.dwFileLength)
            {
                chunkName = fReader.ReadFourCC();

                switch (chunkName)
                {
                    case FOURCC.fmt:
                        fFormat = fReader.ReadFormatChunk();
                        if (fReader.Position + fFormat.dwChunkSize == fHeader.dwFileLength)
                            return;
                    break;

                    case FOURCC.fact:

                        fFact = fReader.ReadFactChunk();
                        if (fReader.Position + fFact.dwChunkSize == fHeader.dwFileLength)
                            return;
                    break;

                    case FOURCC.data:
                        fData = fReader.ReadDataChunk();
                        if (fReader.Position + fData.dwChunkSize == fHeader.dwFileLength)
                            return;
                        break;

                    default:
                        // Skip over unsupported chunks.
                        fReader.AdvanceToNext();
                        break;
                }
            }
        }