bool TriAcePS1Seq::GetTrackPointers(void) { VGMHeader *TrkInfoHeader = header->AddHeader(dwOffset + 0x16, 6 * 32, L"Track Info Blocks"); GetBytes(dwOffset + 0x16, 6 * 32, &TrkInfos); for (int i = 0; i < 32; i++) if (TrkInfos[i].trkOffset != 0) { aTracks.push_back(new TriAcePS1Track(this, TrkInfos[i].trkOffset, 0)); VGMHeader *TrkInfoBlock = TrkInfoHeader->AddHeader(dwOffset + 0x16 + 6 * i, 6, L"Track Info"); } return true; }
bool NDSInstrSet::GetInstrPointers() { VGMHeader* header = AddHeader(dwOffset, 0x38); uint32_t nInstruments = GetWord(dwOffset + 0x38); VGMHeader* instrptrHdr = AddHeader(dwOffset+0x38, nInstruments*4+4, L"Instrument Pointers"); for (uint32_t i=0; i<nInstruments; i++) { uint32_t instrPtrOff = dwOffset + 0x3C + i*4; uint32_t temp = GetWord(instrPtrOff); if (temp == 0) continue; uint8_t instrType = temp & 0xFF; uint32_t pInstr = temp >> 8; aInstrs.push_back(new NDSInstr(this, pInstr+dwOffset, 0, 0, i, instrType)); VGMHeader* hdr = instrptrHdr->AddHeader(instrPtrOff, 4, L"Pointer"); hdr->AddSimpleItem(instrPtrOff, 1, L"Type"); hdr->AddSimpleItem(instrPtrOff+1, 3, L"Offset"); } return true; }
bool CompileSnesSeq::GetHeaderInfo(void) { SetPPQN(SEQ_PPQN); VGMHeader* header = AddHeader(dwOffset, 0); header->AddSimpleItem(dwOffset, 1, L"Number of Tracks"); nNumTracks = GetByte(dwOffset); if (nNumTracks == 0 || nNumTracks > 8) { return false; } uint32_t curOffset = dwOffset + 1; for (uint8_t trackIndex = 0; trackIndex < nNumTracks; trackIndex++) { std::wstringstream trackName; trackName << L"Track " << (trackIndex + 1); VGMHeader* trackHeader = header->AddHeader(curOffset, 14, trackName.str().c_str()); trackHeader->AddSimpleItem(curOffset, 1, L"Channel"); trackHeader->AddSimpleItem(curOffset + 1, 1, L"Flags"); trackHeader->AddSimpleItem(curOffset + 2, 1, L"Volume"); trackHeader->AddSimpleItem(curOffset + 3, 1, L"Volume Envelope"); trackHeader->AddSimpleItem(curOffset + 4, 1, L"Vibrato"); trackHeader->AddSimpleItem(curOffset + 5, 1, L"Transpose"); trackHeader->AddTempo(curOffset + 6, 1); trackHeader->AddSimpleItem(curOffset + 7, 1, L"Branch ID (Channel #)"); trackHeader->AddSimpleItem(curOffset + 8, 2, L"Score Pointer"); trackHeader->AddSimpleItem(curOffset + 10, 1, L"SRCN"); trackHeader->AddSimpleItem(curOffset + 11, 1, L"ADSR"); trackHeader->AddSimpleItem(curOffset + 12, 1, L"Pan"); trackHeader->AddSimpleItem(curOffset + 13, 1, L"Reserved"); curOffset += 14; } return true; //successful }
bool Vab::GetInstrPointers() { uint32_t nEndOffset = GetEndOffset(); uint32_t nMaxLength = nEndOffset - dwOffset; uint32_t offProgs = dwOffset + 0x20; uint32_t offToneAttrs = offProgs + (16 * 128); uint16_t numPrograms = GetShort(dwOffset + 0x12); uint16_t numVAGs = GetShort(dwOffset + 0x16); uint32_t offVAGOffsets = offToneAttrs + (32 * 16 * numPrograms); VGMHeader* progsHdr = AddHeader(offProgs, 16 * 128, L"Program Table"); VGMHeader* toneAttrsHdr = AddHeader(offToneAttrs, 32 * 16, L"Tone Attributes Table"); if (numPrograms > 128) { return false; } if (numVAGs > 255) { return false; } // Scan all 128 entries regardless of header info. // There could be null instruments that has no tones. // See Clock Tower PSF for example of null instrument. for (uint32_t i = 0; i < 128; i++) { uint32_t offCurrProg = offProgs + (i * 16); uint32_t offCurrToneAttrs = offToneAttrs + (aInstrs.size() * 32 * 16); if (offCurrToneAttrs + (32 * 16) > nEndOffset) { break; } uint8_t numTones = GetByte(offCurrProg); if (numTones > 32) { wchar_t log[512]; wsprintf(log, L"Too many tones (%u) in Program #%u.", numTones, i); pRoot->AddLogItem(new LogItem(log, LOG_LEVEL_WARN, L"Vab")); } else if (numTones != 0) { VabInstr* newInstr = new VabInstr(this, offCurrToneAttrs, 0x20 * 16, 0, i); aInstrs.push_back(newInstr); GetBytes(offCurrProg, 0x10, &newInstr->attr); VGMHeader* hdr = progsHdr->AddHeader(offCurrProg, 0x10, L"Program"); hdr->AddSimpleItem(offCurrProg + 0x00, 1, L"Number of Tones"); hdr->AddSimpleItem(offCurrProg + 0x01, 1, L"Volume"); hdr->AddSimpleItem(offCurrProg + 0x02, 1, L"Priority"); hdr->AddSimpleItem(offCurrProg + 0x03, 1, L"Mode"); hdr->AddSimpleItem(offCurrProg + 0x04, 1, L"Pan"); hdr->AddSimpleItem(offCurrProg + 0x05, 1, L"Reserved"); hdr->AddSimpleItem(offCurrProg + 0x06, 2, L"Attribute"); hdr->AddSimpleItem(offCurrProg + 0x08, 4, L"Reserved"); hdr->AddSimpleItem(offCurrProg + 0x0c, 4, L"Reserved"); newInstr->masterVol = GetByte(offCurrProg + 0x01); toneAttrsHdr->unLength = offCurrToneAttrs + (32 * 16) - offToneAttrs; } } if ((offVAGOffsets + 2 * 256) <= nEndOffset) { wchar_t name[256]; std::vector<SizeOffsetPair> vagLocations; uint32_t totalVAGSize = 0; VGMHeader* vagOffsetHdr = AddHeader(offVAGOffsets, 2 * 256, L"VAG Pointer Table"); uint32_t vagStartOffset = GetShort(offVAGOffsets) * 8; vagOffsetHdr->AddSimpleItem(offVAGOffsets, 2, L"VAG Size /8 #0"); totalVAGSize = vagStartOffset; for (uint32_t i = 0; i < numVAGs; i++) { uint32_t vagOffset; uint32_t vagSize; if (i == 0) { vagOffset = vagStartOffset; vagSize = GetShort(offVAGOffsets + (i + 1) * 2) * 8; } else { vagOffset = vagStartOffset + vagLocations[i - 1].offset + vagLocations[i - 1].size; vagSize = GetShort(offVAGOffsets + (i + 1) * 2) * 8; } wsprintf(name, L"VAG Size /8 #%u", i + 1); vagOffsetHdr->AddSimpleItem(offVAGOffsets + (i + 1) * 2, 2, name); if (vagOffset + vagSize <= nEndOffset) { vagLocations.push_back(SizeOffsetPair(vagOffset, vagSize)); totalVAGSize += vagSize; } else { wchar_t log[512]; wsprintf(log, L"VAG #%u pointer (offset=0x%08X, size=%u) is invalid.", i + 1, vagOffset, vagSize); pRoot->AddLogItem(new LogItem(log, LOG_LEVEL_WARN, L"Vab")); } } unLength = (offVAGOffsets + 2 * 256) - dwOffset; // single VAB file? uint32_t offVAGs = offVAGOffsets + 2 * 256; if (dwOffset == 0 && vagLocations.size() != 0) { // load samples as well PSXSampColl* newSampColl = new PSXSampColl(format, this, offVAGs, totalVAGSize, vagLocations); if (newSampColl->LoadVGMFile()) { pRoot->AddVGMFile(newSampColl); //this->sampColl = newSampColl; } else { delete newSampColl; } } } return true; }