Esempio n. 1
0
        public WaveFormat(BinaryStream stream)
        {
            UInt32 riffChunkSize = Riff.VerifyChunkIdAndGetSize(stream, Riff.RiffHeaderID);

            Console.WriteLine("Riff Chunk Size {0}", riffChunkSize);

            Riff.Verify(stream, Wave.WaveHeaderID, "Expected RIFF format to be");

            UInt32 formatChunkSize = Riff.VerifyChunkIdAndGetSize(stream, Wave.FmtHeaderID);

            if (formatChunkSize < 16)
            {
                throw new FormatException(String.Format("Expected wave 'fmt ' chunk size to be at least 16 but is {0}", formatChunkSize));
            }


            this.audioFormat  = stream.LittleEndianReadUInt16();
            this.channelCount = stream.LittleEndianReadUInt16();

            this.samplesPerSecond  = stream.LittleEndianReadUInt32();
            this.avgBytesPerSecond = stream.LittleEndianReadUInt32();

            this.blockAlign    = stream.LittleEndianReadUInt16();
            this.bitsPerSample = stream.LittleEndianReadUInt16();

            // skip extra parameters
            stream.Skip((Int32)formatChunkSize - 16);

            //
            this.dataChunkSize = Riff.VerifyChunkIdAndGetSize(stream, Wave.DataHeaderID);
        }