From 48c6088c27bab6ed892fe52df99ca7d5f1803597 Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Tue, 14 Aug 2001 21:48:58 +0000 Subject: [PATCH] Fixed common sound loading. Still debugging OpenAL code. --- src/avp/psnd.c | 16 +++++++++++++--- src/avp/psndproj.c | 10 ++++++---- src/main.c | 16 ++++++++-------- src/openal.c | 25 +++++++++++++++---------- 4 files changed, 42 insertions(+), 25 deletions(-) diff --git a/src/avp/psnd.c b/src/avp/psnd.c index 11c96b6..2744ab5 100644 --- a/src/avp/psnd.c +++ b/src/avp/psnd.c @@ -343,6 +343,7 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...) int reverb_off = 0; int soundStartPosition = 0; +printf("1 Play: %d\n", soundNumber); { extern int PlaySounds; if (!PlaySounds) return; @@ -350,11 +351,17 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...) if(!SoundSwitchedOn) return; +printf("2 Play\n"); + /* check soundIndex for bounds, whether it has been loaded, and number of instances */ if((soundNumber<0)||(soundNumber>=SID_MAXIMUM)) return; +printf("A Play: %s\n", GameSounds[soundNumber].wavName); if(!(GameSounds[soundNumber].loaded)) return; +printf("B Play\n"); if(!(GameSounds[soundNumber].activeInstancesdsBufferP,(LPDWORD)&block->position,NULL); // else block->position = 0; -fprintf(stderr, "Save_SoundState: GetCurrentPosition!\n"); +printf("Save_SoundState: GetCurrentPosition!\n"); strcpy((char*)(block+1),name); @@ -931,7 +941,7 @@ void Save_SoundsWithNoReference() // IDirectSoundBuffer_GetCurrentPosition(sound->dsBufferP,(LPDWORD)&block->position,NULL); // else block->position = 0; - fprintf(stderr, "Save_SoundsWithNoReference: GetCurrentPosition!\n"); + printf("Save_SoundsWithNoReference: GetCurrentPosition!\n"); strcpy((char*)(block+1),name); } diff --git a/src/avp/psndproj.c b/src/avp/psndproj.c index b61bd94..c196d3c 100644 --- a/src/avp/psndproj.c +++ b/src/avp/psndproj.c @@ -855,6 +855,7 @@ int FindAndLoadWavFile(int soundNum,char* wavFileName) static char sound_name[200]; sprintf (sound_name, "%s%s", FirstSoundDir,wavFileName); +printf("FindAndLoadWavFile: %d, %s\n", soundNum, wavFileName); #if LOAD_SOUND_FROM_FAST_FILE //first look in fast file { @@ -903,7 +904,8 @@ int FindAndLoadWavFile(int soundNum,char* wavFileName) /* Patrick 5/6/97 ------------------------------------------------------------- Sound data loaders ----------------------------------------------------------------------------*/ -#if USE_REBSND_LOADERS +//#if USE_REBSND_LOADERS +#if 1 extern unsigned char *ExtractWavFile(int soundIndex, unsigned char *bufferPtr); void *LoadRebSndFile(char *filename) { @@ -961,12 +963,12 @@ void LoadSounds(char *soundDirectory) { char filename[64]; #if ALIEN_DEMO - strcpy(filename, ".\\alienfastfile");//CommonSoundDirectory); + strcpy(filename, "./alienfastfile");//CommonSoundDirectory); #else - strcpy(filename, ".\\fastfile");//CommonSoundDirectory); + strcpy(filename, "./fastfile");//CommonSoundDirectory); #endif // strcat(filename, soundDirectory); - strcat(filename, "\\"); + strcat(filename, "/"); // strcat(filename, soundDirectory); // strcat(filename, ".RebSnd"); strcat(filename, "common.ffl"); diff --git a/src/main.c b/src/main.c index d3b60dd..9d3c012 100644 --- a/src/main.c +++ b/src/main.c @@ -23,8 +23,8 @@ #include "cdtrackselection.h" #include "gammacontrol.h" -#define MyWidth 1024 -#define MyHeight 768 +#define MyWidth 512 +#define MyHeight 384 char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */ @@ -91,8 +91,8 @@ int InitialiseWindowsSystem() /* -w will disable to first fullscreen, -f will turn it on */ // SDL_WM_ToggleFullScreen(surface); - SDL_WM_GrabInput(SDL_GRAB_ON); - SDL_ShowCursor(0); +// SDL_WM_GrabInput(SDL_GRAB_ON); +// SDL_ShowCursor(0); glViewport(0, 0, MyWidth, MyHeight); @@ -569,16 +569,16 @@ int main(int argc, char *argv[]) AvP.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */ - AvP.PlayerType = I_Alien; - SetLevelToLoad(AVP_ENVIRONMENT_TEMPLE); /* starting alien level */ +// AvP.PlayerType = I_Alien; +// SetLevelToLoad(AVP_ENVIRONMENT_TEMPLE); /* starting alien level */ -// AvP.PlayerType = I_Marine; + AvP.PlayerType = I_Marine; // SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */ // AvP.PlayerType = I_Predator; // SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); /* starting predator level */ -// SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer */ + SetLevelToLoad(AVP_ENVIRONMENT_LEADWORKS_MP); /* multiplayer */ // SetLevelToLoad(AVP_ENVIRONMENT_E3DEMOSP); /* demo level */ diff --git a/src/openal.c b/src/openal.c index 0c7dbdc..5c841c8 100644 --- a/src/openal.c +++ b/src/openal.c @@ -112,9 +112,9 @@ int PlatPlaySound(int activeIndex) if (!PlatSoundHasStopped(activeIndex)) PlatStopSound (activeIndex); - if (ActiveSounds[activeIndex].loop) - alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_TRUE); - else +// if (ActiveSounds[activeIndex].loop) +// alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_TRUE); +// else alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_FALSE); alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_BUFFER, @@ -219,7 +219,7 @@ int PlatChangeSoundPitch(int activeIndex, int pitch) ActiveSounds[activeIndex].pitch = pitch; - alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_PITCH, frequency); +// alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_PITCH, frequency); return 1; } @@ -247,7 +247,8 @@ int PlatDo3dSound(int activeIndex) int distance; VECTORCH relativePosn; int newPan, newVolume; - + +return; fprintf(stderr, "PlatDo3dSound(%d)\n", activeIndex); relativePosn.vx = ActiveSounds[activeIndex].threedeedata.position.vx - @@ -435,12 +436,14 @@ unsigned char *ExtractWavFile(int soundIndex, unsigned char *bufferPtr) fprintf (stderr, "Loaded %s\n", GameSounds[soundIndex].wavName); } - if (acLoadWAV (bufferPtr, (ALuint *) &len, &udata, &rfmt, + if (acLoadWAV (bufferPtr, (ALuint *) &rsize, &udata, &rfmt, &rchan, &rfreq) == NULL) { fprintf (stderr, "Unable to convert data\n"); return (unsigned char *)0; } + len = rsize; + if ((rfmt == AUDIO_U8)) { nb = Force8to16 (udata, &len); rfmt = AUDIO_S16LSB; @@ -460,11 +463,9 @@ fprintf (stderr, "Loaded %s\n", GameSounds[soundIndex].wavName); } else return (unsigned char *)0; - rsize = len; - alGenBuffers (1, &(GameSounds[soundIndex].dsBufferP)); alBufferData (GameSounds[soundIndex].dsBufferP, - rfmt, udata, rsize, rfreq); + rfmt, udata, len, rfreq); GameSounds[soundIndex].loaded = 1; GameSounds[soundIndex].flags = SAMPLE_IN_HW; @@ -474,7 +475,10 @@ fprintf (stderr, "Loaded %s\n", GameSounds[soundIndex].wavName); free (udata); - return (bufferPtr + rsize); + /* read RIFF chunk length and jump past it */ + return bufferPtr + 8 + + ((bufferPtr[4] << 0) | (bufferPtr[5] << 8) | + (bufferPtr[6] << 16) | (bufferPtr[7] << 24)); } int LoadWavFromFastFile(int soundNum, char * wavFileName) @@ -505,6 +509,7 @@ void PlatUpdatePlayer() ALfloat vel[3], or[6], pos[3]; fprintf(stderr, "PlatUpdatePlayer()\n"); +return; if (Global_VDB_Ptr) { extern int NormalFrameTime; extern int DopplerShiftIsOn;