MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / loadSoundsFromCSS

Function loadSoundsFromCSS

src/OpenLoco/src/Audio/Audio.cpp:55–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 }
54
55 static std::vector<BufferId> loadSoundsFromCSS(const fs::path& path)
56 {
57 Logging::verbose("loadSoundsFromCSS({})", path.string());
58
59 try
60 {
61 std::vector<BufferId> results;
62
63 FileStream fs(path, StreamMode::read);
64 auto numSounds = fs.readValue<uint32_t>();
65
66 std::vector<uint32_t> soundOffsets(numSounds, 0);
67 fs.read(soundOffsets.data(), numSounds * sizeof(uint32_t));
68
69 std::vector<std::byte> pcm;
70 for (uint32_t i = 0; i < numSounds; i++)
71 {
72 fs.setPosition(soundOffsets[i]);
73
74 auto pcmLen = fs.readValue<uint32_t>();
75 auto format = fs.readValue<WAVEFORMATEX>();
76
77 pcm.resize(pcmLen);
78 fs.read(pcm.data(), pcmLen);
79
80 results.push_back(loadSoundFromWaveMemory(format, pcm.data(), pcmLen));
81 }
82
83 return results;
84 }
85 catch (const std::exception& ex)
86 {
87 Logging::error("loadSoundsFromCSS({}) failed: {}", path.string(), ex.what());
88 return {};
89 }
90 }
91
92 std::optional<BufferId> loadMusicSample(PathId asset)
93 {

Callers 1

initialiseDSoundFunction · 0.85

Calls 9

verboseFunction · 0.85
loadSoundFromWaveMemoryFunction · 0.85
errorFunction · 0.85
push_backMethod · 0.80
whatMethod · 0.80
readMethod · 0.45
dataMethod · 0.45
setPositionMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected