diff options
author | JP Cimalando <jpcima@users.noreply.github.com> | 2018-06-03 22:29:19 +0200 |
---|---|---|
committer | JP Cimalando <jpcima@users.noreply.github.com> | 2018-06-03 22:29:19 +0200 |
commit | 32d4a6d002297f6978b6e76907a279c5f8c203fe (patch) | |
tree | b01e30c217ed037d893097495786b1c9f0032e77 /src | |
parent | e3cad2f46925ac0b9ae303bea68a5fe508e78bc9 (diff) | |
download | libADLMIDI-32d4a6d002297f6978b6e76907a279c5f8c203fe.tar.gz libADLMIDI-32d4a6d002297f6978b6e76907a279c5f8c203fe.tar.bz2 libADLMIDI-32d4a6d002297f6978b6e76907a279c5f8c203fe.zip |
clamp the outputs of 16bit adding generators
Diffstat (limited to 'src')
-rw-r--r-- | src/chips/nuked_opl3.cpp | 12 | ||||
-rw-r--r-- | src/chips/nuked_opl3_v174.cpp | 12 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/chips/nuked_opl3.cpp b/src/chips/nuked_opl3.cpp index fc6363d..6490f7f 100644 --- a/src/chips/nuked_opl3.cpp +++ b/src/chips/nuked_opl3.cpp @@ -73,10 +73,14 @@ int NukedOPL3::generateAndMix(int16_t *output, size_t frames) #if defined(ADLMIDI_ENABLE_HQ_RESAMPLER) for(size_t i = 0; i < frames; ++i) { - int16_t frame[2]; - generateResampledHq(frame); - output[0] += (int32_t)frame[0]; - output[1] += (int32_t)frame[1]; + int32_t frame[2]; + generateResampledHq32(frame); + for (unsigned c = 0; c < 2; ++c) { + int32_t temp = (int32_t)output[c] + frame[c]; + temp = (temp > -32768) ? temp : -32768; + temp = (temp < 32767) ? temp : 32767; + output[c] = temp; + } output += 2; } #else diff --git a/src/chips/nuked_opl3_v174.cpp b/src/chips/nuked_opl3_v174.cpp index 675e104..d8e8ef8 100644 --- a/src/chips/nuked_opl3_v174.cpp +++ b/src/chips/nuked_opl3_v174.cpp @@ -73,10 +73,14 @@ int NukedOPL3v174::generateAndMix(int16_t *output, size_t frames) #if defined(ADLMIDI_ENABLE_HQ_RESAMPLER) for(size_t i = 0; i < frames; ++i) { - int16_t frame[2]; - generateResampledHq(frame); - output[0] += (int32_t)frame[0]; - output[1] += (int32_t)frame[1]; + int32_t frame[2]; + generateResampledHq32(frame); + for (unsigned c = 0; c < 2; ++c) { + int32_t temp = (int32_t)output[c] + frame[c]; + temp = (temp > -32768) ? temp : -32768; + temp = (temp < 32767) ? temp : 32767; + output[c] = temp; + } output += 2; } #else |