Beispiel #1
0
 protected virtual bool InitializeForWriting(Stream underlyingStream, WaveFormat2 wfIn, WaveFormat2 wfOut, bool fAppend)
 {
     if (fAppend)
     {
         long position = underlyingStream.Position;
         underlyingStream.Seek(0, SeekOrigin.Begin);
         LoadHeader();
         _ckData.BeginWrite();
         _ckData.Seek(position - _ckData.DataStart, SeekOrigin.Begin);
     }
     else
     {
         _baseStream.Position = 0;
         _mmc = new RiffChunk(underlyingStream);
         (_mmc as RiffChunk).BeginWrite();
         _ckFmt = new FmtChunk(underlyingStream, wfOut);
         _mmc.AppendChunk(_ckFmt);
         _ckFmt.BeginWrite();
         _ckFmt.Write(_ckFmt.WaveFormat.GetBytes());
         _fmt    = wfOut;
         _ckData = new DataChunk(underlyingStream);
         _mmc.AppendChunk(_ckData);
         _ckData.BeginWrite();
     }
     return(true);
 }
Beispiel #2
0
        public override MMChunk CreateSubChunk(FourCC fourCC, Stream st)
        {
            MMChunk ck   = base.CreateSubChunk(fourCC, st);
            long    size = 0;

            foreach (MMChunk cck in m_chunkList)
            {
                if (cck != ck)
                {
                    size += cck.Size;
                }
            }
            ck.Start = m_posStart + 4 + size;
            return(ck);
        }
Beispiel #3
0
 protected virtual void LoadHeader()
 {
     _mmc   = MMChunk.FromStream(_baseStream);
     _ckFmt = _mmc.FindChunk(FourCC.Fmt) as FmtChunk;
     if (_ckFmt != null)
     {
         _fmt = _ckFmt.WaveFormat;
     }
     _ckData = _mmc.FindChunk(FourCC.Data) as DataChunk;
     if (_ckData != null)
     {
         _posData = _ckData.DataStart;
     }
     _baseStream.Seek(_posData, SeekOrigin.Begin);
 }
Beispiel #4
0
        public override void LoadFromStream(Stream st)
        {
            byte[] data = new byte[4];
            m_posStart = st.Position - 4;
            st.Read(data, 0, 4);
            m_nSize = BitConverter.ToInt32(data, 0);

            st.Read(data, 0, 4);
            if (Encoding.ASCII.GetString(data, 0, 4) != "WAVE")
            {
                throw new InvalidOperationException("Must have WAVE format");
            }

            while (st.Position - m_posStart != m_nSize + 8)
            {
                MMChunk ck = MMChunk.FromStream(st);
                if (ck == null)
                {
                    break;
                }
                m_chunkList.Add(ck);
            }
        }
Beispiel #5
0
 public virtual void AppendChunk(MMChunk ck)
 {
     ck.m_fourCC.Write(_stm);
     m_chunkList.Add(ck);
 }