From 5de8dad179299b9207e44488c8225de3e7f6990d Mon Sep 17 00:00:00 2001 From: terminx Date: Sun, 20 Oct 2019 03:13:15 +0000 Subject: [PATCH] Fix mus_adlibstereo git-svn-id: https://svn.eduke32.com/eduke32@8233 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/audiolib/include/al_midi.h --- source/audiolib/src/driver_adlib.cpp | 36 +++++++++++----------------- source/audiolib/src/fx_man.cpp | 5 ++-- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/source/audiolib/src/driver_adlib.cpp b/source/audiolib/src/driver_adlib.cpp index e9b0ff94f..825fd2ca6 100644 --- a/source/audiolib/src/driver_adlib.cpp +++ b/source/audiolib/src/driver_adlib.cpp @@ -198,7 +198,7 @@ static AdLibChannel Channel[NUMADLIBCHANNELS]; static int AL_LeftPort = ADLIB_PORT; static int AL_RightPort = ADLIB_PORT; -int AL_Stereo; +int AL_Stereo = TRUE; static int AL_SendStereo; static int AL_MaxMidiChannel = 16; @@ -632,24 +632,6 @@ static void AL_FlushCard(int const port) } -static void AL_StereoOn(void) -{ - if (AL_Stereo && !AL_SendStereo) - AL_SendStereo = TRUE; - - AL_SendOutputToPort(AL_RightPort, 0x5, 1); -} - - -static void AL_StereoOff(void) -{ - if (AL_Stereo && AL_SendStereo) - AL_SendStereo = FALSE; - - AL_SendOutputToPort(AL_RightPort, 0x5, 0); -} - - static void AL_Reset(void) { AL_SendOutputToPort(ADLIB_PORT, 1, 0x20); @@ -658,13 +640,24 @@ static void AL_Reset(void) // Set the values: AM Depth, VIB depth & Rhythm AL_SendOutputToPort(ADLIB_PORT, 0xBD, 0); - AL_StereoOn(); + AL_SetStereo(AL_Stereo); AL_FlushCard(AL_LeftPort); AL_FlushCard(AL_RightPort); } +void AL_SetStereo(int const stereo) +{ + if (stereo == AL_SendStereo) + return; + + AL_SendStereo = stereo; + AL_SendOutputToPort(AL_RightPort, 0x5, AL_SendStereo); + AL_Reset(); +} + + static void AL_NoteOff(int const channel, int const key, int velocity) { UNREFERENCED_PARAMETER(velocity); @@ -841,7 +834,7 @@ static void AL_SetPitchBend(int const channel, int const lsb, int const msb) static void AL_Shutdown(void) { - AL_StereoOff(); + AL_SetStereo(FALSE); AL_ResetVoices(); AL_Reset(); } @@ -851,7 +844,6 @@ static int AL_Init(int const rate) { OPL3_Reset(&chip, rate); - AL_Stereo = TRUE; AL_LeftPort = ADLIB_PORT; AL_RightPort = ADLIB_PORT + 2; diff --git a/source/audiolib/src/fx_man.cpp b/source/audiolib/src/fx_man.cpp index 5c9f51b4f..c58bea115 100644 --- a/source/audiolib/src/fx_man.cpp +++ b/source/audiolib/src/fx_man.cpp @@ -55,10 +55,9 @@ static int osdcmd_cvar_set_audiolib(osdcmdptr_t parm) if (r != OSDCMD_OK) return r; if (!Bstrcasecmp(parm->name, "mus_emidicard")) - { MIDI_Restart(); - return r; - } + else if (!Bstrcasecmp(parm->name, "mus_adlibstereo")) + AL_SetStereo(AL_Stereo); return r; }