Пример #1
0
        public static WaveFile Import(Stream stream)
        {
            WaveFile wav = new WaveFile();

            while (stream.Position < stream.Length)
            {
                byte[] id = new byte[4];
                stream.Read(id, 0, 4);
                string idn = Encoding.UTF8.GetString(id, 0, 4);
                switch (idn)
                {
                default:
                    GenericChunk.Import(stream);
                    break;

                case "RIFF":
                    wav.RiffHeader = RiffChunk.Import(stream);
                    break;

                case "fmt ":
                    wav.FmtHeader = FmtChunk.Import(stream);
                    break;

                case "data":
                    wav.DataChunk = WaveDataChunk.Import(stream);
                    break;
                }
            }

            return(wav);
        }
Пример #2
0
        public static new WaveDataChunk Import(Stream stream)
        {
            WaveDataChunk chunk = new WaveDataChunk();

            chunk.Size = stream.ReadInt();
            chunk.Data = new byte[chunk.Size];
            stream.Read(chunk.Data, 0, chunk.Size);
            return(chunk);
        }