From de3215bcab273e222821d8c00eccfbe679f4193f Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 30 Oct 2019 05:51:29 +0000 Subject: [PATCH] Add sound and music code for Ken-Build Patch from Nuke.YKT. git-svn-id: https://svn.eduke32.com/eduke32@8266 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # GNUmakefile # platform/Windows/kenbuild.vcxproj # platform/Windows/kenbuild.vcxproj.filters # source/kenbuild/src/config.cpp # source/kenbuild/src/game.cpp # source/kenbuild/src/sound_stub.cpp --- source/audiolib/include/multivoc.h | 7 +++++++ source/audiolib/src/multivoc.cpp | 13 +++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/audiolib/include/multivoc.h b/source/audiolib/include/multivoc.h index 949e9dfdf..59f06b5f9 100644 --- a/source/audiolib/include/multivoc.h +++ b/source/audiolib/include/multivoc.h @@ -130,6 +130,13 @@ int MV_Shutdown(void); void MV_HookMusicRoutine(void (*callback)(void)); void MV_UnhookMusicRoutine(void); +struct MV_MusicRoutineBuffer +{ + char * buffer; + int32_t size; +}; +struct MV_MusicRoutineBuffer MV_GetMusicRoutineBuffer(void); + static inline void MV_SetPrintf(void (*function)(const char *, ...)) { if (function) MV_Printf = function; } #endif diff --git a/source/audiolib/src/multivoc.cpp b/source/audiolib/src/multivoc.cpp index caa99bd19..2d4328ce5 100644 --- a/source/audiolib/src/multivoc.cpp +++ b/source/audiolib/src/multivoc.cpp @@ -270,10 +270,10 @@ static void MV_ServiceVoc(void) MV_MusicCallback(); int16_t *source = (int16_t*)MV_MusicBuffer; int16_t *dest = (int16_t*)MV_MixBuffer[MV_MixPage+MV_NumberOfBuffers]; - for (int i = 0; i < MV_BufferSize>>2; i++) + for (int32_t i = 0; i < MV_BufferSize>>2; i++) { - int sl = *source++; - int sr = *source++; + int32_t sl = *source++; + int32_t sr = *source++; *dest = clamp(*dest+sl,INT16_MIN, INT16_MAX); dest++; *dest = clamp(*dest+sr,INT16_MIN, INT16_MAX); @@ -787,7 +787,7 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, void *initd MV_SetErrorCode(MV_Ok); // MV_TotalMemory + 2: FIXME, see valgrind_errors.log - int const totalmem = Voices * sizeof(VoiceNode) + (MV_TOTALBUFFERSIZE<<1) + (MV_MIXBUFFERSIZE<<2); + int const totalmem = Voices * sizeof(VoiceNode) + (MV_TOTALBUFFERSIZE<<1) + (MV_MIXBUFFERSIZE<<2) + 2; char *ptr = (char *) Xaligned_alloc(16, totalmem); @@ -913,6 +913,11 @@ void MV_UnhookMusicRoutine(void) } } +MV_MusicRoutineBuffer MV_GetMusicRoutineBuffer() +{ + return MV_MusicRoutineBuffer{ MV_MusicBuffer, MV_BufferSize }; +} + const char *loopStartTags[loopStartTagCount] = { "LOOP_START", "LOOPSTART", "LOOP" }; const char *loopEndTags[loopEndTagCount] = { "LOOP_END", "LOOPEND" }; const char *loopLengthTags[loopLengthTagCount] = { "LOOP_LENGTH", "LOOPLENGTH" };