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

Function getSoundBuffer

src/OpenLoco/src/Audio/Audio.cpp:515–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

513 }
514
515 std::optional<BufferId> getSoundBuffer(SoundId id)
516 {
517 if (isObjectSoundId(id))
518 {
519 auto sr = _objectSamples.find((uint16_t)id);
520 if (sr == _objectSamples.end())
521 {
522 auto obj = getSoundObject(id);
523 if (obj != nullptr)
524 {
525 const auto* data = obj->getData();
526 assert(data != nullptr);
527 assert(data->offset == 8);
528 _objectSamples[static_cast<size_t>(id)] = loadSoundFromWaveMemory(data->pcmHeader, data->pcm(), data->length);
529 return _objectSamples[static_cast<size_t>(id)];
530 }
531 }
532 else
533 {
534 return sr->second;
535 }
536 }
537 else if (static_cast<size_t>(id) < _samples.size())
538 {
539 return _samples[static_cast<size_t>(id)];
540 }
541 return std::nullopt;
542 }
543
544 AudioHandle play(SoundId id, ChannelId channel, const AudioAttributes& attribs)
545 {

Callers 3

playSoundFunction · 0.85
playFunction · 0.85
updateSingleVehicleSoundFunction · 0.85

Calls 8

isObjectSoundIdFunction · 0.85
getSoundObjectFunction · 0.85
loadSoundFromWaveMemoryFunction · 0.85
findMethod · 0.80
pcmMethod · 0.80
endMethod · 0.45
getDataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected