Esempio n. 1
0
        public void Parse(BinaryReader reader)
        {
            _header = RiffHeader.Parse(reader);
            _format = WaveFormat.Parse(reader);

            // Every format except the original PCM format must have a fact chunk
            if ((AudioFormatType)_format.AudioFormat != AudioFormatType.Pcm)
            {
                _fact = WaveFact.Parse(reader);
            }

            _data   = WaveData.Parse(reader);
            _buffer = WavParser
                      .GetParser((AudioFormatType)_format.AudioFormat)
                      .Parse(reader, (int)_data.SubChunkSize, _format);
        }
Esempio n. 2
0
        public static WaveFact Parse(BinaryReader reader)
        {
            var fact = new WaveFact();

            fact.SubChunkID = reader.ReadFourCc();
            if (fact.SubChunkID != "fact")
            {
                throw new InvalidDataException("Invalid or missing .wav file fact chunk!");
            }
            fact.SubChunkSize = reader.ReadUInt32();
            if (fact.SubChunkSize != 4)
            {
                throw new NotSupportedException("Invalid or unknown .wav compression format!");
            }
            fact.NumSamples = reader.ReadUInt32();
            return(fact);
        }