diff --git a/src/libs/ngs2.cpp b/src/libs/ngs2.cpp index eb09457d7..efa26fe1e 100644 --- a/src/libs/ngs2.cpp +++ b/src/libs/ngs2.cpp @@ -713,10 +713,11 @@ struct Ngs2VoiceInternal { if (count > capacity) { return NGS2_ERROR_INVALID_NUM_WAVEFORM_BLOCKS; } - EXIT_NOT_IMPLEMENTED(!accepts_blocks || (flags & ~0x17u) != 0); const bool clear = (flags & 4u) != 0; const bool only_data = (flags & 2u) != 0; const bool join = only_data && (flags & 0x10u) == 0; + // CLEAR reopens a list that the previous addition closed. + EXIT_NOT_IMPLEMENTED((!accepts_blocks && !clear) || (flags & ~0x17u) != 0); const auto retained = clear ? 0 : blocks.size(); Block tail = retained == 0 ? Block {} : blocks.back(); std::vector pending; diff --git a/tests/Ngs2SamplerTests.cpp b/tests/Ngs2SamplerTests.cpp index de0dec4ff..8c86034f2 100644 --- a/tests/Ngs2SamplerTests.cpp +++ b/tests/Ngs2SamplerTests.cpp @@ -1210,6 +1210,15 @@ void TestDeferredSamplerSetup() { "sampler did not play after deferred stream setup"); } +void TestClearReopensClosedList() { + Fixture f(48000); + const int16_t first = 8192, second = -16384; + f.Queue(&first, 1, 0); + f.Queue(&second, 1, 4); + f.Render(1); + Check(f.voice.samples[0] == -0.5f, "CLEAR did not reopen a closed waveform list"); +} + void TestSetupQuery() { Fixture f(48000, 2); uint32_t info[2] = {99, 99}; @@ -1965,6 +1974,7 @@ int main() { TestDefaultMatrix(); TestMatrixOutputChannels(); TestCustomPcmStillPlays(); + TestClearReopensClosedList(); TestSetupQuery(); TestPortInfo(); TestPlayStateBeforeRender();