Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public static GenericChunk Import(Stream stream)
        {
            GenericChunk chunk = new GenericChunk();

            chunk.Size       = stream.ReadInt();
            stream.Position += chunk.Size;
            return(chunk);
        }