| 989 | } |
| 990 | |
| 991 | void 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 | |
| 1019 | void CFamiTrackerDocIO::SaveDSamples(const CFamiTrackerModule &modfile, int ver) { |
| 1020 | const auto &manager = *modfile.GetInstrumentManager()->GetDSampleManager(); |
nothing calls this directly
no test coverage detected