diff --git a/source/audiolib/include/fx_man.h b/source/audiolib/include/fx_man.h index b4f791704..09bb3dbbc 100644 --- a/source/audiolib/include/fx_man.h +++ b/source/audiolib/include/fx_man.h @@ -54,7 +54,7 @@ enum FX_LOOP_HOW #define FX_MUSIC_PRIORITY INT_MAX const char *FX_ErrorString(int ErrorNumber); -int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata); +int FX_Init(int numvoices, int numchannels, int mixrate, void *initdata); int FX_Shutdown(void); diff --git a/source/audiolib/src/_multivc.h b/source/audiolib/src/_multivc.h index c50edc85f..87edfc060 100644 --- a/source/audiolib/src/_multivc.h +++ b/source/audiolib/src/_multivc.h @@ -175,7 +175,7 @@ typedef struct VoiceNode float volume; - unsigned LoopCount; + int LoopCount; uint32_t LoopSize; uint32_t BlockLength; diff --git a/source/audiolib/src/driver_adlib.cpp b/source/audiolib/src/driver_adlib.cpp index e5a622107..b0ddf1aab 100644 --- a/source/audiolib/src/driver_adlib.cpp +++ b/source/audiolib/src/driver_adlib.cpp @@ -117,12 +117,12 @@ static opl3_chip chip; opl3_chip *AL_GetChip(void) { return &chip; } -static constexpr unsigned int OctavePitch[MAX_OCTAVE+1] = { +static constexpr uint32_t OctavePitch[MAX_OCTAVE+1] = { OCTAVE_0, OCTAVE_1, OCTAVE_2, OCTAVE_3, OCTAVE_4, OCTAVE_5, OCTAVE_6, OCTAVE_7, }; -static unsigned int NoteMod12[MAX_NOTE+1]; -static unsigned int NoteDiv12[MAX_NOTE+1]; +static uint32_t NoteMod12[MAX_NOTE+1]; +static uint32_t NoteDiv12[MAX_NOTE+1]; // Pitch table @@ -131,7 +131,7 @@ static unsigned int NoteDiv12[MAX_NOTE+1]; // { C, C_SHARP, D, D_SHARP, E, F, F_SHARP, G, G_SHARP, A, A_SHARP, B }, // }; -static constexpr unsigned int NotePitch[FINETUNE_MAX+1][12] = { +static constexpr uint32_t NotePitch[FINETUNE_MAX+1][12] = { { 0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca, 0x1e5, 0x202, 0x220, 0x241, 0x263, 0x287 }, { 0x157, 0x16b, 0x181, 0x198, 0x1b0, 0x1ca, 0x1e5, 0x202, 0x220, 0x242, 0x264, 0x288 }, { 0x158, 0x16c, 0x182, 0x199, 0x1b1, 0x1cb, 0x1e6, 0x203, 0x221, 0x243, 0x265, 0x289 }, @@ -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; static int AL_SendStereo; static int AL_MaxMidiChannel = 16; @@ -334,13 +334,13 @@ static void AL_SetVoiceVolume(int const voice) int const port = Voice[voice].port; // amplitude - uint32_t t1 = (unsigned int)VoiceLevel[slot][port] * (velocity + 0x80); + auto t1 = (uint32_t)VoiceLevel[slot][port] * (velocity + 0x80); t1 = (Channel[channel].Volume * t1) >> 15; if (!AL_SendStereo) { uint32_t volume = t1 ^ 63; - volume |= (unsigned int)VoiceKsl[slot][port]; + volume |= (uint32_t)VoiceKsl[slot][port]; AL_SendOutput(port, 0x40 + offsetSlot[slot], volume); @@ -350,11 +350,11 @@ static void AL_SetVoiceVolume(int const voice) int const slot = slotVoice[voc][0]; // amplitude - uint32_t t2 = (unsigned int)VoiceLevel[slot][port] * (velocity + 0x80); + auto t2 = (uint32_t)VoiceLevel[slot][port] * (velocity + 0x80); t2 = (Channel[channel].Volume * t2) >> 15; volume = t2 ^ 63; - volume |= (unsigned int)VoiceKsl[slot][port]; + volume |= (uint32_t)VoiceKsl[slot][port]; AL_SendOutput(port, 0x40 + offsetSlot[slot], volume); } @@ -371,7 +371,7 @@ static void AL_SetVoiceVolume(int const voice) } volume ^= 63; - volume |= (unsigned int)VoiceKsl[slot][port]; + volume |= (uint32_t)VoiceKsl[slot][port]; AL_SendOutputToPort(AL_LeftPort, 0x40 + offsetSlot[slot], volume); @@ -384,7 +384,7 @@ static void AL_SetVoiceVolume(int const voice) } volume ^= 63; - volume |= (unsigned int)VoiceKsl[slot][port]; + volume |= (uint32_t)VoiceKsl[slot][port]; AL_SendOutputToPort(AL_RightPort, 0x40 + offsetSlot[slot], volume); @@ -392,7 +392,7 @@ static void AL_SetVoiceVolume(int const voice) if (timbre->Feedback & 0x01) { // amplitude - uint32_t t2 = (unsigned int)VoiceLevel[slot][port] * (velocity + 0x80); + auto t2 = (uint32_t)VoiceLevel[slot][port] * (velocity + 0x80); t2 = (Channel[channel].Volume * t2) >> 15; int const slot = slotVoice[voc][0]; @@ -406,7 +406,7 @@ static void AL_SetVoiceVolume(int const voice) } volume ^= 63; - volume |= (unsigned int)VoiceKsl[slot][port]; + volume |= (uint32_t)VoiceKsl[slot][port]; AL_SendOutputToPort(AL_LeftPort, 0x40 + offsetSlot[slot], volume); @@ -419,7 +419,7 @@ static void AL_SetVoiceVolume(int const voice) } volume ^= 63; - volume |= (unsigned int)VoiceKsl[slot][port]; + volume |= (uint32_t)VoiceKsl[slot][port]; AL_SendOutputToPort(AL_RightPort, 0x40 + offsetSlot[slot], volume); } @@ -430,9 +430,9 @@ static int AL_AllocVoice(void) { if (Voice_Pool.start) { - int voice = Voice_Pool.start->num; + int const voice = Voice_Pool.start->num; LL_Remove(AdLibVoice, &Voice_Pool, &Voice[voice]); - return voice; + return voice; } return AL_VoiceNotFound; @@ -441,11 +441,11 @@ static int AL_AllocVoice(void) static int AL_GetVoice(int const channel, int const key) { - auto voice = Channel[channel].Voices.start; + auto const *voice = Channel[channel].Voices.start; while (voice != nullptr) { - if (voice->key == (unsigned int)key) + if (voice->key == (uint32_t)key) return voice->num; voice = voice->next; } @@ -554,10 +554,7 @@ static void AL_ResetVoices(void) Voice_Pool.start = nullptr; Voice_Pool.end = nullptr; - int numvoices = NUMADLIBVOICES; - - if (!AL_Stereo) - numvoices = NUMADLIBVOICES * 2; + int const numvoices = AL_Stereo ? NUMADLIBVOICES : NUMADLIBVOICES * 2; for (int index = 0; index < numvoices; index++) { @@ -576,15 +573,9 @@ static void AL_ResetVoices(void) for (int index = 0; index < NUMADLIBCHANNELS; index++) { - Channel[index].Voices.start = nullptr; - Channel[index].Voices.end = nullptr; - Channel[index].Timbre = 0; - Channel[index].Pitchbend = 0; - Channel[index].KeyOffset = 0; - Channel[index].KeyDetune = 0; + Channel[index] = {}; Channel[index].Volume = AL_DefaultChannelVolume; Channel[index].Pan = 64; - Channel[index].RPN = 0; Channel[index].PitchBendRange = AL_DefaultPitchBendRange; Channel[index].PitchBendSemiTones = AL_DefaultPitchBendRange / 100; Channel[index].PitchBendHundreds = AL_DefaultPitchBendRange % 100; @@ -618,27 +609,27 @@ static void AL_FlushCard(int const port) { for (int i = 0; i < NUMADLIBVOICES; i++) { - if (VoiceReserved[i] == FALSE) - { - unsigned slot1 = offsetSlot[slotVoice[i][0]]; - unsigned slot2 = offsetSlot[slotVoice[i][1]]; + if (VoiceReserved[i]) + continue; - AL_SendOutputToPort(port, 0xA0 + i, 0); - AL_SendOutputToPort(port, 0xB0 + i, 0); + auto slot1 = offsetSlot[slotVoice[i][0]]; + auto slot2 = offsetSlot[slotVoice[i][1]]; - AL_SendOutputToPort(port, 0xE0 + slot1, 0); - AL_SendOutputToPort(port, 0xE0 + slot2, 0); + AL_SendOutputToPort(port, 0xA0 + i, 0); + AL_SendOutputToPort(port, 0xB0 + i, 0); - // Set the envelope to be fast and quiet - AL_SendOutputToPort(port, 0x60 + slot1, 0xff); - AL_SendOutputToPort(port, 0x60 + slot2, 0xff); - AL_SendOutputToPort(port, 0x80 + slot1, 0xff); - AL_SendOutputToPort(port, 0x80 + slot2, 0xff); + AL_SendOutputToPort(port, 0xE0 + slot1, 0); + AL_SendOutputToPort(port, 0xE0 + slot2, 0); - // Maximum attenuation - AL_SendOutputToPort(port, 0x40 + slot1, 0xff); - AL_SendOutputToPort(port, 0x40 + slot2, 0xff); - } + // Set the envelope to be fast and quiet + AL_SendOutputToPort(port, 0x60 + slot1, 0xff); + AL_SendOutputToPort(port, 0x60 + slot2, 0xff); + AL_SendOutputToPort(port, 0x80 + slot1, 0xff); + AL_SendOutputToPort(port, 0x80 + slot2, 0xff); + + // Maximum attenuation + AL_SendOutputToPort(port, 0x40 + slot1, 0xff); + AL_SendOutputToPort(port, 0x40 + slot2, 0xff); } } @@ -839,7 +830,7 @@ static void AL_SetPitchBend(int const channel, int const lsb, int const msb) Channel[channel].KeyOffset = (int)(TotalBend / FINETUNE_RANGE); Channel[channel].KeyOffset -= Channel[channel].PitchBendSemiTones; - Channel[channel].KeyDetune = (unsigned int)(TotalBend % FINETUNE_RANGE); + Channel[channel].KeyDetune = (uint32_t)(TotalBend % FINETUNE_RANGE); auto voice = Channel[channel].Voices.start; while (voice != nullptr) diff --git a/source/audiolib/src/driver_directsound.cpp b/source/audiolib/src/driver_directsound.cpp index 62e9f4e05..e01aa906b 100644 --- a/source/audiolib/src/driver_directsound.cpp +++ b/source/audiolib/src/driver_directsound.cpp @@ -112,7 +112,7 @@ static void FillBuffer(int bufnum) continue; } fail: - MV_Printf("DirectSound FillBuffer: err %x\n", (unsigned int)err); + MV_Printf("DirectSound FillBuffer: err %x\n", (uint32_t)err); return; } @@ -170,7 +170,7 @@ static DWORD WINAPI fillDataThread(LPVOID lpParameter) static void TeardownDSound(HRESULT err) { if (FAILED(err)) - MV_Printf("Dying error: %x\n", (unsigned int)err); + MV_Printf("Dying error: %x\n", (uint32_t)err); if (lpdsnotify) IDirectSoundNotify_Release(lpdsnotify), lpdsnotify = nullptr; diff --git a/source/audiolib/src/driver_nosound.cpp b/source/audiolib/src/driver_nosound.cpp index 64f6d2bb1..fc7a786e8 100644 --- a/source/audiolib/src/driver_nosound.cpp +++ b/source/audiolib/src/driver_nosound.cpp @@ -71,7 +71,7 @@ int NoSoundDrv_MIDI_StartPlayback(void (*service)(void)) } void NoSoundDrv_MIDI_HaltPlayback(void) {} -unsigned int NoSoundDrv_MIDI_GetTick(void) { return 0; } +uint32_t NoSoundDrv_MIDI_GetTick(void) { return 0; } void NoSoundDrv_MIDI_SetTempo(int tempo, int division) { diff --git a/source/audiolib/src/driver_nosound.h b/source/audiolib/src/driver_nosound.h index 1bbb6b2c0..9d0f7496b 100644 --- a/source/audiolib/src/driver_nosound.h +++ b/source/audiolib/src/driver_nosound.h @@ -20,6 +20,8 @@ #include "midifuncs.h" +#include + int NoSoundDrv_GetError(void); const char *NoSoundDrv_ErrorString( int ErrorNumber ); @@ -35,7 +37,7 @@ int NoSoundDrv_MIDI_Init(midifuncs *); void NoSoundDrv_MIDI_Shutdown(void); int NoSoundDrv_MIDI_StartPlayback(void (*service)(void)); void NoSoundDrv_MIDI_HaltPlayback(void); -unsigned int NoSoundDrv_MIDI_GetTick(void); +uint32_t NoSoundDrv_MIDI_GetTick(void); void NoSoundDrv_MIDI_SetTempo(int tempo, int division); void NoSoundDrv_MIDI_Lock(void); void NoSoundDrv_MIDI_Unlock(void); \ No newline at end of file diff --git a/source/audiolib/src/driver_winmm.cpp b/source/audiolib/src/driver_winmm.cpp index e32bdf31a..58916e989 100644 --- a/source/audiolib/src/driver_winmm.cpp +++ b/source/audiolib/src/driver_winmm.cpp @@ -55,10 +55,10 @@ static BOOL midiInstalled; static HMIDISTRM midiStream; static UINT midiDeviceID = MIDI_MAPPER; static void (*midiThreadService)(void); -static unsigned int midiThreadTimer; -static unsigned int midiLastEventTime; -static unsigned int midiThreadQueueTimer; -static unsigned int midiThreadQueueTicks; +static uint32_t midiThreadTimer; +static uint32_t midiLastEventTime; +static uint32_t midiThreadQueueTimer; +static uint32_t midiThreadQueueTicks; static HANDLE midiThread; static HANDLE midiThreadQuitEvent; static HANDLE midiMutex; @@ -354,7 +354,7 @@ static void midi_setup_event(int length, unsigned char ** data) */ static BOOL midi_get_buffer(int length, unsigned char ** data) { - unsigned int datalen; + uint32_t datalen; MidiBuffer * node; // determine the space to alloc. diff --git a/source/audiolib/src/fx_man.cpp b/source/audiolib/src/fx_man.cpp index c9bc1cf22..121ac957b 100644 --- a/source/audiolib/src/fx_man.cpp +++ b/source/audiolib/src/fx_man.cpp @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. int FX_ErrorCode = FX_Ok; int FX_Installed; -const char *FX_ErrorString(int ErrorNumber) +const char *FX_ErrorString(int const ErrorNumber) { const char *ErrorString; @@ -63,7 +63,7 @@ static int osdcmd_cvar_set_audiolib(osdcmdptr_t parm) return r; } -int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata) +int FX_Init(int numvoices, int numchannels, int mixrate, void *initdata) { if (FX_Installed) FX_Shutdown(); @@ -82,9 +82,11 @@ int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata) OSD_RegisterCvar(&i, (i.flags & CVAR_FUNCPTR) ? osdcmd_cvar_set_audiolib : osdcmd_cvar_set); } } + int SoundCard = ASS_AutoDetect; - if (SoundCard == ASS_AutoDetect) { + if (SoundCard == ASS_AutoDetect) + { #if defined RENDERTYPESDL SoundCard = ASS_SDL; #elif defined RENDERTYPEWIN @@ -100,7 +102,6 @@ int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata) return FX_Error; } - if (SoundDriver_IsPCMSupported(SoundCard) == 0) { // unsupported cards fall back to no sound