sound patch from stephen anthony

git-svn-id: https://svn.eduke32.com/eduke32@585 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2007-12-12 23:07:52 +00:00
parent 31a901b7eb
commit 717d839815
20 changed files with 1975 additions and 1591 deletions

View file

@ -71,20 +71,14 @@ JMACTOBJ=$(OBJ)/util_lib.$o \
AUDIOLIB_FX_STUB=$(OBJ)/audiolib_fxstub.$o AUDIOLIB_FX_STUB=$(OBJ)/audiolib_fxstub.$o
AUDIOLIB_MUSIC_STUB=$(OBJ)/audiolib_musicstub.$o AUDIOLIB_MUSIC_STUB=$(OBJ)/audiolib_musicstub.$o
AUDIOLIB_FX_SDL=$(OBJ)/mv_mix.$o \ AUDIOLIB_FX_SDL=$(OBJ)/ll_man.$o \
$(OBJ)/mv_mix16.$o \
$(OBJ)/mvreverb.$o \
$(OBJ)/ll_man.$o \
$(OBJ)/fx_man.$o \ $(OBJ)/fx_man.$o \
$(OBJ)/dsl.$o \ $(OBJ)/dsl.$o \
$(OBJ)/pitch.$o \ $(OBJ)/pitch.$o \
$(OBJ)/multivoc.$o $(OBJ)/multivoc.$o
AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o AUDIOLIB_MUSIC_SDL=$(OBJ)/sdlmusic.$o
AUDIOLIB_FX=$(OBJ)/mv_mix.$o \ AUDIOLIB_FX=$(OBJ)/pitch.$o \
$(OBJ)/mv_mix16.$o \
$(OBJ)/mvreverb.$o \
$(OBJ)/pitch.$o \
$(OBJ)/multivoc.$o \ $(OBJ)/multivoc.$o \
$(OBJ)/ll_man.$o \ $(OBJ)/ll_man.$o \
$(OBJ)/fx_man.$o \ $(OBJ)/fx_man.$o \
@ -93,6 +87,17 @@ AUDIOLIB_MUSIC=$(OBJ)/midi.$o \
$(OBJ)/mpu401.$o \ $(OBJ)/mpu401.$o \
$(OBJ)/music.$o $(OBJ)/music.$o
ifeq (0,$(NOASM))
# Assembly sound mixing code
AUDIOLIB_FX_SDL += $(OBJ)/mv_mix.$o $(OBJ)/mv_mix16.$o $(OBJ)/mvreverb.$o
AUDIOLIB_FX += $(OBJ)/mv_mix.$o $(OBJ)/mv_mix16.$o $(OBJ)/mvreverb.$o
else
# C fallbacks for sound mixing code
AUDIOLIB_FX_SDL += $(OBJ)/mv_mix-c.$o $(OBJ)/mvreverb-c.$o
AUDIOLIB_FX += $(OBJ)/mv_mix-c.$o $(OBJ)/mvreverb-c.$o
endif
GAMEOBJS=$(OBJ)/game.$o \ GAMEOBJS=$(OBJ)/game.$o \
$(OBJ)/actors.$o \ $(OBJ)/actors.$o \
$(OBJ)/anim.$o \ $(OBJ)/anim.$o \

View file

@ -54,6 +54,8 @@ $(OBJ)/audiolib_fx_fmod.$o: $(SRC)/jaudiolib/audiolib_fx_fmod.c $(SRC)/jaudiolib
$(OBJ)/mv_mix.$o: $(SRC)/jaudiolib/mv_mix.nasm $(OBJ)/mv_mix.$o: $(SRC)/jaudiolib/mv_mix.nasm
$(OBJ)/mv_mix16.$o: $(SRC)/jaudiolib/mv_mix16.nasm $(OBJ)/mv_mix16.$o: $(SRC)/jaudiolib/mv_mix16.nasm
$(OBJ)/mvreverb.$o: $(SRC)/jaudiolib/mvreverb.nasm $(OBJ)/mvreverb.$o: $(SRC)/jaudiolib/mvreverb.nasm
$(OBJ)/mv_mix-c.$o: $(SRC)/jaudiolib/mv_mix-c.c
$(OBJ)/mvreverb-c.$o: $(SRC)/jaudiolib/mvreverb-c.c
$(OBJ)/pitch.$o: $(SRC)/jaudiolib/pitch.c $(SRC)/jaudiolib/pitch.h $(OBJ)/pitch.$o: $(SRC)/jaudiolib/pitch.c $(SRC)/jaudiolib/pitch.h
$(OBJ)/multivoc.$o: $(SRC)/jaudiolib/multivoc.c $(SRC)/jaudiolib/usrhooks.h $(SRC)/jaudiolib/linklist.h $(SRC)/jaudiolib/pitch.h $(SRC)/jaudiolib/multivoc.h $(SRC)/jaudiolib/_multivc.h $(OBJ)/multivoc.$o: $(SRC)/jaudiolib/multivoc.c $(SRC)/jaudiolib/usrhooks.h $(SRC)/jaudiolib/linklist.h $(SRC)/jaudiolib/pitch.h $(SRC)/jaudiolib/multivoc.h $(SRC)/jaudiolib/_multivc.h
$(OBJ)/fx_man.$o: $(SRC)/jaudiolib/fx_man.c $(SRC)/jaudiolib/multivoc.h $(SRC)/jaudiolib/ll_man.h $(SRC)/jaudiolib/fx_man.h $(OBJ)/fx_man.$o: $(SRC)/jaudiolib/fx_man.c $(SRC)/jaudiolib/multivoc.h $(SRC)/jaudiolib/ll_man.h $(SRC)/jaudiolib/fx_man.h

View file

@ -226,11 +226,7 @@ static void MV_SetVoicePitch( VoiceNode *voice, unsigned int rate, int pit
static void MV_CalcVolume( int MaxLevel ); static void MV_CalcVolume( int MaxLevel );
static void MV_CalcPanTable( void ); static void MV_CalcPanTable( void );
void ClearBuffer_DW(void *ptr, int data, int length) static void ClearBuffer_DW(void *ptr, int data, int length);
{
int *pptr = ptr;
for (; length>0; length--) *(pptr++) = data;
}
/* /*
#define ClearBuffer_DW( ptr, data, length ) \ #define ClearBuffer_DW( ptr, data, length ) \

View file

@ -126,6 +126,19 @@ int MV_ErrorCode = MV_Ok;
MV_ErrorCode = (status); MV_ErrorCode = (status);
/*---------------------------------------------------------------------
Function: ClearBuffer_DW
Function code relocated from _multivc.h due to linking issues.
---------------------------------------------------------------------*/
void ClearBuffer_DW(void *ptr, int data, int length)
{
int *pptr = ptr;
for (; length>0; length--) *(pptr++) = data;
}
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
Function: MV_ErrorString Function: MV_ErrorString

View file

@ -0,0 +1,301 @@
#include "multivoc.h"
extern char *MV_MixDestination;
extern unsigned int MV_MixPosition;
extern char *MV_LeftVolume;
extern char *MV_RightVolume;
extern unsigned char *MV_HarshClipTable;
extern int MV_RightChannelOffset;
extern int MV_SampleSize;
void MV_Mix8BitMono(unsigned int position, unsigned int rate,
const char *start, unsigned int length)
{
const unsigned char *src;
unsigned char *dest;
unsigned int i;
src = (const unsigned char *)start;
dest = (unsigned char *)MV_MixDestination;
for (i = 0; i < length; i++)
{
int s = src[position >> 16];
int d = *dest;
s = MV_LeftVolume[s * 2];
s += d;
s = MV_HarshClipTable[s + 0x80];
*dest = (s & 0xff);
position += rate;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix8BitStereo(unsigned int position,
unsigned int rate, const char *start, unsigned int length)
{
const unsigned char *src;
unsigned char *dest;
unsigned int i;
src = (const unsigned char *)start;
dest = (unsigned char *)MV_MixDestination;
for (i = 0; i < length; i++)
{
int s = src[(position >> 16)];
int dl = dest[0];
int dr = dest[MV_RightChannelOffset];
dl += MV_LeftVolume[s * 2];
dr += MV_RightVolume[s * 2];
dl = MV_HarshClipTable[dl + 0x80];
dr = MV_HarshClipTable[dr + 0x80];
dest[0] = (dl & 0xff);
dest[MV_RightChannelOffset] = (dr & 0xff);
position += rate;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix16BitMono(unsigned int position,
unsigned int rate, const char *start, unsigned int length)
{
const short *MV_LeftVolumeS;
const unsigned char *src;
short *dest;
unsigned int i;
src = (const unsigned char *)start;
dest = (short *)MV_MixDestination;
MV_LeftVolumeS = (const short *)MV_LeftVolume;
for (i = 0; i < length; i++)
{
int s = src[position >> 16];
int d = dest[0];
s = MV_LeftVolumeS[s];
s += d;
if (s < -32768) s = -32768;
if (s > 32767) s = 32767;
*dest = (short) s;
position += rate;
dest += MV_SampleSize/2;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix16BitStereo(unsigned int position,
unsigned int rate, const char *start, unsigned int length)
{
const short *MV_LeftVolumeS;
const short *MV_RightVolumeS;
const unsigned char *src;
short *dest;
unsigned int i;
src = (unsigned char *)start;
dest = (short *)MV_MixDestination;
MV_LeftVolumeS = (const short *)MV_LeftVolume;
MV_RightVolumeS = (const short *)MV_RightVolume;
for (i = 0; i < length; i++)
{
int s = src[position >> 16];
int dl = dest[0];
int dr = dest[MV_RightChannelOffset/2];
dl += MV_LeftVolumeS[s];
dr += MV_RightVolumeS[s];
if (dl < -32768) dl = -32768;
if (dl > 32767) dl = 32767;
if (dr < -32768) dr = -32768;
if (dr > 32767) dr = 32767;
dest[0] = (short) dl;
dest[MV_RightChannelOffset/2] = (short) dr;
position += rate;
dest += MV_SampleSize/2;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix8BitMono16(unsigned int position, unsigned int rate,
const char *start, unsigned int length)
{
const char *src;
unsigned char *dest;
unsigned int i;
src = (const char *)start + 1;
dest = (unsigned char *)MV_MixDestination;
for (i = 0; i < length; i++)
{
int s = (int)src[(position >> 16) * 2] + 0x80;
int d = *dest;
s = MV_LeftVolume[s * 2];
s += d;
s = MV_HarshClipTable[s + 0x80];
*dest = (s & 0xff);
position += rate;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix8BitStereo16(unsigned int position,
unsigned int rate, const char *start, unsigned int length)
{
const char *src;
unsigned char *dest;
unsigned int i;
src = (const char *)start + 1;
dest = (unsigned char *)MV_MixDestination;
for (i = 0; i < length; i++)
{
int s = src[(position >> 16) * 2] + 0x80;
int dl = dest[0];
int dr = dest[MV_RightChannelOffset];
dl += MV_LeftVolume[s * 2];
dr += MV_RightVolume[s * 2];
dl = MV_HarshClipTable[dl + 0x80];
dr = MV_HarshClipTable[dr + 0x80];
dest[0] = (dl & 0xff);
dest[MV_RightChannelOffset] = (dr & 0xff);
position += rate;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix16BitMono16(unsigned int position,
unsigned int rate, const char *start, unsigned int length)
{
const short *MV_LeftVolumeS;
const unsigned char *src;
short *dest;
unsigned int i;
src = (const unsigned char *)start;
dest = (short *)MV_MixDestination;
MV_LeftVolumeS = (const short *)MV_LeftVolume;
for (i = 0; i < length; i++)
{
int sl = src[(position >> 16) * 2 + 0];
int sh = src[(position >> 16) * 2 + 1] ^ 0x80;
int d = *dest;
sl = MV_LeftVolume[sl * 2 + 1];
sh = MV_LeftVolumeS[sh];
d = sl + sh + 0x80 + d;
if (d < -32768) d = -32768;
if (d > 32767) d = 32767;
*dest = (short) d;
position += rate;
dest += MV_SampleSize/2;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}
void MV_Mix16BitStereo16(unsigned int position,
unsigned int rate, const char *start, unsigned int length)
{
const short *MV_LeftVolumeS;
const short *MV_RightVolumeS;
const unsigned char *src;
short *dest;
unsigned int i;
src = (const unsigned char *)start;
dest = (short *)MV_MixDestination;
MV_LeftVolumeS = (const short *)MV_LeftVolume;
MV_RightVolumeS = (const short *)MV_RightVolume;
for (i = 0; i < length; i++)
{
int sl = src[(position >> 16) * 2 + 0];
int sh = src[(position >> 16) * 2 + 1] ^ 0x80;
int dl = dest[0];
int dr = dest[MV_RightChannelOffset/2];
int sll = MV_LeftVolume[sl * 2 + 1];
int slh = MV_LeftVolumeS[sh];
int srl = MV_RightVolume[sl * 2 + 1];
int srh = MV_RightVolumeS[sh];
dl = sll + slh + 0x80 + dl;
dr = srl + srh + 0x80 + dr;
if (dl < -32768) dl = -32768;
if (dl > 32767) dl = 32767;
if (dr < -32768) dr = -32768;
if (dr > 32767) dr = 32767;
dest[0] = (short) dl;
dest[MV_RightChannelOffset/2] = (short) dr;
position += rate;
dest += MV_SampleSize/2;
}
MV_MixPosition = position;
MV_MixDestination = (char *)dest;
}

View file

@ -0,0 +1,67 @@
#include "multivoc.h"
#include "_multivc.h"
void MV_16BitReverb(char *src, char *dest, VOLUME16 *volume, int count)
{
int i;
short *pdest = (short *)dest;
for (i = 0; i < count; i++)
{
#if PLATFORM_BIGENDIAN
int sl = src[i*2+1];
int sh = src[i*2+0] ^ 0x80;
#else
int sl = src[i*2+0];
int sh = src[i*2+1] ^ 0x80;
#endif
sl = (*volume)[sl] >> 8;
sh = (*volume)[sh];
pdest[i] = (short)(sl + sh + 0x80);
}
}
void MV_8BitReverb(signed char *src, signed char *dest, VOLUME16 *volume, int count)
{
int i;
for (i = 0; i < count; i++)
{
unsigned char s = (unsigned char) src[i];
s = (*volume)[s] & 0xff;
dest[i] = (char)(s + 0x80);
}
}
void MV_16BitReverbFast(char *src, char *dest, int count, int shift)
{
int i;
short *pdest = (short *)dest;
const short *psrc = (const short *)src;
for (i = 0; i < count; i++)
{
pdest[i] = psrc[i] >> shift;
}
}
void MV_8BitReverbFast(signed char *src, signed char *dest, int count, int shift)
{
int i;
unsigned char sh = 0x80 - (0x80 >> shift);
for (i = 0; i < count; i++)
{
unsigned char a = ((unsigned char) src[i]) >> shift;
unsigned char c = (((unsigned char) src[i]) ^ 0x80) >> 7;
dest[i] = (signed char)(a + sh + c);
}
}