private void Decode() { _InputBuffer = SourceFile.GetData(); Init(); var fileHeaderSize = ReadInt16(0x0E); ReadScdHeader(fileHeaderSize); var entryHeaders = new ScdEntryHeader[ScdHeader.EntryCount]; var entryChunkOffsets = new int[ScdHeader.EntryCount]; var entryDataOffsets = new int[ScdHeader.EntryCount]; for (var i = 0; i < ScdHeader.EntryCount; ++i) { var headerOffset = ReadInt32(ScdHeader.EntryTableOffset + 4 * i); entryHeaders[i] = ReadEntryHeader(headerOffset); entryChunkOffsets[i] = headerOffset + System.Runtime.InteropServices.Marshal.SizeOf <ScdEntryHeader>(); entryDataOffsets[i] = entryChunkOffsets[i]; for (var j = 0; j < entryHeaders[i].AuxChunkCount; ++j) { entryDataOffsets[i] += ReadInt32(entryDataOffsets[i] + 4); } } this.Entries = new ScdEntry[ScdHeader.EntryCount]; for (var i = 0; i < ScdHeader.EntryCount; ++i) { this.Entries[i] = CreateEntry(entryHeaders[i], entryChunkOffsets[i], entryDataOffsets[i]); } _InputBuffer = null; }
private ScdEntryHeader ReadEntryHeader(int offset) { var h = new ScdEntryHeader(); h.DataSize = ReadInt32(offset + 0x00); h.ChannelCount = ReadInt32(offset + 0x04); h.Frequency = ReadInt32(offset + 0x08); h.Codec = (ScdCodec)ReadInt32(offset + 0x0C); h.LoopStartSample = ReadInt32(offset + 0x10); h.LoopEndSample = ReadInt32(offset + 0x14); h.SamplesOffset = ReadInt32(offset + 0x18); h.AuxChunkCount = ReadInt16(offset + 0x1C); h.Unknown1 = ReadInt16(offset + 0x1E); return(h); }
private ScdEntry CreateEntry(ScdEntryHeader header, int chunksOffset, int dataOffset) { if (header.DataSize == 0 || header.Codec == ScdCodec.None) { return(null); } switch (header.Codec) { case ScdCodec.OGG: return(new ScdOggEntry(this, header, dataOffset)); case ScdCodec.MSADPCM: return(new ScdAdpcmEntry(this, header, chunksOffset, dataOffset)); default: throw new NotSupportedException(); } }
internal ScdAdpcmEntry(ScdFile file, ScdEntryHeader header, int chunksOffset, int dataOffset) : base(file, header) { Decode(chunksOffset, dataOffset); }
protected ScdEntry(ScdFile file, ScdEntryHeader header) { this.File = file; this.Header = header; }
internal ScdOggEntry(ScdFile file, ScdEntryHeader header, int dataOffset) : base(file, header) { Decode(dataOffset); }
private ScdEntryHeader ReadEntryHeader(int offset) { var h = new ScdEntryHeader(); h.DataSize = ReadInt32(offset + 0x00); h.ChannelCount = ReadInt32(offset + 0x04); h.Frequency = ReadInt32(offset + 0x08); h.Codec = (ScdCodec)ReadInt32(offset + 0x0C); h.LoopStartSample = ReadInt32(offset + 0x10); h.LoopEndSample = ReadInt32(offset + 0x14); h.SamplesOffset = ReadInt32(offset + 0x18); h.AuxChunkCount = ReadInt16(offset + 0x1C); h.Unknown1 = ReadInt16(offset + 0x1E); return h; }
private void Decode() { _InputBuffer = SourceFile.GetData(); Init(); var fileHeaderSize = ReadInt16(0x0E); ReadScdHeader(fileHeaderSize); var entryHeaders = new ScdEntryHeader[ScdHeader.EntryCount]; var entryChunkOffsets = new int[ScdHeader.EntryCount]; var entryDataOffsets = new int[ScdHeader.EntryCount]; for (var i = 0; i < ScdHeader.EntryCount; ++i) { var headerOffset = ReadInt32(ScdHeader.EntryTableOffset + 4 * i); entryHeaders[i] = ReadEntryHeader(headerOffset); entryChunkOffsets[i] = headerOffset + System.Runtime.InteropServices.Marshal.SizeOf<ScdEntryHeader>(); entryDataOffsets[i] = entryChunkOffsets[i]; for (var j = 0; j < entryHeaders[i].AuxChunkCount; ++j) entryDataOffsets[i] += ReadInt32(entryDataOffsets[i] + 4); } this.Entries = new ScdEntry[ScdHeader.EntryCount]; for (var i = 0; i < ScdHeader.EntryCount; ++i) this.Entries[i] = CreateEntry(entryHeaders[i], entryChunkOffsets[i], entryDataOffsets[i]); _InputBuffer = null; }
private ScdEntry CreateEntry(ScdEntryHeader header, int chunksOffset, int dataOffset) { if (header.DataSize == 0 || header.Codec == ScdCodec.None) return null; switch (header.Codec) { case ScdCodec.OGG: return new ScdOggEntry(this, header, dataOffset); case ScdCodec.MSADPCM: return new ScdAdpcmEntry(this, header, chunksOffset, dataOffset); default: throw new NotSupportedException(); } }