Translate.Services.Audio.WavParser.ParseWaveHeader C# (CSharp) Метод

ParseWaveHeader() публичный Метод

Parses the RIFF WAVE header. .wav files should look like this: RIFF ('WAVE' 'fmt ' = WAVEFORMATEX structure 'data' = audio data )
public ParseWaveHeader ( ) : void
Результат void
        public void ParseWaveHeader()
        {
            bool foundData = false;

            try {
                while (!foundData) {
                    // Go through each chunk and look for the WavFmt which
                    // contains the format information
                    if (Chunk.FCC == FourCC.WavFmt) {
                        this.ReadFormatBlock();
                    }
                    else if (Chunk.FCC == FourCC.WavData || Chunk.FCC == FourCC.Wavdata) {
                        // Found the Wave data.
                        foundData = true;
                        break;
                    }

                    MoveToNextChunk();
                }
            }
            catch (Exception e) {
                if (this.waveFormat == null || !foundData) {
                    throw new InvalidOperationException("Invalid file format", e);
                }
            }

            // Now that we have a chunk with the data from the file,
            // calculate the duration of the file based on the size
            // of the buffer.
            this.duration = this.waveFormat.AudioDurationFromBufferSize(Chunk.Size);
        }