x1_010: Clamp output samples to within range

This commit is contained in:
AJR 2021-02-25 14:11:38 -05:00
parent 99cbd58562
commit f2511bcb67

View File

@ -215,13 +215,13 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s
// if (m_sound_enable == 0) return;
auto &bufL = outputs[0];
auto &bufR = outputs[1];
for (int ch = 0; ch < NUM_CHANNELS; ch++)
{
X1_010_CHANNEL *reg = (X1_010_CHANNEL *)&(m_reg[ch*sizeof(X1_010_CHANNEL)]);
if ((reg->status & 1) != 0) // Key On
{
auto &bufL = outputs[0];
auto &bufR = outputs[1];
const int div = (reg->status & 0x80) ? 1 : 0;
if ((reg->status & 2) == 0) // PCM sampling
{
@ -295,4 +295,10 @@ void x1_010_device::sound_stream_update(sound_stream &stream, std::vector<read_s
}
}
}
for (int i = 0; i < bufL.samples(); i++)
{
bufL.put(i, std::clamp(bufL.getraw(i), -1.0f, 1.0f));
bufR.put(i, std::clamp(bufR.getraw(i), -1.0f, 1.0f));
}
}