test(ngs2): cover append boundaries and missing waveform metadata

This commit is contained in:
TibixDev 2026-10-08 09:44:32 +03:00 committed by Adrià Franch
parent 4a04a78bfc
commit 2d1031b7b9
1 changed files with 37 additions and 0 deletions

View File

@ -446,6 +446,41 @@ static void TestStarvationAndTruncation(const std::vector<float>& reference) {
}
}
static void TestAppendBoundaries(const std::vector<float>& reference) {
for (std::uint32_t split = 1; split < SuperframeBytes; ++split) {
const auto system = CreateSystem();
const auto voice = EmptySampler(system);
Queue(voice, Superframe, split, SCE_NGS2_WAVEFORM_BLOCKS_FLAG_CONTINUE, 500, 100);
for (float value : Render(system, Grain)) Require(value == 0.0f);
const Ngs2WaveformBlock block{split, SuperframeBytes - split, UINT32_MAX, UINT32_MAX, UINT32_MAX, 0, 0};
Control(voice, SCE_NGS2_SAMPLER_VOICE_PARAM_ADD_WAVEFORM_BLOCKS,
Ngs2SamplerVoiceWaveformBlocksParam{{}, Superframe, SCE_NGS2_WAVEFORM_BLOCKS_FLAG_APPEND, 1, &block});
const auto output = Render(system, 512);
for (std::size_t i = 0; i < output.size(); ++i) Require(output[i] == (i < 500 ? reference[100 + i] : 0.0f));
Ngs2SamplerVoiceState state{};
Require(sceNgs2VoiceGetState(voice, &state.voice_state, sizeof(state)) == SCE_NGS2_OK);
Require(state.num_decoded_samples == 500 && state.decoded_data_size == SuperframeBytes);
Require(state.waveform_data == Superframe + SuperframeBytes && Flags(voice) == 0);
Require(sceNgs2SystemDestroy(system, nullptr) == SCE_NGS2_OK);
}
}
static void TestAppendWithoutWaveform() {
const auto system = CreateSystem();
const auto voice = EmptySampler(system);
bool rejected = false;
try {
Queue(voice, Superframe, SuperframeBytes, SCE_NGS2_WAVEFORM_BLOCKS_FLAG_APPEND, 500);
} catch (const std::invalid_argument&) {
rejected = true;
}
Require(rejected);
Queue(voice, Superframe, SuperframeBytes, 0, 500);
Render(system, 512);
Require(Flags(voice) == 0);
Require(sceNgs2SystemDestroy(system, nullptr) == SCE_NGS2_OK);
}
int main() {
const auto reference = Reference();
TestSkipAndBlockEnd(reference);
@ -458,5 +493,7 @@ int main() {
TestStreamPartitions();
TestRefill(reference);
TestStarvationAndTruncation(reference);
TestAppendBoundaries(reference);
TestAppendWithoutWaveform();
return 0;
}