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

ReadFormatBlock() приватный Метод

Read the format block from the file and construct the WAVEFORMATEX structure
private ReadFormatBlock ( ) : void
Результат void
        private void ReadFormatBlock()
        {
            try {
                Debug.Assert(Chunk.FCC == FourCC.WavFmt, "This is not a WavFmt chunk");
                Debug.Assert(this.waveFormat == null, "The waveformat structure should have been set before");

                // Some .wav files do not include the cbSize field of the WAVEFORMATEX
                // structure. For uncompressed PCM audio, field is always zero.
                uint formatSize = 0;
                if (Chunk.Size < MinFormatSize) {
                    throw new InvalidOperationException("File is not a WAV file");
                }

                // Allocate a buffer for the WAVEFORMAT structure.
                formatSize = Chunk.Size;

                this.waveFormat = new WaveFormatEx();

                // Read the format from the current chunk in the file
                byte[] data = ReadDataFromChunk(formatSize);

                // Copy the read data into our WAVFORMATEX
                this.waveFormat.SetFromByteArray(data);
            }
            catch (Exception) {
                this.waveFormat = null;
                throw;
            }
        }