More audiolib cleanup, remove 8-bit output support.

git-svn-id: https://svn.eduke32.com/eduke32@5272 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2015-07-08 03:34:09 +00:00
parent 388fbe041e
commit 26933ecdc2
23 changed files with 95 additions and 463 deletions

View file

@ -321,6 +321,7 @@
<ClInclude Include="source\gamevars.h" /> <ClInclude Include="source\gamevars.h" />
<ClInclude Include="source\global.h" /> <ClInclude Include="source\global.h" />
<ClInclude Include="source\input.h" /> <ClInclude Include="source\input.h" />
<ClInclude Include="source\jaudiolib\include\drivers.h" />
<ClInclude Include="source\lunatic\lunatic_game.h" /> <ClInclude Include="source\lunatic\lunatic_game.h" />
<ClInclude Include="source\lunatic\lunatic_m32.h" /> <ClInclude Include="source\lunatic\lunatic_m32.h" />
<ClInclude Include="source\m32def.h" /> <ClInclude Include="source\m32def.h" />
@ -358,14 +359,11 @@
<ClInclude Include="source\jaudiolib\src\driver_directsound.h" /> <ClInclude Include="source\jaudiolib\src\driver_directsound.h" />
<ClInclude Include="source\jaudiolib\src\driver_nosound.h" /> <ClInclude Include="source\jaudiolib\src\driver_nosound.h" />
<ClInclude Include="source\jaudiolib\src\driver_sdl.h" /> <ClInclude Include="source\jaudiolib\src\driver_sdl.h" />
<ClInclude Include="source\jaudiolib\src\drivers.h" />
<ClInclude Include="source\jaudiolib\include\fx_man.h" /> <ClInclude Include="source\jaudiolib\include\fx_man.h" />
<ClInclude Include="source\jaudiolib\src\linklist.h" /> <ClInclude Include="source\jaudiolib\src\linklist.h" />
<ClInclude Include="source\jaudiolib\src\ll_man.h" />
<ClInclude Include="source\jaudiolib\src\multivoc.h" /> <ClInclude Include="source\jaudiolib\src\multivoc.h" />
<ClInclude Include="source\jaudiolib\include\music.h" /> <ClInclude Include="source\jaudiolib\include\music.h" />
<ClInclude Include="source\jaudiolib\src\pitch.h" /> <ClInclude Include="source\jaudiolib\src\pitch.h" />
<ClInclude Include="source\jaudiolib\include\sndcards.h" />
<ClInclude Include="source\jmact\_control.h" /> <ClInclude Include="source\jmact\_control.h" />
<ClInclude Include="source\jmact\_scrplib.h" /> <ClInclude Include="source\jmact\_scrplib.h" />
<ClInclude Include="source\jmact\animlib.h" /> <ClInclude Include="source\jmact\animlib.h" />

View file

@ -243,9 +243,6 @@
<ClInclude Include="source\jaudiolib\src\driver_sdl.h"> <ClInclude Include="source\jaudiolib\src\driver_sdl.h">
<Filter>jaudiolib\headers</Filter> <Filter>jaudiolib\headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\jaudiolib\src\drivers.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
<ClInclude Include="source\jaudiolib\include\fx_man.h"> <ClInclude Include="source\jaudiolib\include\fx_man.h">
<Filter>jaudiolib\headers</Filter> <Filter>jaudiolib\headers</Filter>
</ClInclude> </ClInclude>
@ -264,9 +261,6 @@
<ClInclude Include="source\jaudiolib\src\pitch.h"> <ClInclude Include="source\jaudiolib\src\pitch.h">
<Filter>jaudiolib\headers</Filter> <Filter>jaudiolib\headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\jaudiolib\include\sndcards.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
<ClInclude Include="source\jmact\_control.h"> <ClInclude Include="source\jmact\_control.h">
<Filter>jmact\headers</Filter> <Filter>jmact\headers</Filter>
</ClInclude> </ClInclude>
@ -516,6 +510,9 @@
<ClInclude Include="build\include\jwzglesI.h"> <ClInclude Include="build\include\jwzglesI.h">
<Filter>build\headers</Filter> <Filter>build\headers</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\jaudiolib\include\drivers.h">
<Filter>jaudiolib\headers</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="build\src\a-c.c"> <ClCompile Include="build\src\a-c.c">

View file

@ -26,8 +26,11 @@
typedef enum typedef enum
{ {
ASS_NoSound, ASS_NoSound,
ASS_SDL, #if defined HAVE_DS
ASS_DirectSound, ASS_DirectSound,
#elif defined HAVE_SDL
ASS_SDL,
#endif
ASS_NumSoundCards, ASS_NumSoundCards,
ASS_AutoDetect = -2 ASS_AutoDetect = -2
} soundcardnames; } soundcardnames;
@ -38,7 +41,7 @@ int32_t SoundDriver_IsSupported(int32_t driver);
int32_t SoundDriver_GetError(void); int32_t SoundDriver_GetError(void);
const char *SoundDriver_ErrorString(int32_t ErrorNumber); const char *SoundDriver_ErrorString(int32_t ErrorNumber);
int32_t SoundDriver_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void *initdata); int32_t SoundDriver_Init(int32_t *mixrate, int32_t *numchannels, void *initdata);
void SoundDriver_Shutdown(void); void SoundDriver_Shutdown(void);
int32_t SoundDriver_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t NumDivisions, void(*CallBackFunc)(void)); int32_t SoundDriver_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t NumDivisions, void(*CallBackFunc)(void));
void SoundDriver_StopPlayback(void); void SoundDriver_StopPlayback(void);

View file

@ -57,8 +57,7 @@ enum FX_LOOP_HOW
#define FX_MUSIC_PRIORITY INT_MAX #define FX_MUSIC_PRIORITY INT_MAX
const char *FX_ErrorString(int32_t ErrorNumber); const char *FX_ErrorString(int32_t ErrorNumber);
int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, int32_t samplebits, unsigned mixrate, int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata);
void *initdata);
int32_t FX_Shutdown(void); int32_t FX_Shutdown(void);
void FX_SetCallBack(void(*function)(uint32_t)); void FX_SetCallBack(void(*function)(uint32_t));
void FX_SetVolume(int32_t volume); void FX_SetVolume(int32_t volume);

View file

@ -36,16 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "multivoc.h" #include "multivoc.h"
#define VOC_8BIT 0x0 #define VOC_8BIT 0x0
#define VOC_CT4_ADPCM 0x1
#define VOC_CT3_ADPCM 0x2
#define VOC_CT2_ADPCM 0x3
#define VOC_16BIT 0x4 #define VOC_16BIT 0x4
#define VOC_ALAW 0x6
#define VOC_MULAW 0x7
#define VOC_CREATIVE_ADPCM 0x200
#define T_SIXTEENBIT_STEREO 0 #define T_SIXTEENBIT_STEREO 0
#define T_8BITS 1
#define T_MONO 2 #define T_MONO 2
#define T_16BITSOURCE 4 #define T_16BITSOURCE 4
#define T_STEREOSOURCE 8 #define T_STEREOSOURCE 8
@ -64,24 +57,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define MIX_VOLUME(volume) ((max(0, min((volume), 255)) * (MV_MAXVOLUME + 1)) >> 8) #define MIX_VOLUME(volume) ((max(0, min((volume), 255)) * (MV_MAXVOLUME + 1)) >> 8)
#define STEREO 1
#define SIXTEEN_BIT 2
#define MONO_8BIT 0
#define STEREO_8BIT ( STEREO )
#define MONO_16BIT ( SIXTEEN_BIT )
#define STEREO_16BIT ( STEREO | SIXTEEN_BIT )
#define MONO_8BIT_SAMPLE_SIZE 1
#define MONO_16BIT_SAMPLE_SIZE 2
#define STEREO_8BIT_SAMPLE_SIZE ( 2 * MONO_8BIT_SAMPLE_SIZE )
#define STEREO_16BIT_SAMPLE_SIZE ( 2 * MONO_16BIT_SAMPLE_SIZE )
//#define SILENCE_16BIT 0x80008000
#define SILENCE_16BIT 0
#define SILENCE_8BIT 0x80808080
//#define SILENCE_16BIT_PAS 0
#define MV_MIXBUFFERSIZE 256 #define MV_MIXBUFFERSIZE 256
#define MV_NUMBEROFBUFFERS 16 #define MV_NUMBEROFBUFFERS 16
#define MV_TOTALBUFFERSIZE ( MV_MIXBUFFERSIZE * MV_NUMBEROFBUFFERS ) #define MV_TOTALBUFFERSIZE ( MV_MIXBUFFERSIZE * MV_NUMBEROFBUFFERS )
@ -200,28 +175,18 @@ void MV_ReleaseFLACVoice(VoiceNode *voice);
void MV_ReleaseXAVoice(VoiceNode *voice); void MV_ReleaseXAVoice(VoiceNode *voice);
// implemented in mix.c // implemented in mix.c
void MV_Mix8BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix8BitStereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix8BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix8BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_16BitReverb( char const *src, char *dest, int16_t *volume, int32_t count ); void MV_16BitReverb( char const *src, char *dest, int16_t *volume, int32_t count );
void MV_8BitReverb( int8_t *src, int8_t *dest, int16_t *volume, int32_t count );
// implemented in mixst.c // implemented in mixst.c
void MV_Mix8BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix8BitStereo8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitStereo8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitStereo8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitMono16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitMono16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix8BitMono16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix8BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
void MV_Mix16BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length); void MV_Mix16BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length);
extern char *MV_HarshClipTable;
extern char *MV_MixDestination; // pointer to the next output sample extern char *MV_MixDestination; // pointer to the next output sample
extern uint32_t MV_MixPosition; // return value of where the source pointer got to extern uint32_t MV_MixPosition; // return value of where the source pointer got to
extern const int16_t *MV_LeftVolume; extern const int16_t *MV_LeftVolume;

View file

@ -300,7 +300,7 @@ static void TeardownDSound(HRESULT err)
lpds = NULL; lpds = NULL;
} }
int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata) int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
{ {
HRESULT err; HRESULT err;
DSBUFFERDESC bufdesc; DSBUFFERDESC bufdesc;
@ -341,7 +341,7 @@ int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t
wfex.wFormatTag = WAVE_FORMAT_PCM; wfex.wFormatTag = WAVE_FORMAT_PCM;
wfex.nChannels = *numchannels; wfex.nChannels = *numchannels;
wfex.nSamplesPerSec = *mixrate; wfex.nSamplesPerSec = *mixrate;
wfex.wBitsPerSample = *samplebits; wfex.wBitsPerSample = 16;
wfex.nBlockAlign = wfex.nChannels * wfex.wBitsPerSample / 8; wfex.nBlockAlign = wfex.nChannels * wfex.wBitsPerSample / 8;
wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign; wfex.nAvgBytesPerSec = wfex.nSamplesPerSec * wfex.nBlockAlign;

View file

@ -22,7 +22,7 @@
int32_t DirectSoundDrv_GetError(void); int32_t DirectSoundDrv_GetError(void);
const char *DirectSoundDrv_ErrorString( int32_t ErrorNumber ); const char *DirectSoundDrv_ErrorString( int32_t ErrorNumber );
int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata); int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata);
void DirectSoundDrv_PCM_Shutdown(void); void DirectSoundDrv_PCM_Shutdown(void);
int32_t DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
int32_t NumDivisions, void ( *CallBackFunc )( void ) ); int32_t NumDivisions, void ( *CallBackFunc )( void ) );

View file

@ -40,11 +40,10 @@ const char *NoSoundDrv_ErrorString( int32_t ErrorNumber )
return "No sound, Ok."; return "No sound, Ok.";
} }
int32_t NoSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata) int32_t NoSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
{ {
UNREFERENCED_PARAMETER(mixrate); UNREFERENCED_PARAMETER(mixrate);
UNREFERENCED_PARAMETER(numchannels); UNREFERENCED_PARAMETER(numchannels);
UNREFERENCED_PARAMETER(samplebits);
UNREFERENCED_PARAMETER(initdata); UNREFERENCED_PARAMETER(initdata);
return 0; return 0;
} }

View file

@ -21,7 +21,7 @@
int NoSoundDrv_GetError(void); int NoSoundDrv_GetError(void);
const char *NoSoundDrv_ErrorString( int ErrorNumber ); const char *NoSoundDrv_ErrorString( int ErrorNumber );
int NoSoundDrv_PCM_Init(int *mixrate, int *numchannels, int *samplebits, void * initdata); int NoSoundDrv_PCM_Init(int *mixrate, int *numchannels, void * initdata);
void NoSoundDrv_PCM_Shutdown(void); void NoSoundDrv_PCM_Shutdown(void);
int NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
int NumDivisions, void ( *CallBackFunc )( void ) ); int NumDivisions, void ( *CallBackFunc )( void ) );

View file

@ -143,7 +143,7 @@ const char *SDLDrv_ErrorString( int32_t ErrorNumber )
return ErrorString; return ErrorString;
} }
int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata) int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
{ {
int32_t err = 0; int32_t err = 0;
int32_t chunksize; int32_t chunksize;
@ -164,17 +164,21 @@ int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *sampleb
if (*mixrate >= 16000) chunksize *= 2; if (*mixrate >= 16000) chunksize *= 2;
if (*mixrate >= 32000) chunksize *= 2; if (*mixrate >= 32000) chunksize *= 2;
err = Mix_OpenAudio(*mixrate, (*samplebits == 8) ? AUDIO_U8 : AUDIO_S16SYS, *numchannels, chunksize); err = Mix_OpenAudio(*mixrate, AUDIO_S16SYS, *numchannels, chunksize);
if (err < 0) { if (err < 0) {
ErrorCode = SDLErr_OpenAudio; ErrorCode = SDLErr_OpenAudio;
return SDLErr_Error; return SDLErr_Error;
} }
if (Mix_QuerySpec(mixrate, &fmt, numchannels)) if (Mix_QuerySpec(mixrate, &fmt, numchannels))
{ {
if (fmt == AUDIO_U8 || fmt == AUDIO_S8) *samplebits = 8; if (fmt == AUDIO_U8 || fmt == AUDIO_S8)
else *samplebits = 16; {
ErrorCode = SDLErr_OpenAudio;
return SDLErr_Error;
}
} }
//Mix_SetPostMix(fillData, NULL); //Mix_SetPostMix(fillData, NULL);

View file

@ -21,7 +21,7 @@
int32_t SDLDrv_GetError(void); int32_t SDLDrv_GetError(void);
const char *SDLDrv_ErrorString( int32_t ErrorNumber ); const char *SDLDrv_ErrorString( int32_t ErrorNumber );
int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void * initdata); int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata);
void SDLDrv_PCM_Shutdown(void); void SDLDrv_PCM_Shutdown(void);
int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
int32_t NumDivisions, void ( *CallBackFunc )( void ) ); int32_t NumDivisions, void ( *CallBackFunc )( void ) );

View file

@ -27,12 +27,10 @@
#include "driver_nosound.h" #include "driver_nosound.h"
#ifdef HAVE_SDL #if defined HAVE_DS
# include "driver_sdl.h"
#endif
#ifdef HAVE_DS
# include "driver_directsound.h" # include "driver_directsound.h"
#elif defined HAVE_SDL
# include "driver_sdl.h"
#endif #endif
int32_t ASS_SoundDriver = -1; int32_t ASS_SoundDriver = -1;
@ -43,7 +41,7 @@ static struct
{ {
int32_t (*GetError)(void); int32_t (*GetError)(void);
const char *(*ErrorString)(int32_t); const char *(*ErrorString)(int32_t);
int32_t (*Init)(int32_t *, int32_t *, int32_t *, void *); int32_t (*Init)(int32_t *, int32_t *, void *);
void (*Shutdown)(void); void (*Shutdown)(void);
int32_t (*BeginPlayback)(char *, int32_t, int32_t, void (*)(void)); int32_t (*BeginPlayback)(char *, int32_t, int32_t, void (*)(void));
void (*StopPlayback)(void); void (*StopPlayback)(void);
@ -57,32 +55,24 @@ static struct
NoSoundDrv_PCM_BeginPlayback, NoSoundDrv_PCM_StopPlayback, NoSoundDrv_PCM_Lock, NoSoundDrv_PCM_Unlock, NoSoundDrv_PCM_BeginPlayback, NoSoundDrv_PCM_StopPlayback, NoSoundDrv_PCM_Lock, NoSoundDrv_PCM_Unlock,
}, },
// Simple DirectMedia Layer
#ifdef HAVE_SDL
{
SDLDrv_GetError, SDLDrv_ErrorString, SDLDrv_PCM_Init, SDLDrv_PCM_Shutdown,
SDLDrv_PCM_BeginPlayback, SDLDrv_PCM_StopPlayback, SDLDrv_PCM_Lock, SDLDrv_PCM_Unlock,
},
#else
UNSUPPORTED
#endif
// Windows DirectSound // Windows DirectSound
#ifdef HAVE_DS #if defined HAVE_DS
{ {
DirectSoundDrv_GetError, DirectSoundDrv_ErrorString, DirectSoundDrv_PCM_Init, DirectSoundDrv_PCM_Shutdown, DirectSoundDrv_GetError, DirectSoundDrv_ErrorString, DirectSoundDrv_PCM_Init, DirectSoundDrv_PCM_Shutdown,
DirectSoundDrv_PCM_BeginPlayback, DirectSoundDrv_PCM_StopPlayback, DirectSoundDrv_PCM_Lock, DirectSoundDrv_PCM_BeginPlayback, DirectSoundDrv_PCM_StopPlayback, DirectSoundDrv_PCM_Lock,
DirectSoundDrv_PCM_Unlock, DirectSoundDrv_PCM_Unlock,
}, },
#else // Simple DirectMedia Layer
UNSUPPORTED #elif defined HAVE_SDL
#endif {
SDLDrv_GetError, SDLDrv_ErrorString, SDLDrv_PCM_Init, SDLDrv_PCM_Shutdown,
SDLDrv_PCM_BeginPlayback, SDLDrv_PCM_StopPlayback, SDLDrv_PCM_Lock, SDLDrv_PCM_Unlock,
},
#endif
}; };
int32_t SoundDriver_IsSupported(int32_t driver) { return (SoundDrivers[driver].GetError != 0); } int32_t SoundDriver_IsSupported(int32_t driver) { return (SoundDrivers[driver].GetError != 0); }
int32_t SoundDriver_GetError(void) int32_t SoundDriver_GetError(void)
{ {
return SoundDriver_IsSupported(ASS_SoundDriver) ? SoundDrivers[ASS_SoundDriver].GetError() : -1; return SoundDriver_IsSupported(ASS_SoundDriver) ? SoundDrivers[ASS_SoundDriver].GetError() : -1;
@ -99,9 +89,9 @@ const char * SoundDriver_ErrorString( int32_t ErrorNumber )
return SoundDrivers[ASS_SoundDriver].ErrorString(ErrorNumber); return SoundDrivers[ASS_SoundDriver].ErrorString(ErrorNumber);
} }
int32_t SoundDriver_Init(int32_t *mixrate, int32_t *numchannels, int32_t *samplebits, void *initdata) int32_t SoundDriver_Init(int32_t *mixrate, int32_t *numchannels, void *initdata)
{ {
return SoundDrivers[ASS_SoundDriver].Init(mixrate, numchannels, samplebits, initdata); return SoundDrivers[ASS_SoundDriver].Init(mixrate, numchannels, initdata);
} }
void SoundDriver_Shutdown(void) { SoundDrivers[ASS_SoundDriver].Shutdown(); } void SoundDriver_Shutdown(void) { SoundDrivers[ASS_SoundDriver].Shutdown(); }

View file

@ -665,6 +665,10 @@ void MV_ReleaseFLACVoice(VoiceNode *voice)
voice->rawdataptr = 0; voice->rawdataptr = 0;
} }
#else #else
#include <stdlib.h>
#include <stdio.h>
#include "_multivc.h"
int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval) int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval)
{ {

View file

@ -75,7 +75,7 @@ static inline int32_t FX_CheckMVErr(int32_t status)
return status; return status;
} }
int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, int32_t samplebits, unsigned mixrate, void *initdata) int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata)
{ {
if (FX_Installed) if (FX_Installed)
FX_Shutdown(); FX_Shutdown();
@ -106,7 +106,7 @@ int32_t FX_Init(int32_t SoundCard, int32_t numvoices, int32_t numchannels, int32
int status = FX_Ok; int status = FX_Ok;
if (MV_Init(SoundCard, mixrate, numvoices, numchannels, samplebits, initdata) != MV_Ok) if (MV_Init(SoundCard, mixrate, numvoices, numchannels, initdata) != MV_Ok)
{ {
FX_SetErrorCode(FX_MultiVocError); FX_SetErrorCode(FX_MultiVocError);
status = FX_Error; status = FX_Error;

View file

@ -29,56 +29,6 @@
length = count of samples to mix length = count of samples to mix
*/ */
// 8-bit mono source, 8-bit mono output
void MV_Mix8BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0;
while (length--) {
sample0 = source[position >> 16];
position += rate;
sample0 = MV_LeftVolume[sample0] + *dest;
sample0 = MV_HarshClipTable[sample0 + 128];
*dest = sample0 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 8-bit mono source, 8-bit stereo output
void MV_Mix8BitStereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0, sample1;
while (length--) {
sample0 = source[position >> 16];
sample1 = sample0;
position += rate;
sample0 = MV_LeftVolume[sample0] + *dest;
sample1 = MV_RightVolume[sample1] + *(dest + MV_RightChannelOffset);
sample0 = MV_HarshClipTable[sample0 + 128];
sample1 = MV_HarshClipTable[sample1 + 128];
*dest = sample0 & 255;
*(dest + MV_RightChannelOffset) = sample1 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 8-bit mono source, 16-bit mono output // 8-bit mono source, 16-bit mono output
void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length) void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{ {
@ -165,56 +115,6 @@ void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint
MV_MixDestination = (char *) dest; MV_MixDestination = (char *) dest;
} }
// 16-bit mono source, 8-bit mono output
void MV_Mix8BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
int8_t const * const source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0;
while (length--) {
sample0 = source[(position >> 16) << 1];
position += rate;
sample0 = MV_LeftVolume[sample0 + 128] + *dest;
sample0 = MV_HarshClipTable[sample0 + 128];
*dest = sample0 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 16-bit mono source, 8-bit stereo output
void MV_Mix8BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
int8_t const * const source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0, sample1;
while (length--) {
sample0 = source[(position >> 16) << 1];
sample1 = sample0;
position += rate;
sample0 = MV_LeftVolume[sample0 + 128] + *dest;
sample1 = MV_RightVolume[sample1 + 128] + *(dest + MV_RightChannelOffset);
sample0 = MV_HarshClipTable[sample0 + 128];
sample1 = MV_HarshClipTable[sample1 + 128];
*dest = sample0 & 255;
*(dest + MV_RightChannelOffset) = sample1 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 16-bit mono source, 16-bit stereo output // 16-bit mono source, 16-bit stereo output
void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length) void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{ {
@ -278,13 +178,3 @@ void MV_16BitReverb(char const *src, char *dest, int16_t *volume, int32_t count)
*output++ = (int16_t) (sample0l + sample0h + 128); *output++ = (int16_t) (sample0l + sample0h + 128);
} while (--count > 0); } while (--count > 0);
} }
void MV_8BitReverb(int8_t *src, int8_t *dest, int16_t *volume, int32_t count)
{
uint8_t const * input = (uint8_t *) src;
uint8_t * output = (uint8_t *) dest;
do {
*output++ = ((int16_t *) volume)[*input++] + 128;
} while (--count > 0);
}

View file

@ -30,57 +30,6 @@
length = count of samples to mix length = count of samples to mix
*/ */
// 8-bit stereo source, 8-bit mono output
void MV_Mix8BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0, sample1;
while (length--) {
sample0 = source[(position >> 16) << 1];
sample1 = source[((position >> 16) << 1) + 1];
position += rate;
sample0 = (MV_LeftVolume[sample0] + MV_LeftVolume[sample1]) / 2 + *dest;
sample0 = MV_HarshClipTable[sample0 + 128];
*dest = sample0 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 8-bit stereo source, 8-bit stereo output
void MV_Mix8BitStereo8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0, sample1;
while (length--) {
sample0 = source[(position >> 16) << 1];
sample1 = source[((position >> 16) << 1) + 1];
position += rate;
sample0 = MV_LeftVolume[sample0] + *dest;
sample1 = MV_RightVolume[sample1] + *(dest + MV_RightChannelOffset);
sample0 = MV_HarshClipTable[sample0 + 128];
sample1 = MV_HarshClipTable[sample1 + 128];
*dest = sample0 & 255;
*(dest + MV_RightChannelOffset) = sample1 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 8-bit stereo source, 16-bit mono output // 8-bit stereo source, 16-bit mono output
void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length) void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{ {
@ -179,59 +128,6 @@ void MV_Mix16BitMono16Stereo(uint32_t position, uint32_t rate, const char *start
MV_MixDestination = (char *) dest; MV_MixDestination = (char *) dest;
} }
// 16-bit stereo source, 8-bit mono output
void MV_Mix8BitMono16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
int8_t const * const source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0, sample1;
while (length--) {
sample0 = source[(position >> 16) << 2];
sample1 = source[((position >> 16) << 2) + 2];
position += rate;
sample0 = MV_LeftVolume[sample0 + 128];
sample1 = MV_LeftVolume[sample1 + 128];
sample0 = (sample0 + sample1) / 2 + *dest;
sample0 = MV_HarshClipTable[sample0 + 128];
*dest = sample0 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 16-bit stereo source, 8-bit stereo output
void MV_Mix8BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
int8_t const * const source = (int8_t *) start + 1;
uint8_t *dest = (uint8_t *) MV_MixDestination;
int32_t sample0, sample1;
while (length--) {
sample0 = source[(position >> 16) << 2];
sample1 = source[((position >> 16) << 2) + 2];
position += rate;
sample0 = MV_LeftVolume[sample0 + 128] + *dest;
sample1 = MV_RightVolume[sample1 + 128] + *(dest + MV_RightChannelOffset);
sample0 = MV_HarshClipTable[sample0 + 128];
sample1 = MV_HarshClipTable[sample1 + 128];
*dest = sample0 & 255;
*(dest + MV_RightChannelOffset) = sample1 & 255;
dest += MV_SampleSize;
}
MV_MixPosition = position;
MV_MixDestination = (char *) dest;
}
// 16-bit stereo source, 16-bit stereo output // 16-bit stereo source, 16-bit stereo output
void MV_Mix16BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length) void MV_Mix16BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{ {

View file

@ -52,7 +52,6 @@ static VoiceNode *MV_GetVoice(int32_t handle);
static const int16_t *MV_GetVolumeTable(int32_t vol); static const int16_t *MV_GetVolumeTable(int32_t vol);
static void MV_CalcVolume(int32_t MaxLevel);
static void MV_CalcPanTable(void); static void MV_CalcPanTable(void);
#define IS_QUIET(ptr) ((void *)(ptr) == (void *)&MV_VolumeTable[0]) #define IS_QUIET(ptr) ((void *)(ptr) == (void *)&MV_VolumeTable[0])
@ -74,15 +73,11 @@ static int32_t MV_BufferLength;
static int32_t MV_NumberOfBuffers = MV_NUMBEROFBUFFERS; static int32_t MV_NumberOfBuffers = MV_NUMBEROFBUFFERS;
static int32_t MV_Channels = 1; static int32_t MV_Channels = 1;
static int32_t MV_Bits = 8;
static int32_t MV_Silence = SILENCE_8BIT; static int32_t MV_ReverseStereo = FALSE;
static int32_t MV_SwapLeftRight = FALSE;
int32_t MV_MixRate; int32_t MV_MixRate;
// static int32_t MV_BuffShift;
static int32_t MV_BufferEmpty[MV_NUMBEROFBUFFERS]; static int32_t MV_BufferEmpty[MV_NUMBEROFBUFFERS];
char *MV_MixBuffer[MV_NUMBEROFBUFFERS + 1]; char *MV_MixBuffer[MV_NUMBEROFBUFFERS + 1];
@ -95,9 +90,7 @@ static int32_t MV_MixPage = 0;
void (*MV_Printf)(const char *fmt, ...) = NULL; void (*MV_Printf)(const char *fmt, ...) = NULL;
static void (*MV_CallBackFunc)(uint32_t) = NULL; static void (*MV_CallBackFunc)(uint32_t) = NULL;
static void (*MV_MixFunction)(VoiceNode *voice, int32_t buffer);
char *MV_HarshClipTable;
char *MV_MixDestination; char *MV_MixDestination;
const int16_t *MV_LeftVolume; const int16_t *MV_LeftVolume;
const int16_t *MV_RightVolume; const int16_t *MV_RightVolume;
@ -122,15 +115,6 @@ static inline void RestoreInterrupts(void)
SoundDriver_Unlock(); SoundDriver_Unlock();
} }
static inline void ClearBuffer_DW(void *ptr, unsigned data, int32_t length)
{
unsigned *ptrdw = (unsigned *)ptr;
while (length--)
{
*(ptrdw++) = data;
}
}
const char *MV_ErrorString(int32_t ErrorNumber) const char *MV_ErrorString(int32_t ErrorNumber)
{ {
switch (ErrorNumber) switch (ErrorNumber)
@ -168,7 +152,7 @@ static void MV_Mix(VoiceNode *voice, int32_t buffer)
{ {
/* cheap fix for a crash under 64-bit linux */ /* cheap fix for a crash under 64-bit linux */
/* v v v v */ /* v v v v */
if (voice->length == 0 && (!voice->GetSound || voice->GetSound(voice) != KeepPlaying)) if (voice->length == 0 && (voice->GetSound == NULL || voice->GetSound(voice) != KeepPlaying))
return; return;
int32_t length = MV_MIXBUFFERSIZE; int32_t length = MV_MIXBUFFERSIZE;
@ -282,7 +266,7 @@ static void MV_ServiceVoc(void)
//buffer even when no sounds are playing. //buffer even when no sounds are playing.
if (!MV_BufferEmpty[MV_MixPage]) if (!MV_BufferEmpty[MV_MixPage])
{ {
ClearBuffer_DW(MV_MixBuffer[ MV_MixPage ], MV_Silence, MV_BufferSize >> 2); Bmemset(MV_MixBuffer[MV_MixPage], 0, MV_BufferSize);
MV_BufferEmpty[ MV_MixPage ] = TRUE; MV_BufferEmpty[ MV_MixPage ] = TRUE;
} }
} }
@ -301,10 +285,7 @@ static void MV_ServiceVoc(void)
{ {
int const count = (source + length > end) ? (end - source) : length; int const count = (source + length > end) ? (end - source) : length;
if (MV_Bits == 16)
MV_16BitReverb(source, dest, MV_ReverbTable, count / 2); MV_16BitReverb(source, dest, MV_ReverbTable, count / 2);
else // if (MV_Bits == 8)
MV_8BitReverb((int8_t *) source, (int8_t *) dest, MV_ReverbTable, count);
// if we go through the loop again, it means that we've wrapped around the buffer // if we go through the loop again, it means that we've wrapped around the buffer
source = MV_MixBuffer[ 0 ]; source = MV_MixBuffer[ 0 ];
@ -337,7 +318,7 @@ static void MV_ServiceVoc(void)
MV_BufferEmpty[ MV_MixPage ] = FALSE; MV_BufferEmpty[ MV_MixPage ] = FALSE;
MV_MixFunction(voice, MV_MixPage); MV_Mix(voice, MV_MixPage);
// Is this voice done? // Is this voice done?
if (!voice->Playing) if (!voice->Playing)
@ -606,37 +587,25 @@ static const inline int16_t *MV_GetVolumeTable(int32_t vol) { return MV_VolumeTa
Selects which method should be used to mix the voice. Selects which method should be used to mix the voice.
8Bit 16Bit 8Bit 16Bit | 8Bit 16Bit 8Bit 16Bit | 16Bit 16Bit | 8Bit 16Bit 8Bit 16Bit |
Mono Mono Ster Ster | Mono Mono Ster Ster | Mixer Mono Ster | Mono Mono Ster Ster | Mixer
Out Out Out Out | In In In In | Out Out | In In In In |
--------------------------+---------------------------+------------- ----------------------+---------------------------+-------------
X | X | Mix8BitMono16
X | X | Mix8BitMono
X | X | Mix8BitStereo16
X | X | Mix8BitStereo
X | X | Mix16BitMono16 X | X | Mix16BitMono16
X | X | Mix16BitMono X | X | Mix16BitMono
X | X | Mix16BitStereo16 X | X | Mix16BitStereo16
X | X | Mix16BitStereo X | X | Mix16BitStereo
--------------------------+---------------------------+------------- ----------------------+---------------------------+-------------
X | X | Mix16BitStereo16Stereo X | X | Mix16BitStereo16Stereo
X | X | Mix16BitStereo8Stereo X | X | Mix16BitStereo8Stereo
X | X | Mix8BitStereo16Stereo
X | X | Mix8BitStereo8Stereo
X | X | Mix16BitMono16Stereo X | X | Mix16BitMono16Stereo
X | X | Mix16BitMono8Stereo X | X | Mix16BitMono8Stereo
X | X | Mix8BitMono16Stereo
X | X | Mix8BitMono8Stereo
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
void MV_SetVoiceMixMode(VoiceNode *voice) void MV_SetVoiceMixMode(VoiceNode *voice)
{ {
int32_t type = T_DEFAULT; int32_t type = T_DEFAULT;
if (MV_Bits == 8)
type |= T_8BITS;
if (MV_Channels == 1) if (MV_Channels == 1)
type |= T_MONO; type |= T_MONO;
else else
@ -658,18 +627,6 @@ void MV_SetVoiceMixMode(VoiceNode *voice)
switch (type) switch (type)
{ {
case T_8BITS | T_16BITSOURCE | T_LEFTQUIET: MV_LeftVolume = MV_RightVolume;
case T_8BITS | T_16BITSOURCE | T_MONO:
case T_8BITS | T_16BITSOURCE | T_RIGHTQUIET: voice->mix = MV_Mix8BitMono16; break;
case T_8BITS | T_LEFTQUIET: MV_LeftVolume = MV_RightVolume;
case T_8BITS | T_MONO:
case T_8BITS | T_RIGHTQUIET: voice->mix = MV_Mix8BitMono; break;
case T_8BITS | T_16BITSOURCE: voice->mix = MV_Mix8BitStereo16; break;
case T_8BITS: voice->mix = MV_Mix8BitStereo; break;
case T_16BITSOURCE | T_LEFTQUIET: MV_LeftVolume = MV_RightVolume; case T_16BITSOURCE | T_LEFTQUIET: MV_LeftVolume = MV_RightVolume;
case T_16BITSOURCE | T_MONO: case T_16BITSOURCE | T_MONO:
case T_16BITSOURCE | T_RIGHTQUIET: voice->mix = MV_Mix16BitMono16; break; case T_16BITSOURCE | T_RIGHTQUIET: voice->mix = MV_Mix16BitMono16; break;
@ -684,20 +641,12 @@ void MV_SetVoiceMixMode(VoiceNode *voice)
case T_16BITSOURCE | T_STEREOSOURCE: voice->mix = MV_Mix16BitStereo16Stereo; break; case T_16BITSOURCE | T_STEREOSOURCE: voice->mix = MV_Mix16BitStereo16Stereo; break;
case T_16BITSOURCE | T_STEREOSOURCE | T_8BITS: voice->mix = MV_Mix8BitStereo16Stereo; break;
case T_16BITSOURCE | T_STEREOSOURCE | T_MONO: voice->mix = MV_Mix16BitMono16Stereo; break; case T_16BITSOURCE | T_STEREOSOURCE | T_MONO: voice->mix = MV_Mix16BitMono16Stereo; break;
case T_16BITSOURCE | T_STEREOSOURCE | T_8BITS | T_MONO: voice->mix = MV_Mix8BitMono16Stereo; break;
case T_STEREOSOURCE: voice->mix = MV_Mix16BitStereo8Stereo; break; case T_STEREOSOURCE: voice->mix = MV_Mix16BitStereo8Stereo; break;
case T_STEREOSOURCE | T_8BITS: voice->mix = MV_Mix8BitStereo8Stereo; break;
case T_STEREOSOURCE | T_MONO: voice->mix = MV_Mix16BitMono8Stereo; break; case T_STEREOSOURCE | T_MONO: voice->mix = MV_Mix16BitMono8Stereo; break;
case T_STEREOSOURCE | T_8BITS | T_MONO: voice->mix = MV_Mix8BitMono8Stereo; break;
default: voice->mix = NULL; break; default: voice->mix = NULL; break;
} }
} }
@ -715,7 +664,7 @@ void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t righ
{ {
voice->RightVolume = MV_GetVolumeTable(right); voice->RightVolume = MV_GetVolumeTable(right);
if (MV_SwapLeftRight) if (MV_ReverseStereo)
swapptr(&voice->LeftVolume, &voice->RightVolume); swapptr(&voice->LeftVolume, &voice->RightVolume);
} }
@ -843,33 +792,13 @@ void MV_SetReverbDelay(int32_t delay)
MV_ReverbDelay = max(MV_MIXBUFFERSIZE, min(delay, MV_GetMaxReverbDelay())) * MV_SampleSize; MV_ReverbDelay = max(MV_MIXBUFFERSIZE, min(delay, MV_GetMaxReverbDelay())) * MV_SampleSize;
} }
static int32_t MV_SetMixMode(int32_t numchannels, int32_t samplebits) static int32_t MV_SetMixMode(int32_t numchannels)
{ {
if (!MV_Installed) if (!MV_Installed)
return MV_Error; return MV_Error;
int32_t mode = 0; MV_Channels = 1 + (numchannels == 2);
MV_SampleSize = sizeof(int8_t) * MV_Channels * 2;
if (numchannels == 2)
mode |= STEREO;
if (samplebits == 16)
mode |= SIXTEEN_BIT;
MV_Channels = 1 + (mode & STEREO);
MV_SampleSize = sizeof(int8_t) * MV_Channels;
if (mode & SIXTEEN_BIT)
{
MV_Bits = 16;
MV_Silence = SILENCE_16BIT;
MV_SampleSize <<= 1;
}
else
{
MV_Bits = 8;
MV_Silence = SILENCE_8BIT;
}
MV_BufferSize = MV_MIXBUFFERSIZE * MV_SampleSize; MV_BufferSize = MV_MIXBUFFERSIZE * MV_SampleSize;
MV_NumberOfBuffers = MV_TOTALBUFFERSIZE / MV_BufferSize; MV_NumberOfBuffers = MV_TOTALBUFFERSIZE / MV_BufferSize;
@ -883,18 +812,14 @@ static int32_t MV_SetMixMode(int32_t numchannels, int32_t samplebits)
static int32_t MV_StartPlayback(void) static int32_t MV_StartPlayback(void)
{ {
// Initialize the buffers // Initialize the buffers
ClearBuffer_DW(MV_MixBuffer[ 0 ], MV_Silence, MV_TOTALBUFFERSIZE >> 2); Bmemset(MV_MixBuffer[0], 0, MV_TOTALBUFFERSIZE);
for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++) for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++)
MV_BufferEmpty[ buffer ] = TRUE; MV_BufferEmpty[buffer] = TRUE;
MV_MixPage = 1; MV_MixPage = 1;
MV_MixFunction = MV_Mix; if (SoundDriver_BeginPlayback(MV_MixBuffer[0], MV_BufferSize, MV_NumberOfBuffers, MV_ServiceVoc) != MV_Ok)
int status = SoundDriver_BeginPlayback(MV_MixBuffer[0], MV_BufferSize, MV_NumberOfBuffers, MV_ServiceVoc);
if (status != MV_Ok)
{ {
MV_SetErrorCode(MV_DriverError); MV_SetErrorCode(MV_DriverError);
return MV_Error; return MV_Error;
@ -925,38 +850,18 @@ static void MV_StopPlayback(void)
RestoreInterrupts(); RestoreInterrupts();
} }
static void MV_CreateVolumeTable(int32_t index, int32_t volume, int32_t MaxVolume)
{
int const level = (volume * MaxVolume) / MV_MAXTOTALVOLUME;
if (MV_Bits == 16)
{
for (int i = 0; i < 65536; i += 256)
MV_VolumeTable[ index ][ i / 256 ] = ((i - 0x8000) * level) / MV_MAXVOLUME;
}
else
{
for (int i = 0; i < 256; i++)
MV_VolumeTable[ volume ][ i ] = ((i - 0x80) * level) / MV_MAXVOLUME;
}
}
static void MV_CalcVolume(int32_t MaxVolume) static void MV_CalcVolume(int32_t MaxVolume)
{ {
for (int volume = 0; volume < 128; volume++)
{
MV_HarshClipTable[volume] = 0;
MV_HarshClipTable[volume + 384] = 255;
}
for (int volume = 0; volume < 256; volume++)
MV_HarshClipTable[volume + 128] = volume;
// For each volume level, create a translation table with the // For each volume level, create a translation table with the
// appropriate volume calculated. // appropriate volume calculated.
for (int volume = 0; volume <= MV_MAXVOLUME; volume++) for (int volume = 0; volume <= MV_MAXVOLUME; volume++)
MV_CreateVolumeTable(volume, volume, MaxVolume); {
int const level = (volume * MaxVolume) / MV_MAXTOTALVOLUME;
for (int i = 0; i < 65536; i += 256)
MV_VolumeTable[volume][i / 256] = ((i - 0x8000) * level) / MV_MAXVOLUME;
}
} }
static void MV_CalcPanTable(void) static void MV_CalcPanTable(void)
@ -997,11 +902,11 @@ int32_t MV_GetVolume(void) { return MV_TotalVolume; }
void MV_SetCallBack(void (*function)(uint32_t)) { MV_CallBackFunc = function; } void MV_SetCallBack(void (*function)(uint32_t)) { MV_CallBackFunc = function; }
void MV_SetReverseStereo(int32_t setting) { MV_SwapLeftRight = setting; } void MV_SetReverseStereo(int32_t setting) { MV_ReverseStereo = setting; }
int32_t MV_GetReverseStereo(void) { return MV_SwapLeftRight; } int32_t MV_GetReverseStereo(void) { return MV_ReverseStereo; }
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, int32_t samplebits, void *initdata) int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, void *initdata)
{ {
if (MV_Installed) if (MV_Installed)
MV_Shutdown(); MV_Shutdown();
@ -1009,7 +914,7 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
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) + sizeof(HARSH_CLIP_TABLE_8) + MV_TOTALBUFFERSIZE + 2; int const totalmem = Voices * sizeof(VoiceNode) + MV_TOTALBUFFERSIZE + 2;
char *ptr = (char *) Xaligned_alloc(16, totalmem); char *ptr = (char *) Xaligned_alloc(16, totalmem);
@ -1024,9 +929,6 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
MV_Voices = (VoiceNode *)ptr; MV_Voices = (VoiceNode *)ptr;
ptr += Voices * sizeof(VoiceNode); ptr += Voices * sizeof(VoiceNode);
MV_HarshClipTable = ptr;
ptr += sizeof(HARSH_CLIP_TABLE_8);
// Set number of voices before calculating volume table // Set number of voices before calculating volume table
MV_MaxVoices = Voices; MV_MaxVoices = Voices;
@ -1043,19 +945,14 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
ASS_SoundDriver = soundcard; ASS_SoundDriver = soundcard;
// Initialize the sound card // Initialize the sound card
int32_t status = SoundDriver_Init(&MixRate, &numchannels, &samplebits, initdata);
if (status != MV_Ok) if (SoundDriver_Init(&MixRate, &numchannels, initdata) != MV_Ok)
MV_SetErrorCode(MV_DriverError); MV_SetErrorCode(MV_DriverError);
if (MV_ErrorCode != MV_Ok) if (MV_ErrorCode != MV_Ok)
{ {
status = MV_ErrorCode;
ALIGNED_FREE_AND_NULL(MV_Voices); ALIGNED_FREE_AND_NULL(MV_Voices);
MV_HarshClipTable = NULL;
MV_SetErrorCode(status);
return MV_Error; return MV_Error;
} }
@ -1068,7 +965,7 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
MV_MixRate = MixRate; MV_MixRate = MixRate;
// Set Mixer to play stereo digitized sound // Set Mixer to play stereo digitized sound
MV_SetMixMode(numchannels, samplebits); MV_SetMixMode(numchannels);
MV_ReverbDelay = MV_BufferSize * 3; MV_ReverbDelay = MV_BufferSize * 3;
// Make sure we don't cross a physical page // Make sure we don't cross a physical page
@ -1085,11 +982,10 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
MV_SetVolume(MV_MAXTOTALVOLUME); MV_SetVolume(MV_MAXTOTALVOLUME);
// Start the playback engine // Start the playback engine
status = MV_StartPlayback(); if (MV_StartPlayback() != MV_Ok)
if (status != MV_Ok)
{ {
// Preserve error code while we shutdown. // Preserve error code while we shutdown.
status = MV_ErrorCode; int status = MV_ErrorCode;
MV_Shutdown(); MV_Shutdown();
MV_SetErrorCode(status); MV_SetErrorCode(status);
return MV_Error; return MV_Error;

View file

@ -161,7 +161,7 @@ int32_t MV_GetVolume(void);
void MV_SetCallBack(void (*function)(uint32_t)); void MV_SetCallBack(void (*function)(uint32_t));
void MV_SetReverseStereo(int32_t setting); void MV_SetReverseStereo(int32_t setting);
int32_t MV_GetReverseStereo(void); int32_t MV_GetReverseStereo(void);
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, int32_t samplebits, int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels,
void *initdata); void *initdata);
int32_t MV_Shutdown(void); int32_t MV_Shutdown(void);
int32_t MV_SetVoiceCallback(int32_t handle, uint32_t callbackval); int32_t MV_SetVoiceCallback(int32_t handle, uint32_t callbackval);

View file

@ -474,6 +474,10 @@ void MV_ReleaseVorbisVoice( VoiceNode * voice )
voice->rawdataptr = 0; voice->rawdataptr = 0;
} }
#else #else
#include <stdlib.h>
#include <stdio.h>
#include "_multivc.h"
int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopend, int32_t pitchoffset,
int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval) int32_t vol, int32_t left, int32_t right, int32_t priority, uint32_t callbackval)
{ {

View file

@ -958,7 +958,7 @@ static MenuEntry_t ME_SAVE_TEMPLATE = MAKE_MENUENTRY( NULL, &MF_MinifontRed, &ME
static MenuEntry_t ME_SAVE[MAXSAVEGAMES]; static MenuEntry_t ME_SAVE[MAXSAVEGAMES];
static MenuEntry_t *MEL_SAVE[MAXSAVEGAMES]; static MenuEntry_t *MEL_SAVE[MAXSAVEGAMES];
static int32_t soundrate, soundbits, soundvoices; static int32_t soundrate, soundvoices;
static MenuOption_t MEO_SOUND = MAKE_MENUOPTION( &MF_Redfont, &MEOS_OffOn, &ud.config.SoundToggle ); static MenuOption_t MEO_SOUND = MAKE_MENUOPTION( &MF_Redfont, &MEOS_OffOn, &ud.config.SoundToggle );
static MenuEntry_t ME_SOUND = MAKE_MENUENTRY( "Sound:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND, Option ); static MenuEntry_t ME_SOUND = MAKE_MENUENTRY( "Sound:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND, Option );
@ -983,12 +983,6 @@ static MenuOptionSet_t MEOS_SOUND_SAMPLINGRATE = MAKE_MENUOPTIONSET( MEOSN_SOUND
static MenuOption_t MEO_SOUND_SAMPLINGRATE = MAKE_MENUOPTION( &MF_Redfont, &MEOS_SOUND_SAMPLINGRATE, &soundrate ); static MenuOption_t MEO_SOUND_SAMPLINGRATE = MAKE_MENUOPTION( &MF_Redfont, &MEOS_SOUND_SAMPLINGRATE, &soundrate );
static MenuEntry_t ME_SOUND_SAMPLINGRATE = MAKE_MENUENTRY( "Sample rate:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_SAMPLINGRATE, Option ); static MenuEntry_t ME_SOUND_SAMPLINGRATE = MAKE_MENUENTRY( "Sample rate:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_SAMPLINGRATE, Option );
static char *MEOSN_SOUND_SAMPLESIZE[] = { "8-bit", "16-bit", };
static int32_t MEOSV_SOUND_SAMPLESIZE[] = { 8, 16, };
static MenuOptionSet_t MEOS_SOUND_SAMPLESIZE = MAKE_MENUOPTIONSET( MEOSN_SOUND_SAMPLESIZE, MEOSV_SOUND_SAMPLESIZE, 0x3 );
static MenuOption_t MEO_SOUND_SAMPLESIZE = MAKE_MENUOPTION( &MF_Redfont, &MEOS_SOUND_SAMPLESIZE, &soundbits );
static MenuEntry_t ME_SOUND_SAMPLESIZE = MAKE_MENUENTRY( "Sample size:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_SAMPLESIZE, Option );
static MenuRangeInt32_t MEO_SOUND_NUMVOICES = MAKE_MENURANGE( &soundvoices, &MF_Redfont, 16, 256, 0, 16, 1 ); static MenuRangeInt32_t MEO_SOUND_NUMVOICES = MAKE_MENURANGE( &soundvoices, &MF_Redfont, 16, 256, 0, 16, 1 );
static MenuEntry_t ME_SOUND_NUMVOICES = MAKE_MENUENTRY( "Voices:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_NUMVOICES, RangeInt32 ); static MenuEntry_t ME_SOUND_NUMVOICES = MAKE_MENUENTRY( "Voices:", &MF_Redfont, &MEF_BigOptionsRt, &MEO_SOUND_NUMVOICES, RangeInt32 );
@ -1015,7 +1009,6 @@ static MenuEntry_t *MEL_SOUND[] = {
static MenuEntry_t *MEL_ADVSOUND[] = { static MenuEntry_t *MEL_ADVSOUND[] = {
&ME_SOUND_SAMPLINGRATE, &ME_SOUND_SAMPLINGRATE,
&ME_SOUND_SAMPLESIZE,
&ME_Space2, &ME_Space2,
&ME_SOUND_NUMVOICES, &ME_SOUND_NUMVOICES,
&ME_Space2, &ME_Space2,
@ -1639,11 +1632,9 @@ static void M_PreMenu(MenuID_t cm)
MenuEntry_DisableOnCondition(&ME_SOUND_VOLUME_MUSIC, !ud.config.MusicToggle); MenuEntry_DisableOnCondition(&ME_SOUND_VOLUME_MUSIC, !ud.config.MusicToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_DUKETALK, !ud.config.SoundToggle); MenuEntry_DisableOnCondition(&ME_SOUND_DUKETALK, !ud.config.SoundToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_SAMPLINGRATE, !ud.config.SoundToggle && !ud.config.MusicToggle); MenuEntry_DisableOnCondition(&ME_SOUND_SAMPLINGRATE, !ud.config.SoundToggle && !ud.config.MusicToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_SAMPLESIZE, !ud.config.SoundToggle && !ud.config.MusicToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_NUMVOICES, !ud.config.SoundToggle); MenuEntry_DisableOnCondition(&ME_SOUND_NUMVOICES, !ud.config.SoundToggle);
MenuEntry_DisableOnCondition(&ME_SOUND_RESTART, soundrate == ud.config.MixRate && MenuEntry_DisableOnCondition(&ME_SOUND_RESTART, soundrate == ud.config.MixRate &&
soundvoices == ud.config.NumVoices && soundvoices == ud.config.NumVoices);
soundbits == ud.config.NumBits);
break; break;
case MENU_MOUSESETUP: case MENU_MOUSESETUP:
@ -2588,7 +2579,6 @@ static void M_MenuEntryLinkActivate(MenuEntry_t *entry)
{ {
ud.config.MixRate = soundrate; ud.config.MixRate = soundrate;
ud.config.NumVoices = soundvoices; ud.config.NumVoices = soundvoices;
ud.config.NumBits = soundbits;
S_SoundShutdown(); S_SoundShutdown();
S_MusicShutdown(); S_MusicShutdown();
@ -3398,7 +3388,6 @@ void M_ChangeMenu(MenuID_t cm)
case MENU_ADVSOUND: case MENU_ADVSOUND:
soundrate = ud.config.MixRate; soundrate = ud.config.MixRate;
soundvoices = ud.config.NumVoices; soundvoices = ud.config.NumVoices;
soundbits = ud.config.NumBits;
break; break;
default: default:

View file

@ -1632,7 +1632,6 @@ int32_t registerosdcommands(void)
{ "snd_mastervolume", "master volume for sound system", (void *)&ud.config.MasterVolume, CVAR_INT, 0, 255 }, { "snd_mastervolume", "master volume for sound system", (void *)&ud.config.MasterVolume, CVAR_INT, 0, 255 },
{ "snd_fxvolume", "volume of sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 1, 255 }, { "snd_fxvolume", "volume of sound effects", (void *)&ud.config.FXVolume, CVAR_INT, 1, 255 },
{ "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 }, { "snd_mixrate", "sound mixing rate", (void *)&ud.config.MixRate, CVAR_INT, 0, 48000 },
{ "snd_numbits", "sound bits", (void *)&ud.config.NumBits, CVAR_INT, 8, 16 },
{ "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 }, { "snd_numchannels", "the number of sound channels", (void *)&ud.config.NumChannels, CVAR_INT, 0, 2 },
{ "snd_numvoices", "the number of concurrent sounds", (void *)&ud.config.NumVoices, CVAR_INT, 0, 256 }, { "snd_numvoices", "the number of concurrent sounds", (void *)&ud.config.NumVoices, CVAR_INT, 0, 256 },
{ "snd_reversestereo", "reverses the stereo channels", (void *)&ud.config.ReverseStereo, CVAR_BOOL, 0, 16 }, { "snd_reversestereo", "reverses the stereo channels", (void *)&ud.config.ReverseStereo, CVAR_BOOL, 0, 16 },

View file

@ -64,7 +64,7 @@ void S_SoundStartup(void)
initprintf("Initializing sound... "); initprintf("Initializing sound... ");
if (FX_Init(ASS_AutoDetect, ud.config.NumVoices, ud.config.NumChannels, ud.config.NumBits, ud.config.MixRate, initdata) != FX_Ok) if (FX_Init(ASS_AutoDetect, ud.config.NumVoices, ud.config.NumChannels, ud.config.MixRate, initdata) != FX_Ok)
{ {
initprintf("failed! %s\n", FX_ErrorString(FX_Error)); initprintf("failed! %s\n", FX_ErrorString(FX_Error));
return; return;

View file

@ -77,7 +77,7 @@ int32_t S_SoundStartup(void)
void *initdata = 0; void *initdata = 0;
// TODO: read config // TODO: read config
int32_t FXVolume=220, /*NumVoices=32,*/ NumChannels=2, NumBits=16, ReverseStereo=0; int32_t FXVolume=220, /*NumVoices=32,*/ NumChannels=2, ReverseStereo=0;
fxdevicetype = ASS_AutoDetect; fxdevicetype = ASS_AutoDetect;
@ -85,15 +85,14 @@ int32_t S_SoundStartup(void)
initdata = (void *) win_gethwnd(); // used for DirectSound initdata = (void *) win_gethwnd(); // used for DirectSound
#endif #endif
status = FX_Init(fxdevicetype, NumVoices, NumChannels, NumBits, MixRate, initdata); status = FX_Init(fxdevicetype, NumVoices, NumChannels, MixRate, initdata);
if (status == FX_Ok) if (status == FX_Ok)
{ {
FX_SetVolume(FXVolume); FX_SetVolume(FXVolume);
FX_SetReverseStereo(ReverseStereo); FX_SetReverseStereo(ReverseStereo);
status = FX_SetCallBack(S_Callback); FX_SetCallBack(S_Callback);
} }
else
if (status != FX_Ok)
{ {
initprintf("Sound startup error: %s\n", FX_ErrorString(FX_Error)); initprintf("Sound startup error: %s\n", FX_ErrorString(FX_Error));
return -2; return -2;