From 480311b03ec5e064ccf0d002b74ee3a232c8f4a1 Mon Sep 17 00:00:00 2001 From: Zachary Hall Date: Thu, 17 Oct 2024 10:28:22 -0700 Subject: [PATCH] Fix mixing --- backends/playback/zsm/zsm_backend.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backends/playback/zsm/zsm_backend.hpp b/backends/playback/zsm/zsm_backend.hpp index febcf23..c1c29b4 100644 --- a/backends/playback/zsm/zsm_backend.hpp +++ b/backends/playback/zsm/zsm_backend.hpp @@ -134,11 +134,11 @@ class ZsmBackend : public PlaybackBackend { ym_resample_len /= sizeof(int16_t); for (size_t i = 0; i < samples / 2; i++) { size_t j = i * 2; - int32_t psg[2] = {psg_ptr[j], psg_ptr[j + 1]}; - int32_t pcm[2] = {pcm_ptr[j], pcm_ptr[j + 1]}; - int32_t vera[2] = {psg[0] + pcm[0], psg[1] + pcm[1]}; - int32_t fm[2] = {ym_resample_ptr[j], ym_resample_ptr[j + 1]}; - int16_t mix[2] = {(vera[0] + fm[0]) / 3, (vera[1] + fm[1]) / 3}; + int16_t psg[2] = {psg_ptr[j] >> 1, psg_ptr[j + 1] >> 1}; + int16_t pcm[2] = {pcm_ptr[j] >> 1, pcm_ptr[j + 1] >> 1}; + int16_t vera[2] = {psg[0] + pcm[0], psg[1] + pcm[1]}; + int16_t fm[2] = {ym_resample_ptr[j], ym_resample_ptr[j + 1]}; + int16_t mix[2] = {vera[0] + (fm[0] >> 1), vera[1] + (fm[1] >> 1)}; out_ptr[j++] = mix[0]; out_ptr[j++] = mix[1]; }