private void Flush() { subchunks.Clear(); foreach (KeyValuePair <string, string> kvp in dictionary) { RiffSubchunk rs = new RiffSubchunk(); rs.tag = kvp.Key; rs.data = System.Text.Encoding.ASCII.GetBytes(kvp.Value); subchunks.Add(rs); } }
public RiffSubchunk_fmt(RiffSubchunk origin) { tag = "fmt "; BinaryReader br = new BinaryReader(new MemoryStream(origin.ReadAll())); format_tag = (FORMAT_TAG)br.ReadUInt16(); channels = br.ReadUInt16(); samplesPerSec = br.ReadUInt32(); avgBytesPerSec = br.ReadUInt32(); blockAlign = br.ReadUInt16(); bitsPerSample = br.ReadUInt16(); }
public RiffContainer_INFO(RiffContainer rc) { subchunks = rc.subchunks; type = "INFO"; foreach (RiffChunk chunk in subchunks) { RiffSubchunk rsc = chunk as RiffSubchunk; if (chunk == null) { throw new FormatException("Invalid subchunk of INFO list"); } dictionary[rsc.tag] = System.Text.Encoding.ASCII.GetString(rsc.ReadAll()); } }
/// <exception cref="FormatException"><paramref name="rc"/>.<see cref="RiffContainer.subchunks"/> contains a chunk that does not inherit <see cref="RiffSubchunk"/></exception> public RiffContainer_INFO(RiffContainer rc) { subchunks = rc.subchunks; type = "INFO"; foreach (RiffChunk chunk in subchunks) { RiffSubchunk rsc = chunk as RiffSubchunk; if (chunk == null) { throw new FormatException("Invalid subchunk of INFO list"); //TODO is this supposed to be a check on `rsc` (i.e. as a type check)? --yoshi } dictionary[rsc.tag] = System.Text.Encoding.ASCII.GetString(rsc.ReadAll()); } }
private void Flush() { subchunks.Clear(); foreach (KeyValuePair <string, string> kvp in dictionary) { RiffSubchunk rs = new RiffSubchunk { tag = kvp.Key, Source = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(kvp.Value)), Position = 0 }; rs.Length = (uint)rs.Source.Length; subchunks.Add(rs); } }
private void Flush() { subchunks.Clear(); foreach (var(subchunkTag, s) in dictionary) { RiffSubchunk rs = new RiffSubchunk { tag = subchunkTag, Source = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(s)), Position = 0 }; rs.Length = (uint)rs.Source.Length; subchunks.Add(rs); } }
private RiffChunk ReadChunk(BinaryReader br) { RiffChunk ret; string tag = ReadTag(br); readCounter += 4; uint size = br.ReadUInt32(); readCounter += 4; if (size > int.MaxValue) { throw new FormatException("chunk too big"); } if (tag == "RIFF" || tag == "LIST") { RiffContainer rc = new RiffContainer { tag = tag, type = ReadTag(br) }; readCounter += 4; long readEnd = readCounter - 4 + size; while (readEnd > readCounter) { rc.subchunks.Add(ReadChunk(br)); } ret = rc.Morph(); } else { RiffSubchunk rsc = new RiffSubchunk { tag = tag, Source = br.BaseStream, Position = br.BaseStream.Position, Length = size }; readCounter += size; br.BaseStream.Position += size; ret = rsc.Morph(); } if (size % 2 != 0) { br.ReadByte(); readCounter += 1; } return(ret); }
private RiffChunk ReadChunk(BinaryReader br) { RiffChunk ret; string tag = ReadTag(br); readCounter += 4; uint size = br.ReadUInt32(); readCounter += 4; if (size > int.MaxValue) { throw new FormatException("chunk too big"); } if (tag == "RIFF" || tag == "LIST") { RiffContainer rc = new RiffContainer(); rc.tag = tag; rc.type = ReadTag(br); readCounter += 4; long readEnd = readCounter - 4 + size; while (readEnd > readCounter) { rc.subchunks.Add(ReadChunk(br)); } ret = rc.Morph(); } else { RiffSubchunk rsc = new RiffSubchunk(); rsc.tag = tag; rsc.data = br.ReadBytes((int)size); readCounter += size; ret = rsc.Morph(); } if (size % 2 != 0) { br.ReadByte(); readCounter += 1; } return(ret); }
private RiffChunk ReadChunk(BinaryReader br) { RiffChunk ret; string tag = ReadTag(br); readCounter += 4; uint size = br.ReadUInt32(); readCounter += 4; if (size > int.MaxValue) throw new FormatException("chunk too big"); if (tag == "RIFF" || tag == "LIST") { RiffContainer rc = new RiffContainer { tag = tag, type = ReadTag(br) }; readCounter += 4; long readEnd = readCounter - 4 + size; while (readEnd > readCounter) rc.subchunks.Add(ReadChunk(br)); ret = rc.Morph(); } else { RiffSubchunk rsc = new RiffSubchunk { tag = tag, Source = br.BaseStream, Position = br.BaseStream.Position, Length = size }; readCounter += size; br.BaseStream.Position += size; ret = rsc.Morph(); } if (size % 2 != 0) { br.ReadByte(); readCounter += 1; } return ret; }
private void Flush() { subchunks.Clear(); foreach (KeyValuePair<string, string> kvp in dictionary) { RiffSubchunk rs = new RiffSubchunk { tag = kvp.Key, Source = new MemoryStream(System.Text.Encoding.ASCII.GetBytes(kvp.Value)), Position = 0 }; rs.Length = (uint)rs.Source.Length; subchunks.Add(rs); } }