diff --git a/src/include/86box/snd_ad1848.h b/src/include/86box/snd_ad1848.h index 82a7721f3..b6782c139 100644 --- a/src/include/86box/snd_ad1848.h +++ b/src/include/86box/snd_ad1848.h @@ -15,7 +15,7 @@ typedef struct ad1848_t int16_t out_l, out_r; - uint32_t cd_vol_l, cd_vol_r; + double cd_vol_l, cd_vol_r; int enable; diff --git a/src/sound/snd_ad1848.c b/src/sound/snd_ad1848.c index 6f2656ff8..a4595595a 100644 --- a/src/sound/snd_ad1848.c +++ b/src/sound/snd_ad1848.c @@ -16,7 +16,7 @@ #define CS4231 0x80 static int ad1848_vols_6bits[64]; -static uint32_t ad1848_vols_5bits_aux_gain[32]; +static double ad1848_vols_5bits_aux_gain[32]; void ad1848_setirq(ad1848_t *ad1848, int irq) @@ -224,11 +224,11 @@ static void ad1848_poll(void *p) static void ad1848_filter_cd_audio(int channel, double *buffer, void *p) { ad1848_t *ad1848 = (ad1848_t *)p; - int32_t c; - uint32_t volume = channel ? ad1848->cd_vol_r : ad1848->cd_vol_l; + double c; + double volume = channel ? ad1848->cd_vol_r : ad1848->cd_vol_l; - c = (((int32_t) *buffer) * volume) >> 16; - *buffer = (double) c; + c = ((*buffer) * volume) / 65536.0; + *buffer = c; } void ad1848_init(ad1848_t *ad1848, int type) @@ -292,7 +292,7 @@ void ad1848_init(ad1848_t *ad1848, int type) attenuation = pow(10, attenuation / 10); - ad1848_vols_5bits_aux_gain[c] = (int)(attenuation * 65536); + ad1848_vols_5bits_aux_gain[c] = (attenuation * 65536); } ad1848->type = type;