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
This commit is contained in:
hendricks266 2019-10-30 05:51:29 +00:00 committed by Christoph Oelckers
parent 3e5d5a9a3d
commit de3215bcab
2 changed files with 16 additions and 4 deletions

View file

@ -130,6 +130,13 @@ int MV_Shutdown(void);
void MV_HookMusicRoutine(void (*callback)(void)); void MV_HookMusicRoutine(void (*callback)(void));
void MV_UnhookMusicRoutine(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; } static inline void MV_SetPrintf(void (*function)(const char *, ...)) { if (function) MV_Printf = function; }
#endif #endif

View file

@ -270,10 +270,10 @@ static void MV_ServiceVoc(void)
MV_MusicCallback(); MV_MusicCallback();
int16_t *source = (int16_t*)MV_MusicBuffer; int16_t *source = (int16_t*)MV_MusicBuffer;
int16_t *dest = (int16_t*)MV_MixBuffer[MV_MixPage+MV_NumberOfBuffers]; 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++; int32_t sl = *source++;
int sr = *source++; int32_t sr = *source++;
*dest = clamp(*dest+sl,INT16_MIN, INT16_MAX); *dest = clamp(*dest+sl,INT16_MIN, INT16_MAX);
dest++; dest++;
*dest = clamp(*dest+sr,INT16_MIN, INT16_MAX); *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_SetErrorCode(MV_Ok);
// MV_TotalMemory + 2: FIXME, see valgrind_errors.log // 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); 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 *loopStartTags[loopStartTagCount] = { "LOOP_START", "LOOPSTART", "LOOP" };
const char *loopEndTags[loopEndTagCount] = { "LOOP_END", "LOOPEND" }; const char *loopEndTags[loopEndTagCount] = { "LOOP_END", "LOOPEND" };
const char *loopLengthTags[loopLengthTagCount] = { "LOOP_LENGTH", "LOOPLENGTH" }; const char *loopLengthTags[loopLengthTagCount] = { "LOOP_LENGTH", "LOOPLENGTH" };