mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 08:52:00 +00:00
Audiolib rework WIP
This attempts to rectify the differences between versions of JFAudiolib created after we forked the code, and the extra features contained in Nuke.YKT's fork of our version. git-svn-id: https://svn.eduke32.com/eduke32@8216 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # GNUmakefile # platform/Windows/audiolib.vcxproj # platform/Windows/audiolib.vcxproj.filters # platform/Windows/eduke32.vcxproj # platform/Windows/eduke32.vcxproj.filters # source/audiolib/include/fx_man.h # source/audiolib/include/multivoc.h # source/audiolib/src/flac.cpp # source/audiolib/src/formats.cpp # source/audiolib/src/fx_man.cpp # source/audiolib/src/vorbis.cpp # source/audiolib/src/xa.cpp # source/audiolib/src/xmp.cpp # source/duke3d/src/sounds_mapster32.cpp # Conflicts: # Common.mak # GNUmakefile # platform/Windows/audiolib.vcxproj # platform/Windows/audiolib.vcxproj.filters # platform/Windows/eduke32.vcxproj # platform/Windows/eduke32.vcxproj.filters # source/audiolib/include/multivoc.h # source/audiolib/src/vorbis.cpp # source/duke3d/src/config.cpp # source/duke3d/src/game.h # source/duke3d/src/osdcmds.cpp # source/duke3d/src/sounds_mapster32.cpp
This commit is contained in:
parent
a1f08f2465
commit
8b20118026
21 changed files with 719 additions and 610 deletions
|
@ -21,30 +21,36 @@
|
|||
#ifndef DRIVERS_H
|
||||
#define DRIVERS_H
|
||||
|
||||
#include "inttypes.h"
|
||||
#include "sndcards.h"
|
||||
#include "midifuncs.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ASS_NoSound,
|
||||
#if defined MIXERTYPEWIN
|
||||
ASS_DirectSound,
|
||||
#elif defined MIXERTYPESDL
|
||||
ASS_SDL,
|
||||
#endif
|
||||
ASS_NumSoundCards,
|
||||
} soundcardnames;
|
||||
extern int ASS_PCMSoundDriver;
|
||||
extern int ASS_CDSoundDriver;
|
||||
extern int ASS_MIDISoundDriver;
|
||||
|
||||
extern int32_t ASS_SoundDriver;
|
||||
int SoundDriver_IsPCMSupported(int driver);
|
||||
int SoundDriver_IsMIDISupported(int driver);
|
||||
|
||||
int32_t SoundDriver_IsSupported(int32_t driver);
|
||||
const char *SoundDriver_GetName(int driver);
|
||||
|
||||
int32_t SoundDriver_GetError(void);
|
||||
const char *SoundDriver_ErrorString(int32_t ErrorNumber);
|
||||
int32_t SoundDriver_Init(int32_t *mixrate, int32_t *numchannels, void *initdata);
|
||||
void SoundDriver_Shutdown(void);
|
||||
int32_t SoundDriver_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t NumDivisions, void(*CallBackFunc)(void));
|
||||
void SoundDriver_StopPlayback(void);
|
||||
void SoundDriver_Lock(void);
|
||||
void SoundDriver_Unlock(void);
|
||||
int SoundDriver_PCM_GetError(void);
|
||||
const char *SoundDriver_PCM_ErrorString(int ErrorNumber);
|
||||
int SoundDriver_MIDI_GetError(void);
|
||||
const char *SoundDriver_MIDI_ErrorString(int ErrorNumber);
|
||||
|
||||
int SoundDriver_PCM_Init(int *mixrate, int *numchannels, void *initdata);
|
||||
void SoundDriver_PCM_Shutdown(void);
|
||||
int SoundDriver_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)(void));
|
||||
void SoundDriver_PCM_StopPlayback(void);
|
||||
void SoundDriver_PCM_Lock(void);
|
||||
void SoundDriver_PCM_Unlock(void);
|
||||
|
||||
int SoundDriver_MIDI_Init(midifuncs *);
|
||||
void SoundDriver_MIDI_Shutdown(void);
|
||||
int SoundDriver_MIDI_StartPlayback(void (*service)(void));
|
||||
void SoundDriver_MIDI_HaltPlayback(void);
|
||||
void SoundDriver_MIDI_SetTempo(int tempo, int division);
|
||||
void SoundDriver_MIDI_Lock(void);
|
||||
void SoundDriver_MIDI_Unlock(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,28 +53,28 @@ enum FX_LOOP_HOW
|
|||
|
||||
#define FX_MUSIC_PRIORITY INT_MAX
|
||||
|
||||
const char *FX_ErrorString(int32_t ErrorNumber);
|
||||
int32_t FX_Init(int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata);
|
||||
int32_t FX_Shutdown(void);
|
||||
const char *FX_ErrorString(int ErrorNumber);
|
||||
int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata);
|
||||
int FX_Shutdown(void);
|
||||
|
||||
|
||||
|
||||
int32_t FX_Play(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, float volume, intptr_t callbackval);
|
||||
int32_t FX_Play3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle,
|
||||
int32_t distance, int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t FX_PlayRaw(char *ptr, uint32_t ptrlength, int32_t rate, int32_t pitchoffset, int32_t vol,
|
||||
int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loopend, int32_t rate,
|
||||
int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval);
|
||||
int FX_Play(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitchoffset,
|
||||
int vol, int left, int right, int priority, float volume, intptr_t callbackval);
|
||||
int FX_Play3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int angle,
|
||||
int distance, int priority, float volume, intptr_t callbackval);
|
||||
int FX_PlayRaw(char *ptr, uint32_t ptrlength, int rate, int pitchoffset, int vol,
|
||||
int left, int right, int priority, float volume, intptr_t callbackval);
|
||||
int FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loopend, int rate,
|
||||
int pitchoffset, int vol, int left, int right, int priority, float volume, intptr_t callbackval);
|
||||
|
||||
|
||||
int32_t FX_SetPrintf(void(*function)(const char *, ...));
|
||||
int FX_SetPrintf(void(*function)(const char *, ...));
|
||||
|
||||
extern int32_t FX_ErrorCode;
|
||||
extern int FX_ErrorCode;
|
||||
#define FX_SetErrorCode(status) FX_ErrorCode = (status);
|
||||
|
||||
static FORCE_INLINE int FX_CheckMVErr(int32_t status)
|
||||
static FORCE_INLINE int FX_CheckMVErr(int status)
|
||||
{
|
||||
if (status != MV_Ok)
|
||||
{
|
||||
|
@ -86,32 +86,32 @@ static FORCE_INLINE int FX_CheckMVErr(int32_t status)
|
|||
}
|
||||
|
||||
static FORCE_INLINE void FX_SetCallBack(void(*function)(intptr_t)) { MV_SetCallBack(function); }
|
||||
static FORCE_INLINE void FX_SetVolume(int32_t volume) { MV_SetVolume(volume); }
|
||||
static FORCE_INLINE int32_t FX_GetVolume(void) { return MV_GetVolume(); }
|
||||
static FORCE_INLINE void FX_SetReverseStereo(int32_t setting) { MV_SetReverseStereo(setting); }
|
||||
static FORCE_INLINE int32_t FX_GetReverseStereo(void) { return MV_GetReverseStereo(); }
|
||||
static FORCE_INLINE void FX_SetReverb(int32_t reverb) { MV_SetReverb(reverb); }
|
||||
static FORCE_INLINE int32_t FX_GetMaxReverbDelay(void) { return MV_GetMaxReverbDelay(); }
|
||||
static FORCE_INLINE int32_t FX_GetReverbDelay(void) { return MV_GetReverbDelay(); }
|
||||
static FORCE_INLINE void FX_SetReverbDelay(int32_t delay) { MV_SetReverbDelay(delay); }
|
||||
static FORCE_INLINE int32_t FX_VoiceAvailable(int32_t priority) { return MV_VoiceAvailable(priority); }
|
||||
static FORCE_INLINE int32_t FX_PauseVoice(int32_t handle, int32_t pause) { return FX_CheckMVErr(MV_PauseVoice(handle, pause)); }
|
||||
static FORCE_INLINE int32_t FX_GetPosition(int32_t handle, int32_t *position) { return FX_CheckMVErr(MV_GetPosition(handle, position)); }
|
||||
static FORCE_INLINE int32_t FX_SetPosition(int32_t handle, int32_t position) { return FX_CheckMVErr(MV_SetPosition(handle, position)); }
|
||||
static FORCE_INLINE int32_t FX_EndLooping(int32_t handle) { return FX_CheckMVErr(MV_EndLooping(handle)); }
|
||||
static FORCE_INLINE int32_t FX_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right)
|
||||
static FORCE_INLINE void FX_SetVolume(int volume) { MV_SetVolume(volume); }
|
||||
static FORCE_INLINE int FX_GetVolume(void) { return MV_GetVolume(); }
|
||||
static FORCE_INLINE void FX_SetReverseStereo(int setting) { MV_SetReverseStereo(setting); }
|
||||
static FORCE_INLINE int FX_GetReverseStereo(void) { return MV_GetReverseStereo(); }
|
||||
static FORCE_INLINE void FX_SetReverb(int reverb) { MV_SetReverb(reverb); }
|
||||
static FORCE_INLINE int FX_GetMaxReverbDelay(void) { return MV_GetMaxReverbDelay(); }
|
||||
static FORCE_INLINE int FX_GetReverbDelay(void) { return MV_GetReverbDelay(); }
|
||||
static FORCE_INLINE void FX_SetReverbDelay(int delay) { MV_SetReverbDelay(delay); }
|
||||
static FORCE_INLINE int FX_VoiceAvailable(int priority) { return MV_VoiceAvailable(priority); }
|
||||
static FORCE_INLINE int FX_PauseVoice(int handle, int pause) { return FX_CheckMVErr(MV_PauseVoice(handle, pause)); }
|
||||
static FORCE_INLINE int FX_GetPosition(int handle, int *position) { return FX_CheckMVErr(MV_GetPosition(handle, position)); }
|
||||
static FORCE_INLINE int FX_SetPosition(int handle, int position) { return FX_CheckMVErr(MV_SetPosition(handle, position)); }
|
||||
static FORCE_INLINE int FX_EndLooping(int handle) { return FX_CheckMVErr(MV_EndLooping(handle)); }
|
||||
static FORCE_INLINE int FX_SetPan(int handle, int vol, int left, int right)
|
||||
{
|
||||
return FX_CheckMVErr(MV_SetPan(handle, vol, left, right));
|
||||
}
|
||||
static FORCE_INLINE int32_t FX_SetPitch(int32_t handle, int32_t pitchoffset) { return FX_CheckMVErr(MV_SetPitch(handle, pitchoffset)); }
|
||||
static FORCE_INLINE int32_t FX_SetFrequency(int32_t handle, int32_t frequency) { return FX_CheckMVErr(MV_SetFrequency(handle, frequency)); }
|
||||
static FORCE_INLINE int32_t FX_Pan3D(int32_t handle, int32_t angle, int32_t distance)
|
||||
static FORCE_INLINE int FX_SetPitch(int handle, int pitchoffset) { return FX_CheckMVErr(MV_SetPitch(handle, pitchoffset)); }
|
||||
static FORCE_INLINE int FX_SetFrequency(int handle, int frequency) { return FX_CheckMVErr(MV_SetFrequency(handle, frequency)); }
|
||||
static FORCE_INLINE int FX_Pan3D(int handle, int angle, int distance)
|
||||
{
|
||||
return FX_CheckMVErr(MV_Pan3D(handle, angle, distance));
|
||||
}
|
||||
static FORCE_INLINE int32_t FX_SoundActive(int32_t handle) { return MV_VoicePlaying(handle); }
|
||||
static FORCE_INLINE int32_t FX_SoundsPlaying(void) { return MV_VoicesPlaying(); }
|
||||
static FORCE_INLINE int32_t FX_StopSound(int32_t handle) { return FX_CheckMVErr(MV_Kill(handle)); }
|
||||
static FORCE_INLINE int32_t FX_StopAllSounds(void) { return FX_CheckMVErr(MV_KillAllVoices()); }
|
||||
static FORCE_INLINE int FX_SoundActive(int handle) { return MV_VoicePlaying(handle); }
|
||||
static FORCE_INLINE int FX_SoundsPlaying(void) { return MV_VoicesPlaying(); }
|
||||
static FORCE_INLINE int FX_StopSound(int handle) { return FX_CheckMVErr(MV_Kill(handle)); }
|
||||
static FORCE_INLINE int FX_StopAllSounds(void) { return FX_CheckMVErr(MV_KillAllVoices()); }
|
||||
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ typedef enum : char
|
|||
|
||||
#define MV_MINVOICEHANDLE 1
|
||||
|
||||
extern int32_t MV_ErrorCode;
|
||||
extern int MV_ErrorCode;
|
||||
|
||||
enum MV_Errors
|
||||
{
|
||||
|
@ -63,67 +63,72 @@ enum MV_Errors
|
|||
MV_InvalidFile,
|
||||
};
|
||||
|
||||
void MV_Lock(void);
|
||||
void MV_Unlock(void);
|
||||
|
||||
extern void (*MV_Printf)(const char *fmt, ...);
|
||||
const char *MV_ErrorString(int32_t ErrorNumber);
|
||||
int32_t MV_VoicePlaying(int32_t handle);
|
||||
int32_t MV_KillAllVoices(void);
|
||||
int32_t MV_Kill(int32_t handle);
|
||||
int32_t MV_VoicesPlaying(void);
|
||||
int32_t MV_VoiceAvailable(int32_t priority);
|
||||
int32_t MV_SetPitch(int32_t handle, int32_t pitchoffset);
|
||||
int32_t MV_SetFrequency(int32_t handle, int32_t frequency);
|
||||
int32_t MV_PauseVoice(int32_t handle, int32_t pause);
|
||||
int32_t MV_EndLooping(int32_t handle);
|
||||
int32_t MV_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right);
|
||||
int32_t MV_Pan3D(int32_t handle, int32_t angle, int32_t distance);
|
||||
void MV_SetReverb(int32_t reverb);
|
||||
int32_t MV_GetMaxReverbDelay(void);
|
||||
int32_t MV_GetReverbDelay(void);
|
||||
void MV_SetReverbDelay(int32_t delay);
|
||||
extern int MV_Locked;
|
||||
|
||||
int32_t MV_PlayWAV3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority,
|
||||
float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayWAV(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayVOC3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority,
|
||||
float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayVOC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayVorbis3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority,
|
||||
float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayFLAC3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority,
|
||||
float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayXA3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority, float volume,
|
||||
intptr_t callbackval);
|
||||
int32_t MV_PlayXA(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayXMP3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority,
|
||||
float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayXMP(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
int32_t MV_PlayRAW(char *ptr, uint32_t length, int32_t rate, char *loopstart, char *loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval);
|
||||
static inline void MV_Lock(void)
|
||||
{
|
||||
if (!MV_Locked++)
|
||||
SoundDriver_PCM_Lock();
|
||||
}
|
||||
|
||||
int MV_IdentifyXMP(char const *ptr, uint32_t length);
|
||||
static inline void MV_Unlock(void)
|
||||
{
|
||||
if (!--MV_Locked)
|
||||
SoundDriver_PCM_Unlock();
|
||||
else if (MV_Locked < 0)
|
||||
MV_Printf("MV_Unlock(): lockdepth < 0!\n");
|
||||
}
|
||||
|
||||
int32_t MV_GetPosition(int32_t handle, int32_t *position);
|
||||
int32_t MV_SetPosition(int32_t handle, int32_t position);
|
||||
const char *MV_ErrorString(int ErrorNumber);
|
||||
|
||||
int MV_VoicePlaying(int handle);
|
||||
int MV_KillAllVoices(void);
|
||||
int MV_Kill(int handle);
|
||||
int MV_VoicesPlaying(void);
|
||||
int MV_VoiceAvailable(int priority);
|
||||
int MV_SetPitch(int handle, int pitchoffset);
|
||||
int MV_SetFrequency(int handle, int frequency);
|
||||
int MV_PauseVoice(int handle, int pause);
|
||||
int MV_EndLooping(int handle);
|
||||
int MV_SetPan(int handle, int vol, int left, int right);
|
||||
int MV_Pan3D(int handle, int angle, int distance);
|
||||
void MV_SetReverb(int reverb);
|
||||
int MV_GetMaxReverbDelay(void);
|
||||
int MV_GetReverbDelay(void);
|
||||
void MV_SetReverbDelay(int delay);
|
||||
|
||||
int MV_PlayVOC3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle, int distance,
|
||||
int priority, float volume, uint32_t callbackval);
|
||||
int MV_PlayVOC(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol,
|
||||
int left, int right, int priority, float volume, uint32_t callbackval);
|
||||
|
||||
decltype(MV_PlayVOC3D) MV_PlayWAV3D;
|
||||
decltype(MV_PlayVOC) MV_PlayWAV;
|
||||
decltype(MV_PlayVOC3D) MV_PlayVorbis3D;
|
||||
decltype(MV_PlayVOC) MV_PlayVorbis;
|
||||
decltype(MV_PlayVOC3D) MV_PlayFLAC3D;
|
||||
decltype(MV_PlayVOC) MV_PlayFLAC;
|
||||
decltype(MV_PlayVOC3D) MV_PlayXA3D;
|
||||
decltype(MV_PlayVOC) MV_PlayXA;
|
||||
decltype(MV_PlayVOC3D) MV_PlayXMP3D;
|
||||
decltype(MV_PlayVOC) MV_PlayXMP;
|
||||
|
||||
int MV_IdentifyXMP(char const *ptr, uint32_t length);
|
||||
int MV_GetPosition(int handle, int *position);
|
||||
int MV_SetPosition(int handle, int position);
|
||||
void MV_SetVolume(int volume);
|
||||
int MV_GetVolume(void);
|
||||
void MV_SetCallBack(void (*function)(uint32_t));
|
||||
void MV_SetReverseStereo(int setting);
|
||||
int MV_GetReverseStereo(void);
|
||||
int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, void *initdata);
|
||||
int MV_Shutdown(void);
|
||||
void MV_HookMusicRoutine(void (*callback)(char *buffer, int length));
|
||||
void MV_UnhookMusicRoutine(void);
|
||||
|
||||
void MV_SetVolume(int32_t volume);
|
||||
int32_t MV_GetVolume(void);
|
||||
void MV_SetCallBack(void (*function)(intptr_t));
|
||||
void MV_SetReverseStereo(int32_t setting);
|
||||
int32_t MV_GetReverseStereo(void);
|
||||
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels,
|
||||
void *initdata);
|
||||
int32_t MV_Shutdown(void);
|
||||
static inline void MV_SetPrintf(void (*function)(const char *, ...)) { if (function) MV_Printf = function; }
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,13 +34,14 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au)
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
extern int32_t MUSIC_ErrorCode;
|
||||
extern int MUSIC_ErrorCode;
|
||||
|
||||
enum MUSIC_ERRORS
|
||||
{
|
||||
MUSIC_Error = -1,
|
||||
MUSIC_Ok = 0,
|
||||
MUSIC_FileError,
|
||||
MUSIC_Warning = -2,
|
||||
MUSIC_Error = -1,
|
||||
MUSIC_Ok = 0,
|
||||
MUSIC_MidiError,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
|
@ -58,30 +59,17 @@ typedef struct
|
|||
|
||||
#define MUSIC_SetErrorCode(status) MUSIC_ErrorCode = (status);
|
||||
|
||||
extern char const *errorMessage;
|
||||
extern const char *MUSIC_ErrorString(int ErrorNumber);
|
||||
|
||||
static inline const char *MUSIC_ErrorString(int32_t ErrorNumber)
|
||||
{
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
case MUSIC_Error: return errorMessage;
|
||||
case MUSIC_Ok: return "Music ok.";
|
||||
case MUSIC_FileError: return "Error playing file.";
|
||||
default: return "Unknown error.";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int32_t MUSIC_Init(int32_t SoundCard, int32_t Address);
|
||||
int32_t MUSIC_Shutdown(void);
|
||||
void MUSIC_SetVolume(int32_t volume);
|
||||
int32_t MUSIC_GetVolume(void);
|
||||
void MUSIC_SetLoopFlag(int32_t loopflag);
|
||||
int MUSIC_Init(int SoundCard);
|
||||
int MUSIC_Shutdown(void);
|
||||
void MUSIC_SetVolume(int volume);
|
||||
int MUSIC_GetVolume(void);
|
||||
void MUSIC_SetLoopFlag(int loopflag);
|
||||
void MUSIC_Continue(void);
|
||||
void MUSIC_Pause(void);
|
||||
int32_t MUSIC_StopSong(void);
|
||||
int32_t MUSIC_PlaySong(char *song, int32_t songsize, int32_t loopflag, const char *fn = nullptr);
|
||||
int MUSIC_StopSong(void);
|
||||
int MUSIC_PlaySong(char *song, int songsize, int loopflag, const char *fn = nullptr);
|
||||
void MUSIC_Update(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -74,49 +74,49 @@ static inline enable_if_t<is_signed<T>::value, T> SCALE_SAMPLE(T src, float volu
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static inline T CONVERT_SAMPLE_FROM_SIGNED(int32_t src);
|
||||
static inline T CONVERT_SAMPLE_FROM_SIGNED(int src);
|
||||
|
||||
template<>
|
||||
inline int16_t CONVERT_SAMPLE_FROM_SIGNED<int16_t>(int32_t src)
|
||||
inline int16_t CONVERT_SAMPLE_FROM_SIGNED<int16_t>(int src)
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline int32_t CONVERT_SAMPLE_TO_SIGNED(T src);
|
||||
static inline int CONVERT_SAMPLE_TO_SIGNED(T src);
|
||||
|
||||
template<>
|
||||
inline int32_t CONVERT_SAMPLE_TO_SIGNED<int16_t>(int16_t src)
|
||||
inline int CONVERT_SAMPLE_TO_SIGNED<int16_t>(int16_t src)
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
template <typename S, typename D>
|
||||
static inline int32_t CONVERT_LE_SAMPLE_TO_SIGNED(S src);
|
||||
static inline int CONVERT_LE_SAMPLE_TO_SIGNED(S src);
|
||||
|
||||
template<>
|
||||
inline int32_t CONVERT_LE_SAMPLE_TO_SIGNED<uint8_t, int16_t>(uint8_t src)
|
||||
inline int CONVERT_LE_SAMPLE_TO_SIGNED<uint8_t, int16_t>(uint8_t src)
|
||||
{
|
||||
return FLIP_SIGN(src) << 8;
|
||||
}
|
||||
|
||||
template<>
|
||||
inline int32_t CONVERT_LE_SAMPLE_TO_SIGNED<int16_t, int16_t>(int16_t src)
|
||||
inline int CONVERT_LE_SAMPLE_TO_SIGNED<int16_t, int16_t>(int16_t src)
|
||||
{
|
||||
return B_LITTLE16(src);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static int32_t CLAMP_SAMPLE(int32_t src);
|
||||
static int CLAMP_SAMPLE(int src);
|
||||
|
||||
template<>
|
||||
inline int32_t CLAMP_SAMPLE<int16_t>(int32_t src)
|
||||
inline int CLAMP_SAMPLE<int16_t>(int src)
|
||||
{
|
||||
return clamp(src, INT16_MIN, INT16_MAX);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T MIX_SAMPLES(int32_t signed_sample, T untouched_sample)
|
||||
static T MIX_SAMPLES(int signed_sample, T untouched_sample)
|
||||
{
|
||||
return CONVERT_SAMPLE_FROM_SIGNED<T>(CLAMP_SAMPLE<T>(signed_sample + CONVERT_SAMPLE_TO_SIGNED<T>(untouched_sample)));
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ private:
|
|||
#define MV_NUMBEROFBUFFERS 32
|
||||
#define MV_TOTALBUFFERSIZE ( MV_MIXBUFFERSIZE * MV_NUMBEROFBUFFERS )
|
||||
|
||||
typedef enum
|
||||
typedef enum : bool
|
||||
{
|
||||
NoMoreData,
|
||||
KeepPlaying
|
||||
|
@ -179,7 +179,7 @@ typedef struct VoiceNode
|
|||
uint32_t LoopSize;
|
||||
uint32_t BlockLength;
|
||||
|
||||
int32_t ptrlength; // ptrlength-1 is the max permissible index for rawdataptr
|
||||
int ptrlength; // ptrlength-1 is the max permissible index for rawdataptr
|
||||
|
||||
uint32_t PitchScale;
|
||||
uint32_t FixedPointBufferSize;
|
||||
|
@ -188,10 +188,10 @@ typedef struct VoiceNode
|
|||
uint32_t SamplingRate;
|
||||
uint32_t RateScale;
|
||||
uint32_t position;
|
||||
int32_t Paused;
|
||||
int Paused;
|
||||
|
||||
int32_t handle;
|
||||
int32_t priority;
|
||||
int handle;
|
||||
int priority;
|
||||
|
||||
intptr_t callbackval;
|
||||
} VoiceNode;
|
||||
|
@ -228,9 +228,9 @@ typedef struct
|
|||
} data_header;
|
||||
|
||||
extern Pan MV_PanTable[ MV_NUMPANPOSITIONS ][ MV_MAXVOLUME + 1 ];
|
||||
extern int32_t MV_ErrorCode;
|
||||
extern int32_t MV_Installed;
|
||||
extern int32_t MV_MixRate;
|
||||
extern int MV_ErrorCode;
|
||||
extern int MV_Installed;
|
||||
extern int MV_MixRate;
|
||||
|
||||
static FORCE_INLINE int MV_SetErrorCode(int status)
|
||||
{
|
||||
|
@ -240,20 +240,20 @@ static FORCE_INLINE int MV_SetErrorCode(int status)
|
|||
|
||||
void MV_PlayVoice(VoiceNode *voice);
|
||||
|
||||
VoiceNode *MV_AllocVoice(int32_t priority);
|
||||
VoiceNode *MV_AllocVoice(int priority);
|
||||
|
||||
void MV_SetVoiceMixMode(VoiceNode *voice);
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right, float volume);
|
||||
void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int32_t pitchoffset);
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int vol, int left, int right, float volume);
|
||||
void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int pitchoffset);
|
||||
|
||||
int32_t MV_GetVorbisPosition(VoiceNode *voice);
|
||||
void MV_SetVorbisPosition(VoiceNode *voice, int32_t position);
|
||||
int32_t MV_GetFLACPosition(VoiceNode *voice);
|
||||
void MV_SetFLACPosition(VoiceNode *voice, int32_t position);
|
||||
int32_t MV_GetXAPosition(VoiceNode *voice);
|
||||
void MV_SetXAPosition(VoiceNode *voice, int32_t position);
|
||||
int32_t MV_GetXMPPosition(VoiceNode *voice);
|
||||
void MV_SetXMPPosition(VoiceNode *voice, int32_t position);
|
||||
int MV_GetVorbisPosition(VoiceNode *voice);
|
||||
void MV_SetVorbisPosition(VoiceNode *voice, int position);
|
||||
int MV_GetFLACPosition(VoiceNode *voice);
|
||||
void MV_SetFLACPosition(VoiceNode *voice, int position);
|
||||
int MV_GetXAPosition(VoiceNode *voice);
|
||||
void MV_SetXAPosition(VoiceNode *voice, int position);
|
||||
int MV_GetXMPPosition(VoiceNode *voice);
|
||||
void MV_SetXMPPosition(VoiceNode *voice, int position);
|
||||
|
||||
void MV_ReleaseVorbisVoice(VoiceNode *voice);
|
||||
void MV_ReleaseFLACVoice(VoiceNode *voice);
|
||||
|
@ -263,15 +263,15 @@ void MV_ReleaseXMPVoice(VoiceNode *voice);
|
|||
// implemented in mix.c
|
||||
template <typename S, typename D> uint32_t MV_MixMono(struct VoiceNode * const voice, uint32_t length);
|
||||
template <typename S, typename D> uint32_t MV_MixStereo(struct VoiceNode * const voice, uint32_t length);
|
||||
template <typename T> void MV_Reverb(char const *src, char * const dest, const float volume, int32_t count);
|
||||
template <typename T> void MV_Reverb(char const *src, char * const dest, const float volume, int count);
|
||||
|
||||
// implemented in mixst.c
|
||||
template <typename S, typename D> uint32_t MV_MixMonoStereo(struct VoiceNode * const voice, uint32_t length);
|
||||
template <typename S, typename D> uint32_t MV_MixStereoStereo(struct VoiceNode * const voice, uint32_t length);
|
||||
|
||||
extern char *MV_MixDestination; // pointer to the next output sample
|
||||
extern int32_t MV_SampleSize;
|
||||
extern int32_t MV_RightChannelOffset;
|
||||
extern int MV_SampleSize;
|
||||
extern int MV_RightChannelOffset;
|
||||
|
||||
#define loopStartTagCount 3
|
||||
extern const char *loopStartTags[loopStartTagCount];
|
||||
|
|
|
@ -34,15 +34,15 @@
|
|||
|
||||
#define MIXBUFFERPOSITIONS 8
|
||||
|
||||
static int32_t ErrorCode;
|
||||
static int32_t Initialised;
|
||||
static int32_t Playing;
|
||||
static int ErrorCode;
|
||||
static int Initialised;
|
||||
static int Playing;
|
||||
|
||||
static char * MixBuffer;
|
||||
static int32_t MixBufferSize;
|
||||
static int32_t MixBufferCount;
|
||||
static int32_t MixBufferCurrent;
|
||||
static int32_t MixBufferUsed;
|
||||
static int MixBufferSize;
|
||||
static int MixBufferCount;
|
||||
static int MixBufferCurrent;
|
||||
static int MixBufferUsed;
|
||||
|
||||
static void (*MixCallBack)(void);
|
||||
|
||||
|
@ -55,9 +55,9 @@ static mutex_t mutex;
|
|||
|
||||
static DSBPOSITIONNOTIFY notifyPositions[MIXBUFFERPOSITIONS + 1] = {};
|
||||
|
||||
static void FillBufferPosition(char * ptr, int32_t remaining)
|
||||
static void FillBufferPosition(char * ptr, int remaining)
|
||||
{
|
||||
int32_t len = 0;
|
||||
int len = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -90,11 +90,11 @@ static void FillBufferPosition(char * ptr, int32_t remaining)
|
|||
while (remaining >= len);
|
||||
}
|
||||
|
||||
static void FillBuffer(int32_t bufnum)
|
||||
static void FillBuffer(int bufnum)
|
||||
{
|
||||
LPVOID ptr, ptr2;
|
||||
DWORD remaining, remaining2;
|
||||
int32_t retries = 1;
|
||||
int retries = 1;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ static void FillBuffer(int32_t bufnum)
|
|||
continue;
|
||||
}
|
||||
fail:
|
||||
MV_Printf("DirectSound FillBuffer: err %x\n", (uint32_t)err);
|
||||
MV_Printf("DirectSound FillBuffer: err %x\n", (unsigned int)err);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ static DWORD WINAPI fillDataThread(LPVOID lpParameter)
|
|||
break;
|
||||
|
||||
default:
|
||||
MV_Printf("DirectSound fillDataThread: wfmo err %d\n", (int32_t)waitret);
|
||||
MV_Printf("DirectSound fillDataThread: wfmo err %d\n", (int)waitret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ static DWORD WINAPI fillDataThread(LPVOID lpParameter)
|
|||
static void TeardownDSound(HRESULT err)
|
||||
{
|
||||
if (FAILED(err))
|
||||
MV_Printf("Dying error: %x\n", (uint32_t)err);
|
||||
MV_Printf("Dying error: %x\n", (unsigned int)err);
|
||||
|
||||
if (lpdsnotify)
|
||||
IDirectSoundNotify_Release(lpdsnotify), lpdsnotify = nullptr;
|
||||
|
@ -204,7 +204,7 @@ static int DirectSound_Error(HRESULT err, int code)
|
|||
return DSErr_Error;
|
||||
}
|
||||
|
||||
int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
|
||||
int DirectSoundDrv_PCM_Init(int *mixrate, int *numchannels, void * initdata)
|
||||
{
|
||||
HRESULT err;
|
||||
DSBUFFERDESC bufdesc = {};
|
||||
|
@ -281,7 +281,7 @@ void DirectSoundDrv_PCM_Shutdown(void)
|
|||
Initialised = 0;
|
||||
}
|
||||
|
||||
int32_t DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t NumDivisions, void (*CallBackFunc)(void))
|
||||
int DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)(void))
|
||||
{
|
||||
if (!Initialised)
|
||||
{
|
||||
|
@ -343,12 +343,12 @@ void DirectSoundDrv_PCM_Unlock(void)
|
|||
mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
int32_t DirectSoundDrv_GetError(void)
|
||||
int DirectSoundDrv_GetError(void)
|
||||
{
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
const char *DirectSoundDrv_ErrorString(int32_t ErrorNumber)
|
||||
const char *DirectSoundDrv_ErrorString(int ErrorNumber)
|
||||
{
|
||||
const char *ErrorString;
|
||||
|
||||
|
|
|
@ -40,12 +40,12 @@ enum
|
|||
DSErr_CreateThread,
|
||||
};
|
||||
|
||||
int32_t DirectSoundDrv_GetError(void);
|
||||
const char *DirectSoundDrv_ErrorString(int32_t ErrorNumber);
|
||||
int DirectSoundDrv_GetError(void);
|
||||
const char *DirectSoundDrv_ErrorString(int ErrorNumber);
|
||||
|
||||
int32_t DirectSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void *initdata);
|
||||
int32_t DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t NumDivisions, void (*CallBackFunc)(void));
|
||||
void DirectSoundDrv_PCM_StopPlayback(void);
|
||||
void DirectSoundDrv_PCM_Lock(void);
|
||||
void DirectSoundDrv_PCM_Unlock(void);
|
||||
void DirectSoundDrv_PCM_Shutdown(void);
|
||||
int DirectSoundDrv_PCM_Init(int *mixrate, int *numchannels, void *initdata);
|
||||
void DirectSoundDrv_PCM_Shutdown(void);
|
||||
int DirectSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)(void));
|
||||
void DirectSoundDrv_PCM_StopPlayback(void);
|
||||
void DirectSoundDrv_PCM_Lock(void);
|
||||
void DirectSoundDrv_PCM_Unlock(void);
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
Copyright (C) 2009 Jonathon Fowler <jf@jonof.id.au>
|
||||
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -23,20 +23,17 @@
|
|||
*/
|
||||
|
||||
#include "compat.h"
|
||||
#include "midifuncs.h"
|
||||
|
||||
int NoSoundDrv_GetError(void) { return 0; }
|
||||
|
||||
int32_t NoSoundDrv_GetError(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *NoSoundDrv_ErrorString( int32_t ErrorNumber )
|
||||
const char *NoSoundDrv_ErrorString(int ErrorNumber)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ErrorNumber);
|
||||
return "No sound, Ok.";
|
||||
}
|
||||
|
||||
int32_t NoSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
|
||||
int NoSoundDrv_PCM_Init(int *mixrate, int *numchannels, void *initdata)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(mixrate);
|
||||
UNREFERENCED_PARAMETER(numchannels);
|
||||
|
@ -44,12 +41,9 @@ int32_t NoSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initd
|
|||
return 0;
|
||||
}
|
||||
|
||||
void NoSoundDrv_PCM_Shutdown(void)
|
||||
{
|
||||
}
|
||||
void NoSoundDrv_PCM_Shutdown(void) {}
|
||||
|
||||
int32_t NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
|
||||
int32_t NumDivisions, void ( *CallBackFunc )( void ) )
|
||||
int NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)(void))
|
||||
{
|
||||
UNREFERENCED_PARAMETER(BufferStart);
|
||||
UNREFERENCED_PARAMETER(BufferSize);
|
||||
|
@ -58,14 +52,32 @@ int32_t NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void NoSoundDrv_PCM_StopPlayback(void)
|
||||
void NoSoundDrv_PCM_StopPlayback(void) {}
|
||||
void NoSoundDrv_PCM_Lock(void) {}
|
||||
void NoSoundDrv_PCM_Unlock(void) {}
|
||||
|
||||
int NoSoundDrv_MIDI_Init(midifuncs *funcs)
|
||||
{
|
||||
Bmemset(funcs, 0, sizeof(midifuncs));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NoSoundDrv_PCM_Lock(void)
|
||||
void NoSoundDrv_MIDI_Shutdown(void) {}
|
||||
|
||||
int NoSoundDrv_MIDI_StartPlayback(void (*service)(void))
|
||||
{
|
||||
UNREFERENCED_PARAMETER(service);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NoSoundDrv_PCM_Unlock(void)
|
||||
void NoSoundDrv_MIDI_HaltPlayback(void) {}
|
||||
unsigned int NoSoundDrv_MIDI_GetTick(void) { return 0; }
|
||||
|
||||
void NoSoundDrv_MIDI_SetTempo(int tempo, int division)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(tempo);
|
||||
UNREFERENCED_PARAMETER(division);
|
||||
}
|
||||
|
||||
void NoSoundDrv_MIDI_Lock(void) {}
|
||||
void NoSoundDrv_MIDI_Unlock(void) {}
|
||||
|
|
|
@ -18,13 +18,24 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "midifuncs.h"
|
||||
|
||||
int32_t NoSoundDrv_GetError(void);
|
||||
const char *NoSoundDrv_ErrorString( int32_t ErrorNumber );
|
||||
int32_t NoSoundDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata);
|
||||
int NoSoundDrv_GetError(void);
|
||||
const char *NoSoundDrv_ErrorString( int ErrorNumber );
|
||||
|
||||
int NoSoundDrv_PCM_Init(int * mixrate, int * numchannels, void * initdata);
|
||||
void NoSoundDrv_PCM_Shutdown(void);
|
||||
int32_t NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
|
||||
int32_t NumDivisions, void ( *CallBackFunc )( void ) );
|
||||
int NoSoundDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
|
||||
int NumDivisions, void ( *CallBackFunc )( void ) );
|
||||
void NoSoundDrv_PCM_StopPlayback(void);
|
||||
void NoSoundDrv_PCM_Lock(void);
|
||||
void NoSoundDrv_PCM_Unlock(void);
|
||||
|
||||
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);
|
||||
void NoSoundDrv_MIDI_SetTempo(int tempo, int division);
|
||||
void NoSoundDrv_MIDI_Lock(void);
|
||||
void NoSoundDrv_MIDI_Unlock(void);
|
|
@ -39,16 +39,16 @@ enum {
|
|||
SDLErr_OpenAudio
|
||||
};
|
||||
|
||||
static int32_t ErrorCode = SDLErr_Ok;
|
||||
static int32_t Initialised;
|
||||
static int32_t Playing;
|
||||
static int ErrorCode = SDLErr_Ok;
|
||||
static int Initialised;
|
||||
static int Playing;
|
||||
static uint32_t StartedSDL;
|
||||
|
||||
static char *MixBuffer;
|
||||
static int32_t MixBufferSize;
|
||||
static int32_t MixBufferCount;
|
||||
static int32_t MixBufferCurrent;
|
||||
static int32_t MixBufferUsed;
|
||||
static int MixBufferSize;
|
||||
static int MixBufferCount;
|
||||
static int MixBufferCurrent;
|
||||
static int MixBufferUsed;
|
||||
static void (*MixCallBack)(void);
|
||||
|
||||
#if (SDL_MAJOR_VERSION == 2)
|
||||
|
@ -57,6 +57,9 @@ static SDL_AudioDeviceID audio_dev;
|
|||
|
||||
static void fillData(void * userdata, Uint8 * ptr, int remaining)
|
||||
{
|
||||
if (!MixBuffer || !MixCallBack)
|
||||
return;
|
||||
|
||||
UNREFERENCED_PARAMETER(userdata);
|
||||
|
||||
int len;
|
||||
|
@ -90,12 +93,12 @@ static void fillData(void * userdata, Uint8 * ptr, int remaining)
|
|||
}
|
||||
}
|
||||
|
||||
int32_t SDLDrv_GetError(void)
|
||||
int SDLDrv_GetError(void)
|
||||
{
|
||||
return ErrorCode;
|
||||
}
|
||||
|
||||
const char *SDLDrv_ErrorString( int32_t ErrorNumber )
|
||||
const char *SDLDrv_ErrorString( int ErrorNumber )
|
||||
{
|
||||
const char *ErrorString;
|
||||
|
||||
|
@ -129,7 +132,7 @@ const char *SDLDrv_ErrorString( int32_t ErrorNumber )
|
|||
return ErrorString;
|
||||
}
|
||||
|
||||
int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata)
|
||||
int SDLDrv_PCM_Init(int *mixrate, int *numchannels, void * initdata)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(initdata);
|
||||
|
||||
|
@ -238,8 +241,8 @@ void SDLDrv_PCM_Shutdown(void)
|
|||
Initialised = 0;
|
||||
}
|
||||
|
||||
int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
|
||||
int32_t NumDivisions, void ( *CallBackFunc )( void ) )
|
||||
int SDLDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
|
||||
int NumDivisions, void ( *CallBackFunc )( void ) )
|
||||
{
|
||||
if (!Initialised) {
|
||||
ErrorCode = SDLErr_Uninitialised;
|
||||
|
|
|
@ -23,12 +23,12 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
int32_t SDLDrv_GetError(void);
|
||||
const char *SDLDrv_ErrorString( int32_t ErrorNumber );
|
||||
int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, void * initdata);
|
||||
int SDLDrv_GetError(void);
|
||||
const char *SDLDrv_ErrorString( int ErrorNumber );
|
||||
int SDLDrv_PCM_Init(int *mixrate, int *numchannels, void * initdata);
|
||||
void SDLDrv_PCM_Shutdown(void);
|
||||
int32_t SDLDrv_PCM_BeginPlayback(char *BufferStart, int32_t BufferSize,
|
||||
int32_t NumDivisions, void ( *CallBackFunc )( void ) );
|
||||
int SDLDrv_PCM_BeginPlayback(char *BufferStart, int BufferSize,
|
||||
int NumDivisions, void ( *CallBackFunc )( void ) );
|
||||
void SDLDrv_PCM_StopPlayback(void);
|
||||
void SDLDrv_PCM_Lock(void);
|
||||
void SDLDrv_PCM_Unlock(void);
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
/*
|
||||
Copyright (C) 2009 Jonathon Fowler <jf@jonof.id.au>
|
||||
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -27,83 +27,229 @@
|
|||
|
||||
#include "driver_nosound.h"
|
||||
|
||||
#if defined MIXERTYPEWIN
|
||||
# include "driver_directsound.h"
|
||||
#elif defined MIXERTYPESDL
|
||||
#ifdef RENDERTYPESDL
|
||||
# include "driver_sdl.h"
|
||||
#endif
|
||||
|
||||
int32_t ASS_SoundDriver = -1;
|
||||
#ifdef _WIN32
|
||||
# include "driver_directsound.h"
|
||||
# include "driver_winmm.h"
|
||||
#endif
|
||||
|
||||
#define UNSUPPORTED { 0,0,0,0,0,0,0,0, },
|
||||
int ASS_PCMSoundDriver = ASS_AutoDetect;
|
||||
int ASS_MIDISoundDriver = ASS_AutoDetect;
|
||||
|
||||
static struct
|
||||
{
|
||||
int32_t (*GetError)(void);
|
||||
const char *(*ErrorString)(int32_t);
|
||||
int32_t (*Init)(int32_t *, int32_t *, void *);
|
||||
void (*Shutdown)(void);
|
||||
int32_t (*BeginPlayback)(char *, int32_t, int32_t, void (*)(void));
|
||||
void (*StopPlayback)(void);
|
||||
void (*Lock)(void);
|
||||
void (*Unlock)(void);
|
||||
#define UNSUPPORTED_PCM 0,0,0,0,0,0
|
||||
#define UNSUPPORTED_MIDI 0,0,0,0,0,0,0
|
||||
#define UNSUPPORTED_COMPLETELY { 0,0, UNSUPPORTED_PCM, UNSUPPORTED_MIDI },
|
||||
|
||||
static struct {
|
||||
const char * DriverName;
|
||||
|
||||
int (*GetError)(void);
|
||||
const char *(*ErrorString)(int);
|
||||
|
||||
int (*PCM_Init)(int *, int *, void *);
|
||||
void (*PCM_Shutdown)(void);
|
||||
int (*PCM_BeginPlayback)(char *, int, int, void (*)(void));
|
||||
void (*PCM_StopPlayback)(void);
|
||||
void (*PCM_Lock)(void);
|
||||
void (*PCM_Unlock)(void);
|
||||
|
||||
int (*MIDI_Init)(midifuncs *);
|
||||
void (*MIDI_Shutdown)(void);
|
||||
int (*MIDI_StartPlayback)(void (*service)(void));
|
||||
void (*MIDI_HaltPlayback)(void);
|
||||
void (*MIDI_SetTempo)(int tempo, int division);
|
||||
void (*MIDI_Lock)(void);
|
||||
void (*MIDI_Unlock)(void);
|
||||
} SoundDrivers[ASS_NumSoundCards] = {
|
||||
|
||||
|
||||
// Everyone gets the "no sound" driver
|
||||
{
|
||||
NoSoundDrv_GetError, NoSoundDrv_ErrorString, NoSoundDrv_PCM_Init, NoSoundDrv_PCM_Shutdown,
|
||||
NoSoundDrv_PCM_BeginPlayback, NoSoundDrv_PCM_StopPlayback, NoSoundDrv_PCM_Lock, NoSoundDrv_PCM_Unlock,
|
||||
},
|
||||
|
||||
// Windows DirectSound
|
||||
#if defined MIXERTYPEWIN
|
||||
{
|
||||
DirectSoundDrv_GetError, DirectSoundDrv_ErrorString, DirectSoundDrv_PCM_Init, DirectSoundDrv_PCM_Shutdown,
|
||||
DirectSoundDrv_PCM_BeginPlayback, DirectSoundDrv_PCM_StopPlayback, DirectSoundDrv_PCM_Lock,
|
||||
DirectSoundDrv_PCM_Unlock,
|
||||
},
|
||||
"No Sound",
|
||||
NoSoundDrv_GetError,
|
||||
NoSoundDrv_ErrorString,
|
||||
NoSoundDrv_PCM_Init,
|
||||
NoSoundDrv_PCM_Shutdown,
|
||||
NoSoundDrv_PCM_BeginPlayback,
|
||||
NoSoundDrv_PCM_StopPlayback,
|
||||
NoSoundDrv_PCM_Lock,
|
||||
NoSoundDrv_PCM_Unlock,
|
||||
NoSoundDrv_MIDI_Init,
|
||||
NoSoundDrv_MIDI_Shutdown,
|
||||
NoSoundDrv_MIDI_StartPlayback,
|
||||
NoSoundDrv_MIDI_HaltPlayback,
|
||||
NoSoundDrv_MIDI_SetTempo,
|
||||
NoSoundDrv_MIDI_Lock,
|
||||
NoSoundDrv_MIDI_Unlock,
|
||||
},
|
||||
|
||||
// Simple DirectMedia Layer
|
||||
#elif defined MIXERTYPESDL
|
||||
#ifdef RENDERTYPESDL
|
||||
{
|
||||
SDLDrv_GetError, SDLDrv_ErrorString, SDLDrv_PCM_Init, SDLDrv_PCM_Shutdown,
|
||||
SDLDrv_PCM_BeginPlayback, SDLDrv_PCM_StopPlayback, SDLDrv_PCM_Lock, SDLDrv_PCM_Unlock,
|
||||
"SDL",
|
||||
SDLDrv_GetError,
|
||||
SDLDrv_ErrorString,
|
||||
SDLDrv_PCM_Init,
|
||||
SDLDrv_PCM_Shutdown,
|
||||
SDLDrv_PCM_BeginPlayback,
|
||||
SDLDrv_PCM_StopPlayback,
|
||||
SDLDrv_PCM_Lock,
|
||||
SDLDrv_PCM_Unlock,
|
||||
UNSUPPORTED_MIDI,
|
||||
},
|
||||
#endif
|
||||
#else
|
||||
UNSUPPORTED_COMPLETELY
|
||||
#endif
|
||||
|
||||
// Windows DirectSound
|
||||
#ifdef _WIN32
|
||||
{
|
||||
"DirectSound",
|
||||
DirectSoundDrv_GetError,
|
||||
DirectSoundDrv_ErrorString,
|
||||
DirectSoundDrv_PCM_Init,
|
||||
DirectSoundDrv_PCM_Shutdown,
|
||||
DirectSoundDrv_PCM_BeginPlayback,
|
||||
DirectSoundDrv_PCM_StopPlayback,
|
||||
DirectSoundDrv_PCM_Lock,
|
||||
DirectSoundDrv_PCM_Unlock,
|
||||
UNSUPPORTED_MIDI,
|
||||
},
|
||||
#else
|
||||
UNSUPPORTED_COMPLETELY
|
||||
#endif
|
||||
|
||||
// Windows MultiMedia system
|
||||
#ifdef _WIN32
|
||||
{
|
||||
"WinMM",
|
||||
WinMMDrv_GetError,
|
||||
WinMMDrv_ErrorString,
|
||||
|
||||
UNSUPPORTED_PCM,
|
||||
|
||||
WinMMDrv_MIDI_Init,
|
||||
WinMMDrv_MIDI_Shutdown,
|
||||
WinMMDrv_MIDI_StartPlayback,
|
||||
WinMMDrv_MIDI_HaltPlayback,
|
||||
WinMMDrv_MIDI_SetTempo,
|
||||
WinMMDrv_MIDI_Lock,
|
||||
WinMMDrv_MIDI_Unlock,
|
||||
},
|
||||
#else
|
||||
UNSUPPORTED_COMPLETELY
|
||||
#endif
|
||||
|
||||
// TODO: create the driver functions for these
|
||||
//
|
||||
// older MPU-401 code...
|
||||
#ifdef _WIN32
|
||||
{
|
||||
"MPU-401",
|
||||
WinMMDrv_GetError,
|
||||
WinMMDrv_ErrorString,
|
||||
|
||||
UNSUPPORTED_PCM,
|
||||
|
||||
WinMMDrv_MIDI_Init,
|
||||
WinMMDrv_MIDI_Shutdown,
|
||||
WinMMDrv_MIDI_StartPlayback,
|
||||
WinMMDrv_MIDI_HaltPlayback,
|
||||
WinMMDrv_MIDI_SetTempo,
|
||||
WinMMDrv_MIDI_Lock,
|
||||
WinMMDrv_MIDI_Unlock,
|
||||
},
|
||||
#else
|
||||
UNSUPPORTED_COMPLETELY
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
// OPL3 emulation
|
||||
{
|
||||
"OPL3",
|
||||
WinMMDrv_GetError,
|
||||
WinMMDrv_ErrorString,
|
||||
|
||||
UNSUPPORTED_PCM,
|
||||
|
||||
WinMMDrv_MIDI_Init,
|
||||
WinMMDrv_MIDI_Shutdown,
|
||||
WinMMDrv_MIDI_StartPlayback,
|
||||
WinMMDrv_MIDI_HaltPlayback,
|
||||
WinMMDrv_MIDI_SetTempo,
|
||||
WinMMDrv_MIDI_Lock,
|
||||
WinMMDrv_MIDI_Unlock,
|
||||
},
|
||||
#else
|
||||
UNSUPPORTED_COMPLETELY
|
||||
#endif
|
||||
};
|
||||
|
||||
int32_t SoundDriver_IsSupported(int32_t driver) { return (SoundDrivers[driver].GetError != 0); }
|
||||
|
||||
int32_t SoundDriver_GetError(void)
|
||||
int SoundDriver_IsPCMSupported(int driver) { return (SoundDrivers[driver].PCM_Init != 0); }
|
||||
int SoundDriver_IsMIDISupported(int driver) { return (SoundDrivers[driver].MIDI_Init != 0); }
|
||||
const char *SoundDriver_GetName(int driver) { return SoundDrivers[driver].DriverName; }
|
||||
|
||||
int SoundDriver_PCM_GetError(void)
|
||||
{
|
||||
return SoundDriver_IsSupported(ASS_SoundDriver) ? SoundDrivers[ASS_SoundDriver].GetError() : -1;
|
||||
if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
|
||||
return -1;
|
||||
}
|
||||
return SoundDrivers[ASS_PCMSoundDriver].GetError();
|
||||
}
|
||||
|
||||
const char * SoundDriver_ErrorString( int32_t ErrorNumber )
|
||||
const char * SoundDriver_PCM_ErrorString( int ErrorNumber )
|
||||
{
|
||||
if (ASS_SoundDriver < 0 || ASS_SoundDriver >= ASS_NumSoundCards)
|
||||
if (ASS_PCMSoundDriver < 0 || ASS_PCMSoundDriver >= ASS_NumSoundCards) {
|
||||
return "No sound driver selected.";
|
||||
|
||||
if (!SoundDriver_IsSupported(ASS_SoundDriver))
|
||||
}
|
||||
if (!SoundDriver_IsPCMSupported(ASS_PCMSoundDriver)) {
|
||||
return "Unsupported sound driver selected.";
|
||||
|
||||
return SoundDrivers[ASS_SoundDriver].ErrorString(ErrorNumber);
|
||||
}
|
||||
return SoundDrivers[ASS_PCMSoundDriver].ErrorString(ErrorNumber);
|
||||
}
|
||||
|
||||
int32_t SoundDriver_Init(int32_t *mixrate, int32_t *numchannels, void *initdata)
|
||||
int SoundDriver_MIDI_GetError(void)
|
||||
{
|
||||
return SoundDrivers[ASS_SoundDriver].Init(mixrate, numchannels, initdata);
|
||||
if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
|
||||
return -1;
|
||||
}
|
||||
return SoundDrivers[ASS_MIDISoundDriver].GetError();
|
||||
}
|
||||
|
||||
void SoundDriver_Shutdown(void) { SoundDrivers[ASS_SoundDriver].Shutdown(); }
|
||||
|
||||
int32_t SoundDriver_BeginPlayback(char *BufferStart, int32_t BufferSize, int32_t NumDivisions,
|
||||
void (*CallBackFunc)(void))
|
||||
const char * SoundDriver_MIDI_ErrorString( int ErrorNumber )
|
||||
{
|
||||
return SoundDrivers[ASS_SoundDriver].BeginPlayback(BufferStart, BufferSize, NumDivisions, CallBackFunc);
|
||||
if (ASS_MIDISoundDriver < 0 || ASS_MIDISoundDriver >= ASS_NumSoundCards) {
|
||||
return "No sound driver selected.";
|
||||
}
|
||||
if (!SoundDriver_IsMIDISupported(ASS_MIDISoundDriver)) {
|
||||
return "Unsupported sound driver selected.";
|
||||
}
|
||||
return SoundDrivers[ASS_MIDISoundDriver].ErrorString(ErrorNumber);
|
||||
}
|
||||
|
||||
void SoundDriver_StopPlayback(void) { SoundDrivers[ASS_SoundDriver].StopPlayback(); }
|
||||
int SoundDriver_PCM_Init(int *mixrate, int *numchannels, void *initdata)
|
||||
{
|
||||
return SoundDrivers[ASS_PCMSoundDriver].PCM_Init(mixrate, numchannels, initdata);
|
||||
}
|
||||
|
||||
void SoundDriver_Lock(void) { SoundDrivers[ASS_SoundDriver].Lock(); }
|
||||
int SoundDriver_PCM_BeginPlayback(char *BufferStart, int BufferSize, int NumDivisions, void (*CallBackFunc)(void))
|
||||
{
|
||||
return SoundDrivers[ASS_PCMSoundDriver].PCM_BeginPlayback(BufferStart, BufferSize, NumDivisions, CallBackFunc);
|
||||
}
|
||||
|
||||
void SoundDriver_Unlock(void) { SoundDrivers[ASS_SoundDriver].Unlock(); }
|
||||
void SoundDriver_PCM_Shutdown(void) { SoundDrivers[ASS_PCMSoundDriver].PCM_Shutdown(); }
|
||||
void SoundDriver_PCM_StopPlayback(void) { SoundDrivers[ASS_PCMSoundDriver].PCM_StopPlayback(); }
|
||||
void SoundDriver_PCM_Lock(void) { SoundDrivers[ASS_PCMSoundDriver].PCM_Lock(); }
|
||||
void SoundDriver_PCM_Unlock(void) { SoundDrivers[ASS_PCMSoundDriver].PCM_Unlock(); }
|
||||
int SoundDriver_MIDI_Init(midifuncs *funcs) { return SoundDrivers[ASS_MIDISoundDriver].MIDI_Init(funcs); }
|
||||
int SoundDriver_MIDI_StartPlayback(void (*service)(void)) { return SoundDrivers[ASS_MIDISoundDriver].MIDI_StartPlayback(service); }
|
||||
void SoundDriver_MIDI_Shutdown(void) { SoundDrivers[ASS_MIDISoundDriver].MIDI_Shutdown(); }
|
||||
void SoundDriver_MIDI_HaltPlayback(void) { SoundDrivers[ASS_MIDISoundDriver].MIDI_HaltPlayback(); }
|
||||
void SoundDriver_MIDI_SetTempo(int tempo, int division) { SoundDrivers[ASS_MIDISoundDriver].MIDI_SetTempo(tempo, division); }
|
||||
void SoundDriver_MIDI_Lock(void) { SoundDrivers[ASS_MIDISoundDriver].MIDI_Lock(); }
|
||||
void SoundDriver_MIDI_Unlock(void) { SoundDrivers[ASS_MIDISoundDriver].MIDI_Unlock(); }
|
||||
|
||||
// vim:ts=4:sw=4:expandtab:
|
||||
|
|
|
@ -101,7 +101,7 @@ static size_t write_flac(const void *ptr, size_t size, size_t nmemb, FLAC__IOHan
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t seek_flac(FLAC__IOHandle datasource, FLAC__int64 offset, int32_t whence)
|
||||
static int seek_flac(FLAC__IOHandle datasource, FLAC__int64 offset, int whence)
|
||||
{
|
||||
flac_data *flac = (flac_data *)datasource;
|
||||
|
||||
|
@ -136,14 +136,14 @@ static FLAC__int64 length_flac(FLAC__IOHandle datasource)
|
|||
return flac->length;
|
||||
}
|
||||
|
||||
static int32_t eof_flac(FLAC__IOHandle datasource)
|
||||
static int eof_flac(FLAC__IOHandle datasource)
|
||||
{
|
||||
flac_data *flac = (flac_data *)datasource;
|
||||
|
||||
return (flac->pos == flac->length);
|
||||
}
|
||||
|
||||
static int32_t close_flac(FLAC__IOHandle datasource)
|
||||
static int close_flac(FLAC__IOHandle datasource)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(datasource);
|
||||
return 0;
|
||||
|
@ -294,7 +294,7 @@ void error_flac_stream(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderEr
|
|||
// FLAC__stream_decoder_flush(fd->stream);
|
||||
}
|
||||
|
||||
int32_t MV_GetFLACPosition(VoiceNode *voice)
|
||||
int MV_GetFLACPosition(VoiceNode *voice)
|
||||
{
|
||||
FLAC__uint64 position = 0;
|
||||
flac_data *fd = (flac_data *)voice->rawdataptr;
|
||||
|
@ -304,7 +304,7 @@ int32_t MV_GetFLACPosition(VoiceNode *voice)
|
|||
return position;
|
||||
}
|
||||
|
||||
void MV_SetFLACPosition(VoiceNode *voice, int32_t position)
|
||||
void MV_SetFLACPosition(VoiceNode *voice, int position)
|
||||
{
|
||||
flac_data *fd = (flac_data *)voice->rawdataptr;
|
||||
|
||||
|
@ -380,13 +380,13 @@ Begin playback of sound data at specified angle and distance
|
|||
from listener.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int32_t MV_PlayFLAC3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayFLAC3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle, int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
int32_t left;
|
||||
int32_t right;
|
||||
int32_t mid;
|
||||
int32_t vol;
|
||||
int32_t status;
|
||||
int left;
|
||||
int right;
|
||||
int mid;
|
||||
int vol;
|
||||
int status;
|
||||
|
||||
if (!MV_Installed)
|
||||
return MV_SetErrorCode(MV_NotInstalled);
|
||||
|
@ -419,7 +419,7 @@ Begin playback of sound data with the given sound levels and
|
|||
priority.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayFLAC(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
VoiceNode *voice;
|
||||
flac_data *fd = 0;
|
||||
|
@ -657,8 +657,8 @@ void MV_ReleaseFLACVoice(VoiceNode *voice)
|
|||
#else
|
||||
#include "_multivc.h"
|
||||
|
||||
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, float volume, intptr_t callbackval)
|
||||
int MV_PlayFLAC(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitchoffset,
|
||||
int vol, int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ptr);
|
||||
UNREFERENCED_PARAMETER(ptrlength);
|
||||
|
@ -676,8 +676,8 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t MV_PlayFLAC3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle,
|
||||
int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayFLAC3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int angle,
|
||||
int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ptr);
|
||||
UNREFERENCED_PARAMETER(ptrlength);
|
||||
|
|
|
@ -301,31 +301,8 @@ end_of_data:
|
|||
return NoMoreData;
|
||||
}
|
||||
|
||||
static playbackstatus MV_GetNextRAWBlock(VoiceNode *voice)
|
||||
{
|
||||
if (voice->BlockLength == 0)
|
||||
{
|
||||
if (voice->LoopStart == NULL)
|
||||
return NoMoreData;
|
||||
|
||||
voice->BlockLength = voice->LoopSize;
|
||||
voice->NextBlock = voice->LoopStart;
|
||||
voice->length = 0;
|
||||
voice->position = 0;
|
||||
}
|
||||
|
||||
voice->sound = voice->NextBlock;
|
||||
voice->position -= voice->length;
|
||||
voice->length = min(voice->BlockLength, 0x8000u);
|
||||
voice->NextBlock += voice->length * (voice->channels * voice->bits / 8);
|
||||
voice->BlockLength -= voice->length;
|
||||
voice->length <<= 16;
|
||||
|
||||
return KeepPlaying;
|
||||
}
|
||||
|
||||
int32_t MV_PlayWAV3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance,
|
||||
int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayWAV3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle, int distance,
|
||||
int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
@ -345,8 +322,8 @@ int32_t MV_PlayWAV3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitcho
|
|||
MV_PanTable[ angle ][ vol ].left, MV_PanTable[ angle ][ vol ].right, priority, volume, callbackval);
|
||||
}
|
||||
|
||||
int32_t MV_PlayWAV(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol,
|
||||
int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayWAV(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol,
|
||||
int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
@ -389,7 +366,7 @@ int32_t MV_PlayWAV(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
|
|||
voice->channels = format.nChannels;
|
||||
voice->GetSound = MV_GetNextWAVBlock;
|
||||
|
||||
int32_t blocklen = data.size;
|
||||
int blocklen = data.size;
|
||||
|
||||
if (voice->bits == 16)
|
||||
{
|
||||
|
@ -426,8 +403,8 @@ int32_t MV_PlayWAV(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
|
|||
return voice->handle;
|
||||
}
|
||||
|
||||
int32_t MV_PlayVOC3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle,
|
||||
int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayVOC3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle,
|
||||
int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
@ -447,8 +424,8 @@ int32_t MV_PlayVOC3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitcho
|
|||
MV_PanTable[ angle ][ vol ].left, MV_PanTable[ angle ][ vol ].right, priority, volume, callbackval);
|
||||
}
|
||||
|
||||
int32_t MV_PlayVOC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol,
|
||||
int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayVOC(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol,
|
||||
int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
@ -491,48 +468,3 @@ int32_t MV_PlayVOC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
|
|||
return voice->handle;
|
||||
}
|
||||
|
||||
int32_t MV_PlayRAW(char *ptr, uint32_t length, int32_t rate, char *loopstart, char *loopend, int32_t pitchoffset, int32_t vol,
|
||||
int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
||||
// Request a voice from the voice pool
|
||||
VoiceNode *voice = MV_AllocVoice(priority);
|
||||
|
||||
if (voice == NULL)
|
||||
{
|
||||
MV_SetErrorCode(MV_NoVoices);
|
||||
return MV_Error;
|
||||
}
|
||||
|
||||
voice->rawdataptr = (uint8_t *)ptr;
|
||||
voice->ptrlength = length;
|
||||
voice->Paused = FALSE;
|
||||
voice->wavetype = FMT_RAW;
|
||||
voice->bits = 8;
|
||||
voice->channels = 1;
|
||||
voice->GetSound = MV_GetNextRAWBlock;
|
||||
voice->NextBlock = ptr;
|
||||
voice->LoopCount = 0;
|
||||
voice->position = 0;
|
||||
voice->BlockLength = length;
|
||||
voice->PitchScale = PITCH_GetScale(pitchoffset);
|
||||
voice->length = 0;
|
||||
voice->next = NULL;
|
||||
voice->prev = NULL;
|
||||
voice->priority = priority;
|
||||
voice->callbackval = callbackval;
|
||||
voice->LoopStart = loopstart;
|
||||
voice->LoopEnd = loopend;
|
||||
voice->LoopSize = loopend - loopstart + 1;
|
||||
|
||||
voice->volume = volume;
|
||||
|
||||
MV_SetVoicePitch(voice, rate, pitchoffset);
|
||||
MV_SetVoiceVolume(voice, vol, left, right, volume);
|
||||
MV_PlayVoice(voice);
|
||||
|
||||
return voice->handle;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "multivoc.h"
|
||||
#include "fx_man.h"
|
||||
|
||||
int32_t FX_ErrorCode = FX_Ok;
|
||||
int32_t FX_Installed;
|
||||
int FX_ErrorCode = FX_Ok;
|
||||
int FX_Installed;
|
||||
|
||||
const char *FX_ErrorString(int32_t ErrorNumber)
|
||||
const char *FX_ErrorString(int ErrorNumber)
|
||||
{
|
||||
const char *ErrorString;
|
||||
|
||||
|
@ -44,23 +44,34 @@ const char *FX_ErrorString(int32_t ErrorNumber)
|
|||
return ErrorString;
|
||||
}
|
||||
|
||||
int32_t FX_Init(int32_t numvoices, int32_t numchannels, unsigned mixrate, void *initdata)
|
||||
int FX_Init(int numvoices, int numchannels, unsigned mixrate, void *initdata)
|
||||
{
|
||||
if (FX_Installed)
|
||||
FX_Shutdown();
|
||||
|
||||
#if defined MIXERTYPEWIN
|
||||
int SoundCard = ASS_DirectSound;
|
||||
#elif defined MIXERTYPESDL
|
||||
int SoundCard = ASS_SDL;
|
||||
#else
|
||||
#warning No sound driver selected!
|
||||
int SoundCard = ASS_NoSound;
|
||||
#endif
|
||||
int SoundCard = ASS_AutoDetect;
|
||||
|
||||
if (SoundDriver_IsSupported(SoundCard) == 0)
|
||||
if (SoundCard == ASS_AutoDetect) {
|
||||
#if defined RENDERTYPESDL
|
||||
SoundCard = ASS_SDL;
|
||||
#elif defined _WIN32
|
||||
SoundCard = ASS_DirectSound;
|
||||
#else
|
||||
SoundCard = ASS_NoSound;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (SoundCard < 0 || SoundCard >= ASS_NumSoundCards)
|
||||
{
|
||||
FX_SetErrorCode(FX_InvalidCard);
|
||||
return FX_Error;
|
||||
}
|
||||
|
||||
|
||||
if (SoundDriver_IsPCMSupported(SoundCard) == 0)
|
||||
{
|
||||
// unsupported cards fall back to no sound
|
||||
MV_Printf("Couldn't init %s, falling back to no sound...\n", SoundDriver_GetName(SoundCard));
|
||||
SoundCard = ASS_NoSound;
|
||||
}
|
||||
|
||||
|
@ -78,7 +89,7 @@ int32_t FX_Init(int32_t numvoices, int32_t numchannels, unsigned mixrate, void *
|
|||
return status;
|
||||
}
|
||||
|
||||
int32_t FX_Shutdown(void)
|
||||
int FX_Shutdown(void)
|
||||
{
|
||||
if (!FX_Installed)
|
||||
return FX_Ok;
|
||||
|
@ -103,7 +114,7 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
|
|||
|
||||
wavefmt_t fmt = FMT_UNKNOWN;
|
||||
|
||||
switch (B_LITTLE32(*(int32_t const *)ptr))
|
||||
switch (B_LITTLE32(*(int const *)ptr))
|
||||
{
|
||||
case 'C' + ('r' << 8) + ('e' << 16) + ('a' << 24): // Crea
|
||||
fmt = FMT_VOC;
|
||||
|
@ -112,7 +123,7 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
|
|||
fmt = FMT_VORBIS;
|
||||
break;
|
||||
case 'R' + ('I' << 8) + ('F' << 16) + ('F' << 24): // RIFF
|
||||
switch (B_LITTLE32(*(int32_t const *)(ptr + 8)))
|
||||
switch (B_LITTLE32(*(int const *)(ptr + 8)))
|
||||
{
|
||||
case 'C' + ('D' << 8) + ('X' << 16) + ('A' << 24): // CDXA
|
||||
fmt = FMT_XA;
|
||||
|
@ -134,10 +145,10 @@ static wavefmt_t FX_DetectFormat(char const * const ptr, uint32_t length)
|
|||
return fmt;
|
||||
}
|
||||
|
||||
int32_t FX_Play(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, float volume, intptr_t callbackval)
|
||||
int FX_Play(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitchoffset,
|
||||
int vol, int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
static int32_t(*const func[])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, float, intptr_t) =
|
||||
static constexpr decltype(MV_PlayVOC) *func[] =
|
||||
{ nullptr, nullptr, MV_PlayVOC, MV_PlayWAV, MV_PlayVorbis, MV_PlayFLAC, MV_PlayXA, MV_PlayXMP };
|
||||
|
||||
EDUKE32_STATIC_ASSERT(FMT_MAX == ARRAY_SIZE(func));
|
||||
|
@ -156,10 +167,10 @@ int32_t FX_Play(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loopen
|
|||
return handle;
|
||||
}
|
||||
|
||||
int32_t FX_Play3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance,
|
||||
int32_t priority, float volume, intptr_t callbackval)
|
||||
int FX_Play3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int angle, int distance,
|
||||
int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
static int32_t (*const func[])(char *, uint32_t, int32_t, int32_t, int32_t, int32_t, int32_t, float, intptr_t) =
|
||||
static constexpr decltype(MV_PlayVOC3D) *func[] =
|
||||
{ nullptr, nullptr, MV_PlayVOC3D, MV_PlayWAV3D, MV_PlayVorbis3D, MV_PlayFLAC3D, MV_PlayXA3D, MV_PlayXMP3D };
|
||||
|
||||
EDUKE32_STATIC_ASSERT(FMT_MAX == ARRAY_SIZE(func));
|
||||
|
@ -178,35 +189,7 @@ int32_t FX_Play3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitcho
|
|||
return handle;
|
||||
}
|
||||
|
||||
int32_t FX_PlayRaw(char *ptr, uint32_t ptrlength, int32_t rate, int32_t pitchoffset, int32_t vol,
|
||||
int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
{
|
||||
int handle = MV_PlayRAW(ptr, ptrlength, rate, NULL, NULL, pitchoffset, vol, left, right, priority, volume, callbackval);
|
||||
|
||||
if (handle <= MV_Ok)
|
||||
{
|
||||
FX_SetErrorCode(FX_MultiVocError);
|
||||
handle = FX_Warning;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
int32_t FX_PlayLoopedRaw(char *ptr, uint32_t ptrlength, char *loopstart, char *loopend, int32_t rate,
|
||||
int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
{
|
||||
int handle = MV_PlayRAW(ptr, ptrlength, rate, loopstart, loopend, pitchoffset, vol, left, right, priority, volume, callbackval);
|
||||
|
||||
if (handle <= MV_Ok)
|
||||
{
|
||||
FX_SetErrorCode(FX_MultiVocError);
|
||||
handle = FX_Warning;
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
int32_t FX_SetPrintf(void (*function)(const char *, ...))
|
||||
int FX_SetPrintf(void (*function)(const char *, ...))
|
||||
{
|
||||
MV_SetPrintf(function);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ template uint32_t MV_MixMono<uint8_t, int16_t>(struct VoiceNode * const voice, u
|
|||
template uint32_t MV_MixStereo<uint8_t, int16_t>(struct VoiceNode * const voice, uint32_t length);
|
||||
template uint32_t MV_MixMono<int16_t, int16_t>(struct VoiceNode * const voice, uint32_t length);
|
||||
template uint32_t MV_MixStereo<int16_t, int16_t>(struct VoiceNode * const voice, uint32_t length);
|
||||
template void MV_Reverb<int16_t>(char const *src, char * const dest, const float volume, int32_t count);
|
||||
template void MV_Reverb<int16_t>(char const *src, char * const dest, const float volume, int count);
|
||||
|
||||
/*
|
||||
length = count of samples to mix
|
||||
|
@ -95,7 +95,7 @@ uint32_t MV_MixStereo(struct VoiceNode * const voice, uint32_t length)
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
void MV_Reverb(char const *src, char * const dest, const float volume, int32_t count)
|
||||
void MV_Reverb(char const *src, char * const dest, const float volume, int count)
|
||||
{
|
||||
auto input = (T const *)src;
|
||||
auto output = (T *)dest;
|
||||
|
|
|
@ -46,66 +46,55 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
static void MV_StopVoice(VoiceNode *voice);
|
||||
static void MV_ServiceVoc(void);
|
||||
|
||||
static VoiceNode *MV_GetVoice(int32_t handle);
|
||||
static VoiceNode *MV_GetVoice(int handle);
|
||||
|
||||
static int32_t MV_ReverbLevel;
|
||||
static int32_t MV_ReverbDelay;
|
||||
static int MV_ReverbLevel;
|
||||
static int MV_ReverbDelay;
|
||||
static float MV_ReverbVolume;
|
||||
|
||||
Pan MV_PanTable[MV_NUMPANPOSITIONS][MV_MAXVOLUME + 1];
|
||||
|
||||
int32_t MV_Installed;
|
||||
static int32_t MV_TotalVolume = MV_MAXTOTALVOLUME;
|
||||
static int32_t MV_MaxVoices = 1;
|
||||
int MV_Installed;
|
||||
static int MV_TotalVolume = MV_MAXTOTALVOLUME;
|
||||
static int MV_MaxVoices = 1;
|
||||
|
||||
static int32_t MV_BufferSize = MV_MIXBUFFERSIZE;
|
||||
static int32_t MV_BufferLength;
|
||||
static int MV_BufferSize = MV_MIXBUFFERSIZE;
|
||||
static int MV_BufferLength;
|
||||
|
||||
static int32_t MV_NumberOfBuffers = MV_NUMBEROFBUFFERS;
|
||||
static int MV_NumberOfBuffers = MV_NUMBEROFBUFFERS;
|
||||
|
||||
static int32_t MV_Channels = 1;
|
||||
static int MV_Channels = 1;
|
||||
|
||||
static int32_t MV_ReverseStereo;
|
||||
static int MV_ReverseStereo;
|
||||
|
||||
int32_t MV_MixRate;
|
||||
int MV_MixRate;
|
||||
|
||||
static int32_t MV_BufferEmpty[MV_NUMBEROFBUFFERS];
|
||||
char *MV_MixBuffer[MV_NUMBEROFBUFFERS + 1];
|
||||
static int MV_BufferEmpty[MV_NUMBEROFBUFFERS];
|
||||
char *MV_MixBuffer[(MV_NUMBEROFBUFFERS << 1) + 1];
|
||||
|
||||
static VoiceNode *MV_Voices;
|
||||
static VoiceNode VoiceList;
|
||||
static VoiceNode VoicePool;
|
||||
|
||||
static VoiceNode VoiceList;
|
||||
static VoiceNode VoicePool;
|
||||
|
||||
static int32_t MV_MixPage;
|
||||
static int MV_MixPage;
|
||||
|
||||
void (*MV_Printf)(const char *fmt, ...) = initprintf;
|
||||
static void (*MV_CallBackFunc)(uint32_t);
|
||||
|
||||
char *MV_MixDestination;
|
||||
int32_t MV_SampleSize = 1;
|
||||
int32_t MV_RightChannelOffset;
|
||||
int MV_SampleSize = 1;
|
||||
int MV_RightChannelOffset;
|
||||
|
||||
int32_t MV_ErrorCode = MV_NotInstalled;
|
||||
int MV_ErrorCode = MV_NotInstalled;
|
||||
|
||||
float MV_GlobalVolume = 1.f;
|
||||
float MV_VolumeSmooth = 1.f;
|
||||
|
||||
static int lockdepth;
|
||||
int MV_Locked;
|
||||
|
||||
static inline void MV_Lock(void)
|
||||
{
|
||||
if (!lockdepth++)
|
||||
SoundDriver_Lock();
|
||||
}
|
||||
|
||||
static inline void MV_Unlock(void)
|
||||
{
|
||||
if (!--lockdepth)
|
||||
SoundDriver_Unlock();
|
||||
else if (lockdepth < 0)
|
||||
MV_Printf("MV_Unlock(): lockdepth < 0!\n");
|
||||
}
|
||||
static char *MV_MusicBuffer;
|
||||
static void (*MV_MusicCallback)(char *buffer, int length) = NULL;
|
||||
static int MV_MixMusic = FALSE;
|
||||
|
||||
static bool MV_Mix(VoiceNode * const voice, int const buffer)
|
||||
{
|
||||
|
@ -119,7 +108,7 @@ static bool MV_Mix(VoiceNode * const voice, int const buffer)
|
|||
if (voice->priority == FX_MUSIC_PRIORITY)
|
||||
MV_GlobalVolume = 1.f;
|
||||
|
||||
int32_t length = MV_MIXBUFFERSIZE;
|
||||
int length = MV_MIXBUFFERSIZE;
|
||||
uint32_t bufsiz = voice->FixedPointBufferSize;
|
||||
uint32_t const rate = voice->RateScale;
|
||||
|
||||
|
@ -128,7 +117,7 @@ static bool MV_Mix(VoiceNode * const voice, int const buffer)
|
|||
// Add this voice to the mix
|
||||
do
|
||||
{
|
||||
int32_t mixlen = length;
|
||||
int mixlen = length;
|
||||
uint32_t const position = voice->position;
|
||||
uint32_t const voclen = voice->length;
|
||||
|
||||
|
@ -237,7 +226,7 @@ static void MV_ServiceVoc(void)
|
|||
if (source < MV_MixBuffer[ 0 ])
|
||||
source += MV_BufferLength;
|
||||
|
||||
int32_t length = MV_BufferSize;
|
||||
int length = MV_BufferSize;
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -252,32 +241,50 @@ static void MV_ServiceVoc(void)
|
|||
} while (length > 0);
|
||||
}
|
||||
|
||||
if (!VoiceList.next || VoiceList.next == &VoiceList)
|
||||
return;
|
||||
|
||||
VoiceNode *voice = VoiceList.next;
|
||||
VoiceNode *next;
|
||||
|
||||
do
|
||||
if (VoiceList.next && VoiceList.next != &VoiceList)
|
||||
{
|
||||
next = voice->next;
|
||||
VoiceNode *voice = VoiceList.next;
|
||||
VoiceNode *next;
|
||||
|
||||
if (voice->Paused)
|
||||
continue;
|
||||
|
||||
MV_BufferEmpty[ MV_MixPage ] = FALSE;
|
||||
|
||||
// Is this voice done?
|
||||
if (!MV_Mix(voice, MV_MixPage))
|
||||
do
|
||||
{
|
||||
MV_CleanupVoice(voice);
|
||||
LL::Move(voice, &VoicePool);
|
||||
next = voice->next;
|
||||
|
||||
if (voice->Paused)
|
||||
continue;
|
||||
|
||||
MV_BufferEmpty[ MV_MixPage ] = FALSE;
|
||||
|
||||
// Is this voice done?
|
||||
if (!MV_Mix(voice, MV_MixPage))
|
||||
{
|
||||
MV_CleanupVoice(voice);
|
||||
LL::Move(voice, &VoicePool);
|
||||
}
|
||||
}
|
||||
while ((voice = next) != &VoiceList);
|
||||
}
|
||||
|
||||
Bmemcpy(MV_MixBuffer[MV_MixPage+MV_NumberOfBuffers], MV_MixBuffer[MV_MixPage], MV_BufferSize);
|
||||
|
||||
if (MV_MixMusic)
|
||||
{
|
||||
MV_MusicCallback(MV_MusicBuffer, MV_BufferSize);
|
||||
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 / 4; i++)
|
||||
{
|
||||
int sl = *source++;
|
||||
int sr = *source++;
|
||||
*dest = clamp(*dest+sl,INT16_MIN, INT16_MAX);
|
||||
dest++;
|
||||
*dest = clamp(*dest+sr,INT16_MIN, INT16_MAX);
|
||||
dest++;
|
||||
}
|
||||
}
|
||||
while ((voice = next) != &VoiceList);
|
||||
}
|
||||
|
||||
static VoiceNode *MV_GetVoice(int32_t handle)
|
||||
static VoiceNode *MV_GetVoice(int handle)
|
||||
{
|
||||
if (handle < MV_MINVOICEHANDLE || handle > MV_MaxVoices)
|
||||
{
|
||||
|
@ -301,7 +308,7 @@ static VoiceNode *MV_GetVoice(int32_t handle)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
VoiceNode *MV_BeginService(int32_t handle)
|
||||
VoiceNode *MV_BeginService(int handle)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return nullptr;
|
||||
|
@ -321,12 +328,12 @@ VoiceNode *MV_BeginService(int32_t handle)
|
|||
|
||||
static inline void MV_EndService(void) { MV_Unlock(); }
|
||||
|
||||
int32_t MV_VoicePlaying(int32_t handle)
|
||||
int MV_VoicePlaying(int handle)
|
||||
{
|
||||
return (MV_Installed && MV_GetVoice(handle)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
int32_t MV_KillAllVoices(void)
|
||||
int MV_KillAllVoices(void)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
@ -359,7 +366,7 @@ int32_t MV_KillAllVoices(void)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_Kill(int32_t handle)
|
||||
int MV_Kill(int handle)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -372,7 +379,7 @@ int32_t MV_Kill(int32_t handle)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_VoicesPlaying(void)
|
||||
int MV_VoicesPlaying(void)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return 0;
|
||||
|
@ -389,7 +396,7 @@ int32_t MV_VoicesPlaying(void)
|
|||
return NumVoices;
|
||||
}
|
||||
|
||||
VoiceNode *MV_AllocVoice(int32_t priority)
|
||||
VoiceNode *MV_AllocVoice(int priority)
|
||||
{
|
||||
VoiceNode *voice;
|
||||
|
||||
|
@ -420,7 +427,7 @@ VoiceNode *MV_AllocVoice(int32_t priority)
|
|||
LL::Remove(voice);
|
||||
MV_Unlock();
|
||||
|
||||
int32_t vhan = MV_MINVOICEHANDLE;
|
||||
int vhan = MV_MINVOICEHANDLE;
|
||||
|
||||
// Find a free voice handle
|
||||
do
|
||||
|
@ -434,7 +441,7 @@ VoiceNode *MV_AllocVoice(int32_t priority)
|
|||
return voice;
|
||||
}
|
||||
|
||||
int32_t MV_VoiceAvailable(int32_t priority)
|
||||
int MV_VoiceAvailable(int priority)
|
||||
{
|
||||
// Check if we have any free voices
|
||||
if (!LL::Empty(&VoicePool))
|
||||
|
@ -461,7 +468,7 @@ int32_t MV_VoiceAvailable(int32_t priority)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int32_t pitchoffset)
|
||||
void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int pitchoffset)
|
||||
{
|
||||
voice->SamplingRate = rate;
|
||||
voice->PitchScale = PITCH_GetScale(pitchoffset);
|
||||
|
@ -472,7 +479,7 @@ void MV_SetVoicePitch(VoiceNode *voice, uint32_t rate, int32_t pitchoffset)
|
|||
voice->RateScale;
|
||||
}
|
||||
|
||||
int32_t MV_SetPitch(int32_t handle, int32_t pitchoffset)
|
||||
int MV_SetPitch(int handle, int pitchoffset)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -485,7 +492,7 @@ int32_t MV_SetPitch(int32_t handle, int32_t pitchoffset)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_SetFrequency(int32_t handle, int32_t frequency)
|
||||
int MV_SetFrequency(int handle, int frequency)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -539,7 +546,7 @@ void MV_SetVoiceMixMode(VoiceNode *voice)
|
|||
voice->mix = mixslut[type];
|
||||
}
|
||||
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t right, float volume)
|
||||
void MV_SetVoiceVolume(VoiceNode *voice, int vol, int left, int right, float volume)
|
||||
{
|
||||
if (MV_Channels == 1)
|
||||
left = right = vol;
|
||||
|
@ -553,7 +560,7 @@ void MV_SetVoiceVolume(VoiceNode *voice, int32_t vol, int32_t left, int32_t righ
|
|||
MV_SetVoiceMixMode(voice);
|
||||
}
|
||||
|
||||
int32_t MV_PauseVoice(int32_t handle, int32_t pause)
|
||||
int MV_PauseVoice(int handle, int pause)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -566,7 +573,7 @@ int32_t MV_PauseVoice(int32_t handle, int32_t pause)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_GetPosition(int32_t handle, int32_t *position)
|
||||
int MV_GetPosition(int handle, int *position)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -594,7 +601,7 @@ int32_t MV_GetPosition(int32_t handle, int32_t *position)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_SetPosition(int32_t handle, int32_t position)
|
||||
int MV_SetPosition(int handle, int position)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -622,7 +629,7 @@ int32_t MV_SetPosition(int32_t handle, int32_t position)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_EndLooping(int32_t handle)
|
||||
int MV_EndLooping(int handle)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -638,7 +645,7 @@ int32_t MV_EndLooping(int32_t handle)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right)
|
||||
int MV_SetPan(int handle, int vol, int left, int right)
|
||||
{
|
||||
VoiceNode *voice = MV_BeginService(handle);
|
||||
|
||||
|
@ -650,7 +657,7 @@ int32_t MV_SetPan(int32_t handle, int32_t vol, int32_t left, int32_t right)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_Pan3D(int32_t handle, int32_t angle, int32_t distance)
|
||||
int MV_Pan3D(int handle, int angle, int distance)
|
||||
{
|
||||
if (distance < 0)
|
||||
{
|
||||
|
@ -667,21 +674,21 @@ int32_t MV_Pan3D(int32_t handle, int32_t angle, int32_t distance)
|
|||
MV_PanTable[ angle ][ volume ].right);
|
||||
}
|
||||
|
||||
void MV_SetReverb(int32_t reverb)
|
||||
void MV_SetReverb(int reverb)
|
||||
{
|
||||
MV_ReverbLevel = MIX_VOLUME(reverb);
|
||||
MV_ReverbVolume = float(MV_ReverbLevel)*(1.f/MV_MAXVOLUME);
|
||||
}
|
||||
|
||||
int32_t MV_GetMaxReverbDelay(void) { return MV_MIXBUFFERSIZE * MV_NumberOfBuffers; }
|
||||
int32_t MV_GetReverbDelay(void) { return tabledivide32(MV_ReverbDelay, MV_SampleSize); }
|
||||
int MV_GetMaxReverbDelay(void) { return MV_MIXBUFFERSIZE * MV_NumberOfBuffers; }
|
||||
int MV_GetReverbDelay(void) { return tabledivide32(MV_ReverbDelay, MV_SampleSize); }
|
||||
|
||||
void MV_SetReverbDelay(int32_t delay)
|
||||
void MV_SetReverbDelay(int delay)
|
||||
{
|
||||
MV_ReverbDelay = max(MV_MIXBUFFERSIZE, min(delay, MV_GetMaxReverbDelay())) * MV_SampleSize;
|
||||
}
|
||||
|
||||
static int32_t MV_SetMixMode(int32_t numchannels)
|
||||
static int MV_SetMixMode(int numchannels)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Error;
|
||||
|
@ -699,17 +706,17 @@ static int32_t MV_SetMixMode(int32_t numchannels)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
static int32_t MV_StartPlayback(void)
|
||||
static int MV_StartPlayback(void)
|
||||
{
|
||||
// Initialize the buffers
|
||||
Bmemset(MV_MixBuffer[0], 0, MV_TOTALBUFFERSIZE);
|
||||
Bmemset(MV_MixBuffer[0], 0, MV_TOTALBUFFERSIZE << 1);
|
||||
|
||||
for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++)
|
||||
MV_BufferEmpty[buffer] = TRUE;
|
||||
|
||||
MV_MixPage = 1;
|
||||
|
||||
if (SoundDriver_BeginPlayback(MV_MixBuffer[0], MV_BufferSize, MV_NumberOfBuffers, MV_ServiceVoc) != MV_Ok)
|
||||
if (SoundDriver_PCM_BeginPlayback(MV_MixBuffer[0], MV_BufferSize, MV_NumberOfBuffers, MV_ServiceVoc) != MV_Ok)
|
||||
return MV_SetErrorCode(MV_DriverError);
|
||||
|
||||
return MV_Ok;
|
||||
|
@ -717,7 +724,7 @@ static int32_t MV_StartPlayback(void)
|
|||
|
||||
static void MV_StopPlayback(void)
|
||||
{
|
||||
SoundDriver_StopPlayback();
|
||||
SoundDriver_PCM_StopPlayback();
|
||||
|
||||
// Make sure all callbacks are done.
|
||||
MV_Lock();
|
||||
|
@ -733,16 +740,16 @@ static void MV_StopPlayback(void)
|
|||
|
||||
static void MV_CalcPanTable(void)
|
||||
{
|
||||
const int32_t HalfAngle = MV_NUMPANPOSITIONS / 2;
|
||||
const int32_t QuarterAngle = HalfAngle / 2;
|
||||
const int HalfAngle = MV_NUMPANPOSITIONS / 2;
|
||||
const int QuarterAngle = HalfAngle / 2;
|
||||
|
||||
for (int distance = 0; distance <= MV_MAXVOLUME; distance++)
|
||||
{
|
||||
const int32_t level = (255 * (MV_MAXVOLUME - distance)) / MV_MAXVOLUME;
|
||||
const int level = (255 * (MV_MAXVOLUME - distance)) / MV_MAXVOLUME;
|
||||
|
||||
for (int angle = 0; angle <= QuarterAngle; angle++)
|
||||
{
|
||||
const int32_t ramp = level - (level * angle) / QuarterAngle;
|
||||
const int ramp = level - (level * angle) / QuarterAngle;
|
||||
|
||||
MV_PanTable[angle][distance].left = ramp;
|
||||
MV_PanTable[angle][distance].right = level;
|
||||
|
@ -759,22 +766,22 @@ static void MV_CalcPanTable(void)
|
|||
}
|
||||
}
|
||||
|
||||
void MV_SetVolume(int32_t volume)
|
||||
void MV_SetVolume(int volume)
|
||||
{
|
||||
MV_TotalVolume = min(max(0, volume), MV_MAXTOTALVOLUME);
|
||||
MV_GlobalVolume = (float)volume / 255.f;
|
||||
// MV_CalcVolume(MV_TotalVolume);
|
||||
}
|
||||
|
||||
int32_t MV_GetVolume(void) { return MV_TotalVolume; }
|
||||
int MV_GetVolume(void) { return MV_TotalVolume; }
|
||||
|
||||
void MV_SetCallBack(void (*function)(uint32_t)) { MV_CallBackFunc = function; }
|
||||
|
||||
void MV_SetReverseStereo(int32_t setting) { MV_ReverseStereo = setting; }
|
||||
void MV_SetReverseStereo(int setting) { MV_ReverseStereo = setting; }
|
||||
|
||||
int32_t MV_GetReverseStereo(void) { return MV_ReverseStereo; }
|
||||
int MV_GetReverseStereo(void) { return MV_ReverseStereo; }
|
||||
|
||||
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, void *initdata)
|
||||
int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, void *initdata)
|
||||
{
|
||||
if (MV_Installed)
|
||||
MV_Shutdown();
|
||||
|
@ -782,7 +789,7 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
|
|||
MV_SetErrorCode(MV_Ok);
|
||||
|
||||
// MV_TotalMemory + 2: FIXME, see valgrind_errors.log
|
||||
int const totalmem = Voices * sizeof(VoiceNode) + MV_TOTALBUFFERSIZE + 2;
|
||||
int const totalmem = Voices * sizeof(VoiceNode) + (MV_TOTALBUFFERSIZE << 1) + 2;
|
||||
|
||||
char *ptr = (char *) Xaligned_alloc(16, totalmem);
|
||||
|
||||
|
@ -804,11 +811,11 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
|
|||
|
||||
MV_SetReverseStereo(FALSE);
|
||||
|
||||
ASS_SoundDriver = soundcard;
|
||||
ASS_PCMSoundDriver = soundcard;
|
||||
|
||||
// Initialize the sound card
|
||||
|
||||
if (SoundDriver_Init(&MixRate, &numchannels, initdata) != MV_Ok)
|
||||
if (SoundDriver_PCM_Init(&MixRate, &numchannels, initdata) != MV_Ok)
|
||||
MV_SetErrorCode(MV_DriverError);
|
||||
|
||||
if (MV_ErrorCode != MV_Ok)
|
||||
|
@ -831,8 +838,8 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
|
|||
MV_ReverbDelay = MV_BufferSize * 3;
|
||||
|
||||
// Make sure we don't cross a physical page
|
||||
MV_MixBuffer[ MV_NumberOfBuffers ] = ptr;
|
||||
for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++)
|
||||
MV_MixBuffer[ MV_NumberOfBuffers<<1 ] = ptr;
|
||||
for (int buffer = 0; buffer < MV_NumberOfBuffers<<1; buffer++)
|
||||
{
|
||||
MV_MixBuffer[ buffer ] = ptr;
|
||||
ptr += MV_BufferSize;
|
||||
|
@ -855,7 +862,7 @@ int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numc
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
int32_t MV_Shutdown(void)
|
||||
int MV_Shutdown(void)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_Ok;
|
||||
|
@ -868,7 +875,7 @@ int32_t MV_Shutdown(void)
|
|||
MV_StopPlayback();
|
||||
|
||||
// Shutdown the sound card
|
||||
SoundDriver_Shutdown();
|
||||
SoundDriver_PCM_Shutdown();
|
||||
|
||||
// Free any voices we allocated
|
||||
ALIGNED_FREE_AND_NULL(MV_Voices);
|
||||
|
@ -879,7 +886,7 @@ int32_t MV_Shutdown(void)
|
|||
MV_MaxVoices = 1;
|
||||
|
||||
// Release the descriptor from our mix buffer
|
||||
for (int buffer = 0; buffer < MV_NUMBEROFBUFFERS; buffer++)
|
||||
for (int buffer = 0; buffer < MV_NUMBEROFBUFFERS<<1; buffer++)
|
||||
MV_MixBuffer[ buffer ] = nullptr;
|
||||
|
||||
MV_SetErrorCode(MV_NotInstalled);
|
||||
|
@ -887,11 +894,27 @@ int32_t MV_Shutdown(void)
|
|||
return MV_Ok;
|
||||
}
|
||||
|
||||
void MV_HookMusicRoutine(void(*callback)(char *buffer, int length))
|
||||
{
|
||||
MV_Lock();
|
||||
MV_MusicCallback = callback;
|
||||
MV_MixMusic = TRUE;
|
||||
MV_Unlock();
|
||||
}
|
||||
|
||||
void MV_UnhookMusicRoutine(void)
|
||||
{
|
||||
MV_Lock();
|
||||
MV_MusicCallback = NULL;
|
||||
MV_MixMusic = FALSE;
|
||||
MV_Unlock();
|
||||
}
|
||||
|
||||
const char *loopStartTags[loopStartTagCount] = { "LOOP_START", "LOOPSTART", "LOOP" };
|
||||
const char *loopEndTags[loopEndTagCount] = { "LOOP_END", "LOOPEND" };
|
||||
const char *loopLengthTags[loopLengthTagCount] = { "LOOP_LENGTH", "LOOPLENGTH" };
|
||||
|
||||
const char *MV_ErrorString(int32_t ErrorNumber)
|
||||
const char *MV_ErrorString(int ErrorNumber)
|
||||
{
|
||||
switch (ErrorNumber)
|
||||
{
|
||||
|
@ -902,7 +925,7 @@ const char *MV_ErrorString(int32_t ErrorNumber)
|
|||
case MV_NotInstalled:
|
||||
return "Multivoc not installed.";
|
||||
case MV_DriverError:
|
||||
return SoundDriver_ErrorString(SoundDriver_GetError());
|
||||
return SoundDriver_PCM_ErrorString(SoundDriver_PCM_GetError());
|
||||
case MV_NoVoices:
|
||||
return "No free voices available to Multivoc.";
|
||||
case MV_NoMem:
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef struct {
|
|||
OggVorbis_File vf;
|
||||
|
||||
char block[BLOCKSIZE];
|
||||
int32_t lastbitstream;
|
||||
int lastbitstream;
|
||||
} vorbis_data;
|
||||
|
||||
// designed with multiple calls in mind
|
||||
|
@ -139,14 +139,14 @@ static size_t read_vorbis(void *ptr, size_t size, size_t nmemb, void *datasource
|
|||
if (vorb->length == vorb->pos)
|
||||
return 0;
|
||||
|
||||
int32_t nread = 0;
|
||||
int nread = 0;
|
||||
|
||||
for (; nmemb > 0; nmemb--, nread++)
|
||||
{
|
||||
int32_t bytes = vorb->length - vorb->pos;
|
||||
int bytes = vorb->length - vorb->pos;
|
||||
|
||||
if ((signed)size < bytes)
|
||||
bytes = (int32_t)size;
|
||||
bytes = (int)size;
|
||||
|
||||
memcpy(ptr, (uint8_t *)vorb->ptr + vorb->pos, bytes);
|
||||
vorb->pos += bytes;
|
||||
|
@ -198,14 +198,14 @@ static long tell_vorbis(void *datasource)
|
|||
static ov_callbacks vorbis_callbacks = { read_vorbis, seek_vorbis, close_vorbis, tell_vorbis };
|
||||
|
||||
|
||||
int32_t MV_GetVorbisPosition(VoiceNode *voice)
|
||||
int MV_GetVorbisPosition(VoiceNode *voice)
|
||||
{
|
||||
auto vd = (vorbis_data *) voice->rawdataptr;
|
||||
|
||||
return ov_pcm_tell(&vd->vf);
|
||||
}
|
||||
|
||||
void MV_SetVorbisPosition(VoiceNode *voice, int32_t position)
|
||||
void MV_SetVorbisPosition(VoiceNode *voice, int position)
|
||||
{
|
||||
auto vd = (vorbis_data *) voice->rawdataptr;
|
||||
|
||||
|
@ -222,14 +222,14 @@ static playbackstatus MV_GetNextVorbisBlock(VoiceNode *voice)
|
|||
{
|
||||
int bitstream;
|
||||
|
||||
int32_t bytesread = 0;
|
||||
int bytesread = 0;
|
||||
auto vd = (vorbis_data *)voice->rawdataptr;
|
||||
do
|
||||
{
|
||||
#ifdef USING_TREMOR
|
||||
int32_t bytes = ov_read(&vd->vf, vd->block + bytesread, BLOCKSIZE - bytesread, &bitstream);
|
||||
int bytes = ov_read(&vd->vf, vd->block + bytesread, BLOCKSIZE - bytesread, &bitstream);
|
||||
#else
|
||||
int32_t bytes = ov_read(&vd->vf, vd->block + bytesread, BLOCKSIZE - bytesread, 0, 2, 1, &bitstream);
|
||||
int bytes = ov_read(&vd->vf, vd->block + bytesread, BLOCKSIZE - bytesread, 0, 2, 1, &bitstream);
|
||||
#endif
|
||||
// fprintf(stderr, "ov_read = %d\n", bytes);
|
||||
if (bytes > 0)
|
||||
|
@ -324,7 +324,7 @@ Begin playback of sound data at specified angle and distance
|
|||
from listener.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int32_t MV_PlayVorbis3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayVorbis3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle, int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
if (!MV_Installed)
|
||||
return MV_SetErrorCode(MV_NotInstalled);
|
||||
|
@ -352,7 +352,7 @@ Begin playback of sound data with the given sound levels and
|
|||
priority.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayVorbis(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(loopend);
|
||||
|
||||
|
@ -370,7 +370,7 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
|
|||
|
||||
vd->lastbitstream = -1;
|
||||
|
||||
int32_t status = ov_open_callbacks((void *)vd, &vd->vf, 0, 0, vorbis_callbacks);
|
||||
int status = ov_open_callbacks((void *)vd, &vd->vf, 0, 0, vorbis_callbacks);
|
||||
|
||||
if (status < 0)
|
||||
{
|
||||
|
@ -457,8 +457,8 @@ void MV_ReleaseVorbisVoice( VoiceNode * voice )
|
|||
#else
|
||||
#include "_multivc.h"
|
||||
|
||||
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, float volume, intptr_t callbackval)
|
||||
int MV_PlayVorbis(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitchoffset,
|
||||
int vol, int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ptr);
|
||||
UNREFERENCED_PARAMETER(ptrlength);
|
||||
|
@ -476,8 +476,8 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t MV_PlayVorbis3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle,
|
||||
int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayVorbis3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int angle,
|
||||
int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ptr);
|
||||
UNREFERENCED_PARAMETER(ptrlength);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#if USE_FXD
|
||||
#define FXD_FxdToPcm16(dt) (max(min((dt)/2, 32767), -32768))
|
||||
#define FXD_Pcm16ToFxd(dt) ((int32_t)dt*2)
|
||||
#define FXD_Pcm16ToFxd(dt) ((int)dt*2)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
|
@ -39,8 +39,8 @@ typedef struct {
|
|||
size_t pos;
|
||||
|
||||
#if USE_FXD
|
||||
int32_t t1, t2;
|
||||
int32_t t1_x, t2_x;
|
||||
int t1, t2;
|
||||
int t1_x, t2_x;
|
||||
#else
|
||||
double t1, t2;
|
||||
double t1_x, t2_x;
|
||||
|
@ -59,17 +59,17 @@ typedef struct XASector {
|
|||
} XASector;
|
||||
|
||||
#if USE_FXD
|
||||
static int32_t K0[4] = {
|
||||
static int K0[4] = {
|
||||
0x00000000,
|
||||
0x0000F000,
|
||||
0x0001CC00,
|
||||
0x00018800,
|
||||
};
|
||||
static int32_t K1[4] = {
|
||||
static int K1[4] = {
|
||||
0x00000000,
|
||||
0x00000000,
|
||||
(int32_t)0xFFFF3000u,
|
||||
(int32_t)0xFFFF2400u,
|
||||
(int)0xFFFF3000u,
|
||||
(int)0xFFFF2400u,
|
||||
};
|
||||
#else
|
||||
static double K0[4] = {
|
||||
|
@ -88,12 +88,12 @@ static double K1[4] = {
|
|||
|
||||
|
||||
#if USE_FXD
|
||||
static int32_t FXD_FixMul(int32_t a, int32_t b)
|
||||
static int FXD_FixMul(int a, int b)
|
||||
{
|
||||
int32_t high_a, low_a, high_b, low_b;
|
||||
int32_t hahb, halb, lahb;
|
||||
int high_a, low_a, high_b, low_b;
|
||||
int hahb, halb, lahb;
|
||||
uint32_t lalb;
|
||||
int32_t ret;
|
||||
int ret;
|
||||
|
||||
high_a = a >> 16;
|
||||
low_a = a & 0x0000FFFF;
|
||||
|
@ -113,11 +113,11 @@ static int32_t FXD_FixMul(int32_t a, int32_t b)
|
|||
|
||||
|
||||
|
||||
static int8_t getSoundData(int8_t *buf, int32_t unit, int32_t sample)
|
||||
static int8_t getSoundData(int8_t *buf, int unit, int sample)
|
||||
{
|
||||
int8_t ret;
|
||||
int8_t *p;
|
||||
int32_t offset, shift;
|
||||
int offset, shift;
|
||||
|
||||
p = buf;
|
||||
shift = (unit%2) * 4;
|
||||
|
@ -133,13 +133,13 @@ static int8_t getSoundData(int8_t *buf, int32_t unit, int32_t sample)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int8_t getFilter(const int8_t *buf, int32_t unit)
|
||||
static int8_t getFilter(const int8_t *buf, int unit)
|
||||
{
|
||||
return (*(buf + 4 + unit) >> 4) & 0x03;
|
||||
}
|
||||
|
||||
|
||||
static int8_t getRange(const int8_t *buf, int32_t unit)
|
||||
static int8_t getRange(const int8_t *buf, int unit)
|
||||
{
|
||||
return *(buf + 4 + unit) & 0x0F;
|
||||
}
|
||||
|
@ -150,10 +150,10 @@ static void decodeSoundSectMono(XASector *ssct, xa_data * xad)
|
|||
size_t count = 0;
|
||||
int8_t snddat, filt, range;
|
||||
int16_t decoded;
|
||||
int32_t unit, sample;
|
||||
int32_t sndgrp;
|
||||
int unit, sample;
|
||||
int sndgrp;
|
||||
#if USE_FXD
|
||||
int32_t tmp2, tmp3, tmp4, tmp5;
|
||||
int tmp2, tmp3, tmp4, tmp5;
|
||||
#else
|
||||
double tmp2, tmp3, tmp4, tmp5;
|
||||
#endif
|
||||
|
@ -169,7 +169,7 @@ static void decodeSoundSectMono(XASector *ssct, xa_data * xad)
|
|||
{
|
||||
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit, sample);
|
||||
#if USE_FXD
|
||||
tmp2 = (int32_t)(snddat) << (12 - range);
|
||||
tmp2 = (int)(snddat) << (12 - range);
|
||||
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
||||
tmp4 = FXD_FixMul(K0[filt], xad->t1);
|
||||
tmp5 = FXD_FixMul(K1[filt], xad->t2);
|
||||
|
@ -200,10 +200,10 @@ static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
|||
int8_t snddat, filt, range;
|
||||
int8_t filt1, range1;
|
||||
int16_t decoded;
|
||||
int32_t unit, sample;
|
||||
int32_t sndgrp;
|
||||
int unit, sample;
|
||||
int sndgrp;
|
||||
#if USE_FXD
|
||||
int32_t tmp2, tmp3, tmp4, tmp5;
|
||||
int tmp2, tmp3, tmp4, tmp5;
|
||||
#else
|
||||
double tmp2, tmp3, tmp4, tmp5;
|
||||
#endif
|
||||
|
@ -223,7 +223,7 @@ static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
|||
// Channel 1
|
||||
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit, sample);
|
||||
#if USE_FXD
|
||||
tmp2 = (int32_t)(snddat) << (12 - range);
|
||||
tmp2 = (int)(snddat) << (12 - range);
|
||||
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
||||
tmp4 = FXD_FixMul(K0[filt], xad->t1);
|
||||
tmp5 = FXD_FixMul(K1[filt], xad->t2);
|
||||
|
@ -245,7 +245,7 @@ static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
|||
// Channel 2
|
||||
snddat = getSoundData(ssct->SoundGroups[sndgrp], unit+1, sample);
|
||||
#if USE_FXD
|
||||
tmp2 = (int32_t)(snddat) << (12 - range1);
|
||||
tmp2 = (int)(snddat) << (12 - range1);
|
||||
tmp3 = FXD_Pcm16ToFxd(tmp2);
|
||||
tmp4 = FXD_FixMul(K0[filt1], xad->t1_x);
|
||||
tmp5 = FXD_FixMul(K1[filt1], xad->t2_x);
|
||||
|
@ -270,13 +270,13 @@ static void decodeSoundSectStereo(XASector *ssct, xa_data * xad)
|
|||
memcpy(xad->block, decodeBuf, kBufSize);
|
||||
}
|
||||
|
||||
int32_t MV_GetXAPosition(VoiceNode *voice)
|
||||
int MV_GetXAPosition(VoiceNode *voice)
|
||||
{
|
||||
auto xad = (xa_data *) voice->rawdataptr;
|
||||
return xad->pos;
|
||||
}
|
||||
|
||||
void MV_SetXAPosition(VoiceNode *voice, int32_t position)
|
||||
void MV_SetXAPosition(VoiceNode *voice, int position)
|
||||
{
|
||||
auto xad = (xa_data *) voice->rawdataptr;
|
||||
|
||||
|
@ -369,14 +369,14 @@ Begin playback of sound data at specified angle and distance
|
|||
from listener.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int32_t MV_PlayXA3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority, float volume,
|
||||
intptr_t callbackval)
|
||||
int MV_PlayXA3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle, int distance, int priority, float volume,
|
||||
uint32_t callbackval)
|
||||
{
|
||||
int32_t left;
|
||||
int32_t right;
|
||||
int32_t mid;
|
||||
int32_t vol;
|
||||
int32_t status;
|
||||
int left;
|
||||
int right;
|
||||
int mid;
|
||||
int vol;
|
||||
int status;
|
||||
|
||||
if (!MV_Installed)
|
||||
return MV_SetErrorCode(MV_NotInstalled);
|
||||
|
@ -409,8 +409,8 @@ Begin playback of sound data with the given sound levels and
|
|||
priority.
|
||||
---------------------------------------------------------------------*/
|
||||
|
||||
int32_t MV_PlayXA(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right,
|
||||
int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayXA(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol, int left, int right,
|
||||
int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
VoiceNode *voice;
|
||||
xa_data * xad = 0;
|
||||
|
|
|
@ -18,13 +18,13 @@ typedef struct {
|
|||
int time;
|
||||
} xmp_data;
|
||||
|
||||
int32_t MV_GetXMPPosition(VoiceNode *voice)
|
||||
int MV_GetXMPPosition(VoiceNode *voice)
|
||||
{
|
||||
auto xmpd = (xmp_data *)voice->rawdataptr;
|
||||
return xmpd->time;
|
||||
}
|
||||
|
||||
void MV_SetXMPPosition(VoiceNode *voice, int32_t position)
|
||||
void MV_SetXMPPosition(VoiceNode *voice, int position)
|
||||
{
|
||||
auto xmpd = (xmp_data *)voice->rawdataptr;
|
||||
xmp_seek_time(xmpd->context, position);
|
||||
|
@ -64,13 +64,13 @@ static playbackstatus MV_GetNextXMPBlock(VoiceNode *voice)
|
|||
return KeepPlaying;
|
||||
}
|
||||
|
||||
int32_t MV_PlayXMP3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitchoffset, int32_t angle, int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayXMP3D(char *ptr, uint32_t length, int loophow, int pitchoffset, int angle, int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
int32_t left;
|
||||
int32_t right;
|
||||
int32_t mid;
|
||||
int32_t vol;
|
||||
int32_t status;
|
||||
int left;
|
||||
int right;
|
||||
int mid;
|
||||
int vol;
|
||||
int status;
|
||||
|
||||
if (!MV_Installed)
|
||||
return MV_SetErrorCode(MV_NotInstalled);
|
||||
|
@ -95,7 +95,7 @@ int32_t MV_PlayXMP3D(char *ptr, uint32_t length, int32_t loophow, int32_t pitcho
|
|||
return status;
|
||||
}
|
||||
|
||||
int32_t MV_PlayXMP(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend, int32_t pitchoffset, int32_t vol, int32_t left, int32_t right, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayXMP(char *ptr, uint32_t length, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
VoiceNode *voice;
|
||||
xmp_data * xmpd = 0;
|
||||
|
@ -199,8 +199,8 @@ void MV_ReleaseXMPVoice(VoiceNode * voice)
|
|||
|
||||
static char const NoXMP[] = "MV_PlayXMP: libxmp-lite support not included in this binary.\n";
|
||||
|
||||
int32_t MV_PlayXMP(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, float volume, intptr_t callbackval)
|
||||
int MV_PlayXMP(char *ptr, uint32_t ptrlength, int loopstart, int loopend, int pitchoffset, int vol,
|
||||
int left, int right, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ptr);
|
||||
UNREFERENCED_PARAMETER(ptrlength);
|
||||
|
@ -218,8 +218,8 @@ int32_t MV_PlayXMP(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t MV_PlayXMP3D(char *ptr, uint32_t ptrlength, int32_t loophow, int32_t pitchoffset, int32_t angle,
|
||||
int32_t distance, int32_t priority, float volume, intptr_t callbackval)
|
||||
int MV_PlayXMP3D(char *ptr, uint32_t ptrlength, int loophow, int pitchoffset, int angle,
|
||||
int distance, int priority, float volume, uint32_t callbackval)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(ptr);
|
||||
UNREFERENCED_PARAMETER(ptrlength);
|
||||
|
|
|
@ -58,7 +58,7 @@ static inline void S_SetProperties(assvoice_t *snd, int const owner, int const v
|
|||
|
||||
void S_SoundStartup(void)
|
||||
{
|
||||
#ifdef MIXERTYPEWIN
|
||||
#ifdef _WIN32
|
||||
void *initdata = (void *) win_gethwnd(); // used for DirectSound
|
||||
#else
|
||||
void *initdata = NULL;
|
||||
|
@ -114,7 +114,7 @@ void S_MusicStartup(void)
|
|||
{
|
||||
initprintf("Initializing music...\n");
|
||||
|
||||
if (MUSIC_Init(0, 0) == MUSIC_Ok || MUSIC_Init(1, 0) == MUSIC_Ok)
|
||||
if (MUSIC_Init(ud.config.MusicDevice) == MUSIC_Ok || MUSIC_Init(0) == MUSIC_Ok || MUSIC_Init(1) == MUSIC_Ok)
|
||||
{
|
||||
MUSIC_SetVolume(mus_volume);
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue