| 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 | { |
no test coverage detected