Fixed common sound loading. Still debugging OpenAL code.

This commit is contained in:
Steven Fuller 2001-08-14 21:48:58 +00:00 committed by Patryk Obara
parent c7d772650f
commit 48c6088c27
4 changed files with 42 additions and 25 deletions

View file

@ -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].activeInstances<SOUND_MAXINSTANCES)) return;
printf("3 Play\n");
db_logf5(("About to play sound %i", soundNumber));
/* initialise volume and pitch from game sound data */
@ -445,6 +452,8 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
return;
}
printf("4 Play\n");
/* Deal with resource allocation. */
{
/* Range of active buffers to search. */
@ -508,6 +517,7 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
ActiveSounds[newIndex].reverb_off=reverb_off;
if(loop) ActiveSounds[newIndex].loop = 1;
else ActiveSounds[newIndex].loop = 0;
printf("Play: new = %d. num = %d, p = %d, v = %d, pi = %d, l = %d, mi = %d, rev = %d\n", newIndex, soundNumber, priority, volume, pitch, loop, marine_ignore, reverb_off);
if(worldPosn)
{
VECTORCH zeroPosn = {0,0,0};
@ -554,7 +564,7 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
// IDirectSoundBuffer_SetCurrentPosition(ActiveSounds[newIndex].dsBufferP,soundStartPosition);
// }
if (soundStartPosition)
fprintf(stderr, "Sound_Play: sound starts part of the way in (%d)\n", soundStartPosition);
printf("Sound_Play: sound starts part of the way in (%d)\n", soundStartPosition);
}
void Sound_Stop(int activeSoundNumber)
@ -841,7 +851,7 @@ void Save_SoundState(int* soundHandle)
// IDirectSoundBuffer_GetCurrentPosition(sound->dsBufferP,(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);
}

View file

@ -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");

View file

@ -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 */

View file

@ -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;