From 312ecbccdee2b2fa6aee4b6c951fc8053a02f4c7 Mon Sep 17 00:00:00 2001 From: goeiecool9999 <7033575+goeiecool9999@users.noreply.github.com> Date: Sun, 17 Dec 2023 04:24:11 +0100 Subject: [PATCH] attempt to implement looping --- src/util/bootSound/BootSoundReader.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/util/bootSound/BootSoundReader.cpp b/src/util/bootSound/BootSoundReader.cpp index 4a7c7400..60a719ba 100644 --- a/src/util/bootSound/BootSoundReader.cpp +++ b/src/util/bootSound/BootSoundReader.cpp @@ -14,14 +14,18 @@ BootSoundReader::BootSoundReader(FSCVirtualFile* bootsndFile, sint32 blockSize) sint16* BootSoundReader::getSamples() { - auto read = fsc_readFile(bootsndFile, bufferBE.data(), blockSize); - if(read % sizeof(sint16be) != 0) - cemu_assert_suspicious(); + size_t totalRead = 0; + while(totalRead < blockSize) + { + auto read = fsc_readFile(bootsndFile, bufferBE.data(), blockSize - totalRead); + if (read % sizeof(sint16be) != 0) + cemu_assert_suspicious(); - auto readValues = read / sizeof(sint16be); - if (readValues < blockSize) - std::fill(buffer.begin() + readValues, buffer.end(), 0); + std::copy_n(bufferBE.begin(), read / sizeof(sint16be), buffer.begin() + totalRead); + totalRead += read; + if (totalRead < blockSize) + fsc_setFileSeek(bootsndFile, loopPoint * 4); + } - std::copy_n(bufferBE.begin(), read / sizeof(sint16be), buffer.begin()); return buffer.data(); }