Exemplo n.º 1
0
        private void ParseFmt(Riff.RiffReader reader)
        {
            Ibasa.IO.BinaryReader binreader = new IO.BinaryReader(reader.Data);

            FormatTag tag;
            int       channels, bytesPerSecond, blockAlignment, bitsPerSample, size;

            if (reader.Length < 16)
            {
                throw new System.IO.InvalidDataException("Invalid fmt chunk.");
            }
            else
            {
                tag            = (FormatTag)binreader.ReadInt16();
                channels       = binreader.ReadInt16();
                Frequency      = binreader.ReadInt32();
                bytesPerSecond = binreader.ReadInt32();
                blockAlignment = binreader.ReadInt16();
                bitsPerSample  = binreader.ReadInt16();
            }

            if (reader.Length >= 18)
            {
                size = binreader.ReadInt16();
            }

            if (tag == FormatTag.Pcm)
            {
                if (bitsPerSample == 8)
                {
                    Format = new Ibasa.SharpAL.Formats.Pcm8(channels);
                }
                else if (bitsPerSample == 16)
                {
                    Format = new Ibasa.SharpAL.Formats.Pcm16(channels);
                }
                else
                {
                    throw new NotSupportedException(string.Format("PCM {0} bit data is not supported.", bitsPerSample));
                }
            }
            else
            {
                throw new NotSupportedException(string.Format("{0} is not supported.", tag));
            }
        }
Exemplo n.º 2
0
Arquivo: Wav.cs Projeto: Frassle/Ibasa
        private void ParseFmt(Riff.RiffReader reader)
        {
            Ibasa.IO.BinaryReader binreader = new IO.BinaryReader(reader.Data);

            FormatTag tag;
            int channels, bytesPerSecond, blockAlignment,bitsPerSample, size;
            if (reader.Length < 16)
            {
                throw new System.IO.InvalidDataException("Invalid fmt chunk.");
            }
            else
            {
                tag = (FormatTag)binreader.ReadInt16();
                channels = binreader.ReadInt16();
                Frequency = binreader.ReadInt32();
                bytesPerSecond = binreader.ReadInt32();
                blockAlignment = binreader.ReadInt16();
                bitsPerSample = binreader.ReadInt16();
            }

            if (reader.Length >= 18)
            {
                size = binreader.ReadInt16();
            }

            if (tag == FormatTag.Pcm)
            {
                if (bitsPerSample == 8)
                {
                    Format = new Ibasa.SharpAL.Formats.Pcm8(channels);
                }
                else if (bitsPerSample == 16)
                {
                    Format = new Ibasa.SharpAL.Formats.Pcm16(channels);
                }
                else
                {
                    throw new NotSupportedException(string.Format("PCM {0} bit data is not supported.", bitsPerSample));
                }
            }
            else
            {
                throw new NotSupportedException(string.Format("{0} is not supported.", tag));
            }
        }