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

View file

@ -1758,12 +1758,15 @@ int MV_SetMixMode(int numchannels, int samplebits)
// OGG file
// ---------------------------------------------------------------------
ov_callbacks cb;
size_t ReadOgg(void *ptr, size_t size1, size_t nmemb, void *datasource)
{
sounddef *d=(sounddef *)datasource;
size1*=nmemb;
if (d->pos>=d->size)return 0;
if (d->pos+size1>=d->size)size1=d->size-d->pos;
if (d->pos>=d->size)
return 0;
if (d->pos+size1>=d->size)
size1=d->size-d->pos;
Bmemcpy(ptr,(d->ptrsnd+d->pos),size1);
d->pos+=size1;
return size1;
@ -1774,12 +1777,19 @@ int SeekOgg(void *datasource,ogg_int64_t offset,int whence)
sounddef *d=(sounddef *)datasource;
switch (whence)
{
case SEEK_SET: whence=offset;break;
case SEEK_CUR: whence=d->pos+offset;break;
case SEEK_END: whence=d->size-offset-1;break;
case SEEK_SET:
whence=offset;
break;
case SEEK_CUR:
whence=d->pos+offset;
break;
case SEEK_END:
whence=d->size-offset-1;
break;
default: return -1;
}
if (whence>=(int)d->size||whence<0)return -1;
if (whence>=(int)d->size||whence<0)
return -1;
d->pos=whence;
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)
voice->downsample++;
length=ov_pcm_total(&voice->OGGstream.oggStream,0);
length=ov_pcm_total(&voice->OGGstream.oggStream,-1);
// if (!length)length=0xffffff;
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);
if (vorbisInfo->channels==2)voice->downsample++;
if (vorbisInfo->channels==2)
voice->downsample++;
MV_SetVoiceVolume(voice, vol, left, right);
MV_PlayVoice(voice);

View file

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

View file

@ -174,7 +174,7 @@ char *MUSIC_ErrorString(int ErrorNumber)
int MUSIC_Init(int SoundCard, int Address)
{
// 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);
if(external_midi)
Mix_SetMusicCMD(command);
@ -297,11 +297,6 @@ int MUSIC_StopSong(void)
// Duke3D-specific. --ryan.
void PlayMusic(char *_filename)
{
//char filename[MAX_PATH];
//strcpy(filename, _filename);
//FixFilePath(filename);
char filename[BMAX_PATH];
int handle;
int size;
int rc;

View file

@ -196,14 +196,16 @@ void intomenusounds(void)
void playmusic(const char *fn)
{
#if defined(_WIN32)
int fp;
int l;
int fp, l;
#else
extern void PlayMusic(char *_filename);
#endif
if (fn == NULL) return;
if (ud.config.MusicToggle == 0) return;
if (ud.config.MusicDevice < 0) return;
#if defined(_WIN32)
fp = kopen4load((char *)fn,0);
if (fp == -1) return;
@ -220,16 +222,9 @@ void playmusic(const char *fn)
kclose(fp);
MUSIC_PlaySong((unsigned char *)MusicPtr, MUSIC_LoopSong);
#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
MUSIC_SetVolume(ud.config.MusicVolume);
PlayMusic((char *)fn, MUSIC_LoopSong);
PlayMusic((char *)fn);
#endif
}