Use a LUT instead of a switch to handle choosing which audiolib mixer function to use for a voice

git-svn-id: https://svn.eduke32.com/eduke32@7917 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-08-07 22:44:37 +00:00 committed by Christoph Oelckers
parent b8f668aa9b
commit 9302e48cef
2 changed files with 8 additions and 22 deletions

View file

@ -37,9 +37,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define VOC_16BIT 0x4 #define VOC_16BIT 0x4
#define T_SIXTEENBIT_STEREO 0 #define T_SIXTEENBIT_STEREO 0
#define T_MONO 2 #define T_MONO 1
#define T_16BITSOURCE 4 #define T_16BITSOURCE 2
#define T_STEREOSOURCE 8 #define T_STEREOSOURCE 4
#define T_DEFAULT T_SIXTEENBIT_STEREO #define T_DEFAULT T_SIXTEENBIT_STEREO
#define MV_MAXPANPOSITION 127 /* formerly 31 */ #define MV_MAXPANPOSITION 127 /* formerly 31 */

View file

@ -574,26 +574,12 @@ void MV_SetVoiceMixMode(VoiceNode *voice)
if (voice->channels == 2) if (voice->channels == 2)
type |= T_STEREOSOURCE; type |= T_STEREOSOURCE;
switch (type) // stereo look-up table
{ static constexpr decltype(voice->mix) mixslut[]
case T_16BITSOURCE | T_MONO: voice->mix = MV_Mix16BitMono16; break; = { MV_Mix16BitStereo, MV_Mix16BitMono, MV_Mix16BitStereo16, MV_Mix16BitMono16,
MV_Mix16BitStereo8Stereo, MV_Mix16BitMono8Stereo, MV_Mix16BitStereo16Stereo, MV_Mix16BitMono16Stereo };
case T_MONO: voice->mix = MV_Mix16BitMono; break; voice->mix = mixslut[type];
case T_16BITSOURCE: voice->mix = MV_Mix16BitStereo16; break;
case T_SIXTEENBIT_STEREO: voice->mix = MV_Mix16BitStereo; break;
case T_16BITSOURCE | T_STEREOSOURCE: voice->mix = MV_Mix16BitStereo16Stereo; break;
case T_16BITSOURCE | T_STEREOSOURCE | T_MONO: voice->mix = MV_Mix16BitMono16Stereo; break;
case T_STEREOSOURCE: voice->mix = MV_Mix16BitStereo8Stereo; break;
case T_STEREOSOURCE | T_MONO: voice->mix = MV_Mix16BitMono8Stereo; break;
default: voice->mix = NULL; break;
}
} }
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right, float volume) void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right, float volume)