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

Function LoadSampleFromFile

Source/InstrumentEditorDPCM.cpp:49–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47LPCWSTR NO_SAMPLE_STR = L"(no sample)";
48
49std::shared_ptr<ft0cc::doc::dpcm_sample> LoadSampleFromFile(CFile &file, std::string_view name) {
50 // Clip file if too large
51 std::size_t Size = std::min(static_cast<std::size_t>(file.GetLength()), ft0cc::doc::dpcm_sample::max_size);
52
53 // Make sure size is compatible with DPCM hardware
54 int NewSize = Size;
55 if ((Size & 0xF) != 1)
56 NewSize = Size + 0x10 - ((Size + 0x0F) & 0x0F);
57
58 std::vector<uint8_t> pBuf(NewSize, 0xAAu); // // //
59 file.Read(pBuf.data(), Size);
60
61 return std::make_shared<ft0cc::doc::dpcm_sample>(std::move(pBuf), name);
62}
63
64} // namespace
65

Callers 1

LoadSampleMethod · 0.85

Calls 3

GetLengthMethod · 0.45
ReadMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected