MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / LoadDSamples

Method LoadDSamples

Source/FamiTrackerDocIO.cpp:991–1017  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

989}
990
991void CFamiTrackerDocIO::LoadDSamples(CFamiTrackerModule &modfile, int ver) {
992 unsigned int Count = AssertRange(
993 static_cast<unsigned char>(file_.GetBlockChar()), 0U, CDSampleManager::MAX_DSAMPLES, "DPCM sample count");
994
995 auto &manager = *modfile.GetInstrumentManager()->GetDSampleManager();
996
997 for (unsigned int i = 0; i < Count; ++i) {
998 unsigned int Index = AssertRange(
999 static_cast<unsigned char>(file_.GetBlockChar()), 0U, CDSampleManager::MAX_DSAMPLES - 1, "DPCM sample index");
1000 try {
1001 unsigned int Len = AssertRange(file_.GetBlockInt(), 0, (int)ft0cc::doc::dpcm_sample::max_name_length, "DPCM sample name length");
1002 char Name[ft0cc::doc::dpcm_sample::max_name_length + 1] = { };
1003 file_.GetBlock(Name, Len);
1004 int Size = AssertRange(file_.GetBlockInt(), 0, 0x7FFF, "DPCM sample size");
1005 AssertFileData<MODULE_ERROR_STRICT>(Size <= 0xFF1 && Size % 0x10 == 1, "Bad DPCM sample size");
1006 int TrueSize = Size + ((1 - Size) & 0x0F); // // //
1007 std::vector<uint8_t> samples(TrueSize);
1008 file_.GetBlock(samples.data(), Size);
1009
1010 manager.SetDSample(Index, std::make_unique<ft0cc::doc::dpcm_sample>(samples, Name)); // // //
1011 }
1012 catch (CModuleException &e) {
1013 e.AppendError("At DPCM sample " + conv::from_int(Index) + ',');
1014 throw e;
1015 }
1016 }
1017}
1018
1019void CFamiTrackerDocIO::SaveDSamples(const CFamiTrackerModule &modfile, int ver) {
1020 const auto &manager = *modfile.GetInstrumentManager()->GetDSampleManager();

Callers

nothing calls this directly

Calls 9

from_intFunction · 0.85
GetBlockCharMethod · 0.80
GetBlockIntMethod · 0.80
AppendErrorMethod · 0.80
GetDSampleManagerMethod · 0.45
GetInstrumentManagerMethod · 0.45
GetBlockMethod · 0.45
dataMethod · 0.45
SetDSampleMethod · 0.45

Tested by

no test coverage detected