virtual public MMChunk CreateSubChunk(FourCC fourCC, Stream st) { if ( fourCC == FourCC.Riff ) { MMChunk ck = new RiffChunk(st); m_chunkList.Add(ck); return ck; } else if ( fourCC == FourCC.Wave ) { MMChunk ck = new WaveChunk(st); m_chunkList.Add(ck); return ck; } else if ( fourCC == FourCC.Fmt ) { MMChunk ck = new FmtChunk(st, null); m_chunkList.Add(ck); return ck; } else if ( fourCC == FourCC.Data ) { MMChunk ck = new DataChunk(st); m_chunkList.Add(ck); return ck; } return null; }
static public MMChunk FromStream(Stream st) { if ( !st.CanRead ) return null; if ( st.Position > st.Length - 4 ) return null; byte[] data = new byte[4]; st.Read(data, 0, 4); FourCC fourCC = BitConverter.ToInt32(data, 0); if ( fourCC == FourCC.Riff ) { RiffChunk ck = new RiffChunk(st); ck.LoadFromStream(st); return ck; } else if ( fourCC == FourCC.Wave ) { WaveChunk ck = new WaveChunk(st); ck.LoadFromStream(st); return ck; } else if ( fourCC == FourCC.Fmt ) { FmtChunk ck = new FmtChunk(st, null); ck.LoadFromStream(st); return ck; } else if ( fourCC == FourCC.Data ) { DataChunk ck = new DataChunk(st); ck.LoadFromStream(st); return ck; } else return new MMChunk(fourCC, st); }