attempt to implement looping

This commit is contained in:
goeiecool9999 2023-12-17 04:24:11 +01:00
parent 9354db6a16
commit 312ecbccde

View File

@ -14,14 +14,18 @@ BootSoundReader::BootSoundReader(FSCVirtualFile* bootsndFile, sint32 blockSize)
sint16* BootSoundReader::getSamples() sint16* BootSoundReader::getSamples()
{ {
auto read = fsc_readFile(bootsndFile, bufferBE.data(), blockSize); size_t totalRead = 0;
if(read % sizeof(sint16be) != 0) while(totalRead < blockSize)
cemu_assert_suspicious(); {
auto read = fsc_readFile(bootsndFile, bufferBE.data(), blockSize - totalRead);
if (read % sizeof(sint16be) != 0)
cemu_assert_suspicious();
auto readValues = read / sizeof(sint16be); std::copy_n(bufferBE.begin(), read / sizeof(sint16be), buffer.begin() + totalRead);
if (readValues < blockSize) totalRead += read;
std::fill(buffer.begin() + readValues, buffer.end(), 0); if (totalRead < blockSize)
fsc_setFileSeek(bootsndFile, loopPoint * 4);
}
std::copy_n(bufferBE.begin(), read / sizeof(sint16be), buffer.begin());
return buffer.data(); return buffer.data();
} }