git-svn-id: https://svn.eduke32.com/eduke32@647 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-03-17 07:08:56 +00:00
parent 5d1abf26a8
commit 43a7dc4d33
5 changed files with 150 additions and 150 deletions

View file

@ -83,129 +83,136 @@ Modifications for JonoF's port by Jonathon Fowler (jonof@edgenetwk.com)
#define PI 3.1415926536 #define PI 3.1415926536
typedef enum typedef enum
{ {
Raw, Raw,
VOC, VOC,
DemandFeed, DemandFeed,
WAV, WAV,
OGG OGG
} wavedata; } wavedata;
typedef enum typedef enum
{ {
NoMoreData, NoMoreData,
KeepPlaying KeepPlaying
} playbackstatus; } playbackstatus;
typedef struct sounddef
{
unsigned pos;
char *ptrsnd;
unsigned size;
OggVorbis_File oggStream;
} sounddef;
typedef struct VoiceNode typedef struct VoiceNode
{ {
struct VoiceNode *next; struct VoiceNode *next;
struct VoiceNode *prev; struct VoiceNode *prev;
wavedata wavetype; wavedata wavetype;
char bits; char bits;
playbackstatus ( *GetSound )( struct VoiceNode *voice ); playbackstatus(*GetSound)(struct VoiceNode *voice);
void ( *mix )( unsigned int position, unsigned int rate, void (*mix)(unsigned int position, unsigned int rate,
char *start, unsigned int length ); char *start, unsigned int length);
char *NextBlock; char *NextBlock;
char *LoopStart; char *LoopStart;
char *LoopEnd; char *LoopEnd;
unsigned LoopCount; unsigned LoopCount;
unsigned int LoopSize; unsigned int LoopSize;
unsigned int BlockLength; unsigned int BlockLength;
unsigned int PitchScale; unsigned int PitchScale;
unsigned int FixedPointBufferSize; unsigned int FixedPointBufferSize;
char *sound; char *sound;
unsigned int length; unsigned int length;
unsigned int SamplingRate; unsigned int SamplingRate;
unsigned int RateScale; unsigned int RateScale;
unsigned int position; unsigned int position;
int Playing; int Playing;
int handle; int handle;
int priority; int priority;
void ( *DemandFeed )( char **ptr, unsigned int *length ); void (*DemandFeed)(char **ptr, unsigned int *length);
struct sounddef OGGstream; struct sounddef OGGstream;
// char *bufsnd; // char *bufsnd;
char bufsnd[0x8000*4]; char bufsnd[0x8000*4];
int downsample; int downsample;
short *LeftVolume; short *LeftVolume;
short *RightVolume; short *RightVolume;
unsigned int callbackval; unsigned int callbackval;
} VoiceNode; } VoiceNode;
typedef struct typedef struct
{ {
VoiceNode *start; VoiceNode *start;
VoiceNode *end; VoiceNode *end;
} VList; } VList;
typedef struct typedef struct
{ {
char left; char left;
char right; char right;
} Pan; } Pan;
typedef signed short MONO16; typedef signed short MONO16;
typedef signed char MONO8; typedef signed char MONO8;
typedef struct typedef struct
{ {
MONO16 left; MONO16 left;
MONO16 right; MONO16 right;
// unsigned short left; // unsigned short left;
// unsigned short right; // unsigned short right;
} STEREO16; } STEREO16;
typedef struct typedef struct
{ {
MONO16 left; MONO16 left;
MONO16 right; MONO16 right;
} SIGNEDSTEREO16; } SIGNEDSTEREO16;
typedef struct typedef struct
{ {
// MONO8 left; // MONO8 left;
// MONO8 right; // MONO8 right;
char left; char left;
char right; char right;
} STEREO8; } STEREO8;
typedef struct typedef struct
{ {
char RIFF[ 4 ]; char RIFF[ 4 ];
unsigned int file_size; unsigned int file_size;
char WAVE[ 4 ]; char WAVE[ 4 ];
char fmt[ 4 ]; char fmt[ 4 ];
unsigned int format_size; unsigned int format_size;
} riff_header; } riff_header;
typedef struct typedef struct
{ {
unsigned short wFormatTag; unsigned short wFormatTag;
unsigned short nChannels; unsigned short nChannels;
unsigned int nSamplesPerSec; unsigned int nSamplesPerSec;
unsigned int nAvgBytesPerSec; unsigned int nAvgBytesPerSec;
unsigned short nBlockAlign; unsigned short nBlockAlign;
unsigned short nBitsPerSample; unsigned short nBitsPerSample;
} format_header; } format_header;
typedef struct typedef struct
{ {
unsigned char DATA[ 4 ]; unsigned char DATA[ 4 ];
unsigned int size; unsigned int size;
} data_header; } data_header;
typedef MONO8 VOLUME8[ 256 ]; typedef MONO8 VOLUME8[ 256 ];
typedef MONO16 VOLUME16[ 256 ]; typedef MONO16 VOLUME16[ 256 ];
@ -214,27 +221,27 @@ typedef char HARSH_CLIP_TABLE_8[ MV_NumVoices * 256 ];
static unsigned MV_GetBufferSize(unsigned); static unsigned MV_GetBufferSize(unsigned);
static void MV_Mix( VoiceNode *voice, int buffer ); static void MV_Mix(VoiceNode *voice, int buffer);
static void MV_PlayVoice( VoiceNode *voice ); static void MV_PlayVoice(VoiceNode *voice);
static void MV_StopVoice( VoiceNode *voice ); static void MV_StopVoice(VoiceNode *voice);
static int MV_ServiceVoc( int ); static int MV_ServiceVoc(int);
static playbackstatus MV_GetNextVOCBlock( VoiceNode *voice ); static playbackstatus MV_GetNextVOCBlock(VoiceNode *voice);
static playbackstatus MV_GetNextDemandFeedBlock( VoiceNode *voice ); static playbackstatus MV_GetNextDemandFeedBlock(VoiceNode *voice);
static playbackstatus MV_GetNextRawBlock( VoiceNode *voice ); static playbackstatus MV_GetNextRawBlock(VoiceNode *voice);
static playbackstatus MV_GetNextWAVBlock( VoiceNode *voice ); static playbackstatus MV_GetNextWAVBlock(VoiceNode *voice);
// static void MV_ServiceRecord( void ); // static void MV_ServiceRecord( void );
static VoiceNode *MV_GetVoice( int handle ); static VoiceNode *MV_GetVoice(int handle);
static VoiceNode *MV_AllocVoice( int priority ); static VoiceNode *MV_AllocVoice(int priority);
static short *MV_GetVolumeTable( int vol ); static short *MV_GetVolumeTable(int vol);
static void MV_SetVoiceMixMode( VoiceNode *voice ); static void MV_SetVoiceMixMode(VoiceNode *voice);
static void MV_SetVoicePitch( VoiceNode *voice, unsigned int rate, int pitchoffset ); static void MV_SetVoicePitch(VoiceNode *voice, unsigned int rate, int pitchoffset);
static void MV_CalcVolume( int MaxLevel ); static void MV_CalcVolume(int MaxLevel);
static void MV_CalcPanTable( void ); static void MV_CalcPanTable(void);
static void ClearBuffer_DW(void *ptr, int data, int length); static void ClearBuffer_DW(void *ptr, int data, int length);
@ -289,34 +296,34 @@ parm [ edi ] [ eax ] [ ecx ] modify exact [ ecx edi ];
#endif #endif
void CDEC MV_Mix8BitMono( unsigned int position, unsigned int rate, void CDEC MV_Mix8BitMono(unsigned int position, unsigned int rate,
char *start, unsigned int length ); char *start, unsigned int length);
void CDEC MV_Mix8BitStereo( unsigned int position, void CDEC MV_Mix8BitStereo(unsigned int position,
unsigned int rate, char *start, unsigned int length ); unsigned int rate, char *start, unsigned int length);
void CDEC MV_Mix16BitMono( unsigned int position, void CDEC MV_Mix16BitMono(unsigned int position,
unsigned int rate, char *start, unsigned int length ); unsigned int rate, char *start, unsigned int length);
void CDEC MV_Mix16BitStereo( unsigned int position, void CDEC MV_Mix16BitStereo(unsigned int position,
unsigned int rate, char *start, unsigned int length ); unsigned int rate, char *start, unsigned int length);
void CDEC MV_Mix16BitMono16( unsigned int position, void CDEC MV_Mix16BitMono16(unsigned int position,
unsigned int rate, char *start, unsigned int length ); unsigned int rate, char *start, unsigned int length);
void CDEC MV_Mix8BitMono16( unsigned int position, unsigned int rate, void CDEC MV_Mix8BitMono16(unsigned int position, unsigned int rate,
char *start, unsigned int length ); char *start, unsigned int length);
void CDEC MV_Mix8BitStereo16( unsigned int position, void CDEC MV_Mix8BitStereo16(unsigned int position,
unsigned int rate, char *start, unsigned int length ); unsigned int rate, char *start, unsigned int length);
void CDEC MV_Mix16BitStereo16( unsigned int position, void CDEC MV_Mix16BitStereo16(unsigned int position,
unsigned int rate, char *start, unsigned int length ); unsigned int rate, char *start, unsigned int length);
void CDEC MV_16BitReverb( char *src, char *dest, VOLUME16 *volume, int count ); void CDEC MV_16BitReverb(char *src, char *dest, VOLUME16 *volume, int count);
void CDEC MV_8BitReverb( signed char *src, signed char *dest, VOLUME16 *volume, int count ); void CDEC MV_8BitReverb(signed char *src, signed char *dest, VOLUME16 *volume, int count);
void CDEC MV_16BitReverbFast( char *src, char *dest, int count, int shift ); void CDEC MV_16BitReverbFast(char *src, char *dest, int count, int shift);
void CDEC MV_8BitReverbFast( signed char *src, signed char *dest, int count, int shift ); void CDEC MV_8BitReverbFast(signed char *src, signed char *dest, int count, int shift);
#undef CDEC #undef CDEC

View file

@ -1758,12 +1758,15 @@ int MV_SetMixMode(int numchannels, int samplebits)
// OGG file // OGG file
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
ov_callbacks cb; ov_callbacks cb;
size_t ReadOgg(void *ptr, size_t size1, size_t nmemb, void *datasource) size_t ReadOgg(void *ptr, size_t size1, size_t nmemb, void *datasource)
{ {
sounddef *d=(sounddef *)datasource; sounddef *d=(sounddef *)datasource;
size1*=nmemb; size1*=nmemb;
if (d->pos>=d->size)return 0; if (d->pos>=d->size)
if (d->pos+size1>=d->size)size1=d->size-d->pos; return 0;
if (d->pos+size1>=d->size)
size1=d->size-d->pos;
Bmemcpy(ptr,(d->ptrsnd+d->pos),size1); Bmemcpy(ptr,(d->ptrsnd+d->pos),size1);
d->pos+=size1; d->pos+=size1;
return size1; return size1;
@ -1774,12 +1777,19 @@ int SeekOgg(void *datasource,ogg_int64_t offset,int whence)
sounddef *d=(sounddef *)datasource; sounddef *d=(sounddef *)datasource;
switch (whence) switch (whence)
{ {
case SEEK_SET: whence=offset;break; case SEEK_SET:
case SEEK_CUR: whence=d->pos+offset;break; whence=offset;
case SEEK_END: whence=d->size-offset-1;break; break;
case SEEK_CUR:
whence=d->pos+offset;
break;
case SEEK_END:
whence=d->size-offset-1;
break;
default: return -1; default: return -1;
} }
if (whence>=(int)d->size||whence<0)return -1; if (whence>=(int)d->size||whence<0)
return -1;
d->pos=whence; d->pos=whence;
return 0; return 0;
} }
@ -2436,7 +2446,7 @@ int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int
while ((ogg_int64_t)(vorbisInfo->rate)/(1<<voice->downsample)*PITCH_GetScale(pitchoffset)/0x1000000/0x100) while ((ogg_int64_t)(vorbisInfo->rate)/(1<<voice->downsample)*PITCH_GetScale(pitchoffset)/0x1000000/0x100)
voice->downsample++; voice->downsample++;
length=ov_pcm_total(&voice->OGGstream.oggStream,0); length=ov_pcm_total(&voice->OGGstream.oggStream,-1);
// if (!length)length=0xffffff; // if (!length)length=0xffffff;
if (length == OV_EINVAL) if (length == OV_EINVAL)
{ {
@ -2474,7 +2484,8 @@ int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int
} }
MV_SetVoicePitch(voice, vorbisInfo->rate>>voice->downsample, pitchoffset); MV_SetVoicePitch(voice, vorbisInfo->rate>>voice->downsample, pitchoffset);
if (vorbisInfo->channels==2)voice->downsample++; if (vorbisInfo->channels==2)
voice->downsample++;
MV_SetVoiceVolume(voice, vol, left, right); MV_SetVoiceVolume(voice, vol, left, right);
MV_PlayVoice(voice); MV_PlayVoice(voice);

View file

@ -16,13 +16,5 @@ void AL_Pause();
void AL_Continue(); void AL_Continue();
void AL_SetMusicVolume(int volume); void AL_SetMusicVolume(int volume);
typedef struct sounddef
{
unsigned pos;
char *ptrsnd;
unsigned size;
OggVorbis_File oggStream;
}sounddef;
int openal_disabled; int openal_disabled;
#endif #endif

View file

@ -174,7 +174,7 @@ char *MUSIC_ErrorString(int ErrorNumber)
int MUSIC_Init(int SoundCard, int Address) int MUSIC_Init(int SoundCard, int Address)
{ {
// Use an external MIDI player if the user has specified to do so // Use an external MIDI player if the user has specified to do so
char *command = getenv("EDUKE32_MIDI_CMD"); char *command = getenv("EDUKE32_MUSIC_CMD");
external_midi = (command != NULL && command[0] != 0); external_midi = (command != NULL && command[0] != 0);
if(external_midi) if(external_midi)
Mix_SetMusicCMD(command); Mix_SetMusicCMD(command);
@ -297,11 +297,6 @@ int MUSIC_StopSong(void)
// Duke3D-specific. --ryan. // Duke3D-specific. --ryan.
void PlayMusic(char *_filename) void PlayMusic(char *_filename)
{ {
//char filename[MAX_PATH];
//strcpy(filename, _filename);
//FixFilePath(filename);
char filename[BMAX_PATH];
int handle; int handle;
int size; int size;
int rc; int rc;

View file

@ -196,14 +196,16 @@ void intomenusounds(void)
void playmusic(const char *fn) void playmusic(const char *fn)
{ {
#if defined(_WIN32) #if defined(_WIN32)
int fp; int fp, l;
int l; #else
extern void PlayMusic(char *_filename);
#endif
if (fn == NULL) return; if (fn == NULL) return;
if (ud.config.MusicToggle == 0) return; if (ud.config.MusicToggle == 0) return;
if (ud.config.MusicDevice < 0) return; if (ud.config.MusicDevice < 0) return;
#if defined(_WIN32)
fp = kopen4load((char *)fn,0); fp = kopen4load((char *)fn,0);
if (fp == -1) return; if (fp == -1) return;
@ -220,16 +222,9 @@ void playmusic(const char *fn)
kclose(fp); kclose(fp);
MUSIC_PlaySong((unsigned char *)MusicPtr, MUSIC_LoopSong); MUSIC_PlaySong((unsigned char *)MusicPtr, MUSIC_LoopSong);
#else #else
void PlayMusic(char *_filename, int loopflag);
if (fn == NULL) return;
if (ud.config.MusicToggle == 0) return;
if (ud.config.MusicDevice < 0) return;
// FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler // FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler
MUSIC_SetVolume(ud.config.MusicVolume); MUSIC_SetVolume(ud.config.MusicVolume);
PlayMusic((char *)fn, MUSIC_LoopSong); PlayMusic((char *)fn);
#endif #endif
} }