Ejemplo n.º 1
0
        /// <summary>
        /// Read the format block from the file and construct the WAVEFORMATEX
        /// structure
        /// </summary>
        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;
            }
        }
Ejemplo n.º 2
0
        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");
                uint formatSize = 0;
                if (Chunk.Size < MinFormatSize)
                {
                }
                formatSize = Chunk.Size;

                this.waveFormat = new WAVEFORMATEX();

                byte[] data = ReadDataFromChunk(formatSize);

                this.waveFormat.SetFromByteArray(data);
            }
            catch (Exception)
            {
                this.waveFormat = null;
                throw;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read the format block from the file and construct the WAVEFORMATEX
        /// structure
        /// </summary>
        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;
            }
        }