From 288b6454eeeb0cbd813ad75a94a6efdc112d6be9 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 23 Sep 2025 17:55:46 +0200 Subject: [PATCH] AdLib Gold: Correctly use separate pseudo-stereo X and Y for the two sources. --- src/include/86box/filters.h | 18 +++++++++--------- src/sound/snd_adlibgold.c | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/include/86box/filters.h b/src/include/86box/filters.h index d11e79512..3e20fa653 100644 --- a/src/include/86box/filters.h +++ b/src/include/86box/filters.h @@ -75,7 +75,7 @@ adgold_lowpass_iir(int c, int i, float NewSample) /* fc=56Hz */ static inline float -adgold_pseudo_stereo_iir(float NewSample) +adgold_pseudo_stereo_iir(int i, float NewSample) { float ACoef[NCoef + 1] = { 0.00001409030866231767, @@ -89,23 +89,23 @@ adgold_pseudo_stereo_iir(float NewSample) 0.98738361004063568000 }; - static float y[NCoef + 1]; /* output samples */ - static float x[NCoef + 1]; /* input samples */ + static float y[2][NCoef + 1]; /* output samples */ + static float x[2][NCoef + 1]; /* input samples */ int n; /* shift the old samples */ for (n = NCoef; n > 0; n--) { - x[n] = x[n - 1]; - y[n] = y[n - 1]; + x[i][n] = x[i][n - 1]; + y[i][n] = y[i][n - 1]; } /* Calculate the new output */ - x[0] = NewSample; - y[0] = ACoef[0] * x[0]; + x[i][0] = NewSample; + y[i][0] = ACoef[0] * x[i][0]; for (n = 1; n <= NCoef; n++) - y[0] += ACoef[n] * x[n] - BCoef[n] * y[n]; + y[i][0] += ACoef[n] * x[i][n] - BCoef[n] * y[i][n]; - return y[0]; + return y[i][0]; } /* fc=3.2kHz - probably incorrect */ diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 360da3fec..3be304cd7 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -82,7 +82,7 @@ typedef struct adgold_t { int treble; int bass; - int16_t opl_buffer[SOUNDBUFLEN * 2]; + int16_t opl_buffer[MUSICBUFLEN * 2]; int16_t mma_buffer[2][SOUNDBUFLEN]; int pos; @@ -829,7 +829,7 @@ adgold_get_buffer(int32_t *buffer, int len, void *priv) /*Filter left channel, leave right channel unchanged*/ /*Filter cutoff is largely a guess*/ for (c = 0; c < len * 2; c += 2) - adgold_buffer[c] += adgold_pseudo_stereo_iir(adgold_buffer[c]); + adgold_buffer[c] += adgold_pseudo_stereo_iir(0, adgold_buffer[c]); break; case 0x18: /*Spatial stereo*/ /*Quite probably wrong, I only have the diagram in the TDA8425 datasheet @@ -944,7 +944,7 @@ adgold_get_music_buffer(int32_t *buffer, int len, void *priv) /*Filter left channel, leave right channel unchanged*/ /*Filter cutoff is largely a guess*/ for (c = 0; c < len * 2; c += 2) - adgold_buffer[c] += adgold_pseudo_stereo_iir(adgold_buffer[c]); + adgold_buffer[c] += adgold_pseudo_stereo_iir(1, adgold_buffer[c]); break; case 0x18: /*Spatial stereo*/ /*Quite probably wrong, I only have the diagram in the TDA8425 datasheet