From 0a8b93d58f1d3f5f15eb0a16c4fcc588e4dd97dd Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Thu, 20 Jan 2022 04:49:06 -0400 Subject: [PATCH 1/4] Fixed incorrect control chip ID of AdLib Gold --- src/sound/snd_adlibgold.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 5d435f61e..f3aeb35eb 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -498,9 +498,9 @@ uint8_t adgold_read(uint16_t addr, void *p) { case 0x00: /*Control/ID*/ if (adgold->surround_enabled) - temp = 0x50; /*16-bit ISA, surround module, no telephone/CDROM*/ + temp = 0x51; /*8-bit ISA, surround module, no telephone/CD-ROM*/ else - temp = 0x70; /*16-bit ISA, no telephone/surround/CD-ROM*/ + temp = 0x71; /*8-bit ISA, no telephone/surround/CD-ROM*/ break; default: From 415a98fa15e9497f557f49ff586adfc5f67660d1 Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Thu, 20 Jan 2022 13:12:28 -0400 Subject: [PATCH 2/4] Added auxillary registers (used for line in and CD audio) to AdLib Gold mixer --- src/sound/snd_adlibgold.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index f3aeb35eb..853e74f0e 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -60,6 +60,7 @@ typedef struct adgold_t int fm_vol_l, fm_vol_r; int samp_vol_l, samp_vol_r; + int aux_vol_l, aux_vol_r; int vol_l, vol_r; int treble, bass; @@ -260,6 +261,14 @@ void adgold_write(uint16_t addr, uint8_t val, void *p) adgold->adgold_38x_regs[0x0c] = val; adgold->samp_vol_r = (int)(int8_t)(val - 128); break; + case 0x0d: /*Aux volume left*/ + adgold->adgold_38x_regs[0x0d] = val; + adgold->aux_vol_l = (int)(int8_t)(val - 128); + break; + case 0x0e: /*Aux volume right*/ + adgold->adgold_38x_regs[0x0e] = val; + adgold->aux_vol_r = (int)(int8_t)(val - 128); + break; case 0x18: /*Surround*/ adgold->adgold_38x_regs[0x18] = val; @@ -810,6 +819,8 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p) free(adgold_buffer); } +/*CD audio filter goes here*/ + static void adgold_input_msg(void *p, uint8_t *msg, uint32_t len) { @@ -899,6 +910,8 @@ void *adgold_init(const device_t *info) adgold->fm_vol_r = (int)(int8_t)(adgold->adgold_eeprom[0x0a] - 128); adgold->samp_vol_l = (int)(int8_t)(adgold->adgold_eeprom[0x0b] - 128); adgold->samp_vol_r = (int)(int8_t)(adgold->adgold_eeprom[0x0c] - 128); + adgold->aux_vol_l = (int)(int8_t)(adgold->adgold_eeprom[0x0d] - 128); + adgold->aux_vol_r = (int)(int8_t)(adgold->adgold_eeprom[0x0e] - 128); adgold->adgold_mma_enable[0] = 0; adgold->adgold_mma_fifo_start[0] = adgold->adgold_mma_fifo_end[0] = 0; @@ -913,6 +926,8 @@ void *adgold_init(const device_t *info) sound_add_handler(adgold_get_buffer, adgold); + /*sound_set_cd_audio_filter(adgold_filter_cd_audio, adgold);*/ + if (device_get_config_int("receive_input")) midi_in_handler(1, adgold_input_msg, adgold_input_sysex, adgold); From 5218fa0b19214cc00f409167bec0339720d7f5cb Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Thu, 20 Jan 2022 17:43:31 -0400 Subject: [PATCH 3/4] Refined and optimized CD audio filter on AdLib Gold sound card --- src/sound/snd_adlibgold.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 853e74f0e..4a94fc0d1 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -819,7 +819,17 @@ static void adgold_get_buffer(int32_t *buffer, int len, void *p) free(adgold_buffer); } -/*CD audio filter goes here*/ +static void +adgold_filter_cd_audio(int channel, double *buffer, void *p) +{ + adgold_t *adgold = (adgold_t *)p; + double c; + int aux = channel ? adgold->aux_vol_r : adgold->aux_vol_l; + int vol = channel ? adgold->vol_r : adgold->vol_l; + + c = ((((*buffer) * aux) / 4096.0) * vol) / 4096.0; + *buffer = c; +} static void adgold_input_msg(void *p, uint8_t *msg, uint32_t len) @@ -926,7 +936,7 @@ void *adgold_init(const device_t *info) sound_add_handler(adgold_get_buffer, adgold); - /*sound_set_cd_audio_filter(adgold_filter_cd_audio, adgold);*/ + sound_set_cd_audio_filter(adgold_filter_cd_audio, adgold); if (device_get_config_int("receive_input")) midi_in_handler(1, adgold_input_msg, adgold_input_sysex, adgold); From 89c8212267d1de6f23dd3f1e0c876f79805a4fdc Mon Sep 17 00:00:00 2001 From: Ompronce <88358700+Ompronce@users.noreply.github.com> Date: Thu, 20 Jan 2022 17:46:36 -0400 Subject: [PATCH 4/4] Corrected spacing --- src/sound/snd_adlibgold.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sound/snd_adlibgold.c b/src/sound/snd_adlibgold.c index 4a94fc0d1..93c0af420 100644 --- a/src/sound/snd_adlibgold.c +++ b/src/sound/snd_adlibgold.c @@ -825,7 +825,7 @@ adgold_filter_cd_audio(int channel, double *buffer, void *p) adgold_t *adgold = (adgold_t *)p; double c; int aux = channel ? adgold->aux_vol_r : adgold->aux_vol_l; - int vol = channel ? adgold->vol_r : adgold->vol_l; + int vol = channel ? adgold->vol_r : adgold->vol_l; c = ((((*buffer) * aux) / 4096.0) * vol) / 4096.0; *buffer = c;