Fixed common sound loading. Still debugging OpenAL code.
This commit is contained in:
parent
c7d772650f
commit
48c6088c27
4 changed files with 42 additions and 25 deletions
|
@ -343,6 +343,7 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
|
||||||
int reverb_off = 0;
|
int reverb_off = 0;
|
||||||
int soundStartPosition = 0;
|
int soundStartPosition = 0;
|
||||||
|
|
||||||
|
printf("1 Play: %d\n", soundNumber);
|
||||||
{
|
{
|
||||||
extern int PlaySounds;
|
extern int PlaySounds;
|
||||||
if (!PlaySounds) return;
|
if (!PlaySounds) return;
|
||||||
|
@ -350,11 +351,17 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
|
||||||
|
|
||||||
if(!SoundSwitchedOn) return;
|
if(!SoundSwitchedOn) return;
|
||||||
|
|
||||||
|
printf("2 Play\n");
|
||||||
|
|
||||||
/* check soundIndex for bounds, whether it has been loaded, and number of instances */
|
/* check soundIndex for bounds, whether it has been loaded, and number of instances */
|
||||||
if((soundNumber<0)||(soundNumber>=SID_MAXIMUM)) return;
|
if((soundNumber<0)||(soundNumber>=SID_MAXIMUM)) return;
|
||||||
|
printf("A Play: %s\n", GameSounds[soundNumber].wavName);
|
||||||
if(!(GameSounds[soundNumber].loaded)) return;
|
if(!(GameSounds[soundNumber].loaded)) return;
|
||||||
|
printf("B Play\n");
|
||||||
if(!(GameSounds[soundNumber].activeInstances<SOUND_MAXINSTANCES)) return;
|
if(!(GameSounds[soundNumber].activeInstances<SOUND_MAXINSTANCES)) return;
|
||||||
|
|
||||||
|
printf("3 Play\n");
|
||||||
|
|
||||||
db_logf5(("About to play sound %i", soundNumber));
|
db_logf5(("About to play sound %i", soundNumber));
|
||||||
|
|
||||||
/* initialise volume and pitch from game sound data */
|
/* initialise volume and pitch from game sound data */
|
||||||
|
@ -445,6 +452,8 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("4 Play\n");
|
||||||
|
|
||||||
/* Deal with resource allocation. */
|
/* Deal with resource allocation. */
|
||||||
{
|
{
|
||||||
/* Range of active buffers to search. */
|
/* Range of active buffers to search. */
|
||||||
|
@ -508,6 +517,7 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
|
||||||
ActiveSounds[newIndex].reverb_off=reverb_off;
|
ActiveSounds[newIndex].reverb_off=reverb_off;
|
||||||
if(loop) ActiveSounds[newIndex].loop = 1;
|
if(loop) ActiveSounds[newIndex].loop = 1;
|
||||||
else ActiveSounds[newIndex].loop = 0;
|
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)
|
if(worldPosn)
|
||||||
{
|
{
|
||||||
VECTORCH zeroPosn = {0,0,0};
|
VECTORCH zeroPosn = {0,0,0};
|
||||||
|
@ -554,7 +564,7 @@ void Sound_Play(SOUNDINDEX soundNumber, char *format, ...)
|
||||||
// IDirectSoundBuffer_SetCurrentPosition(ActiveSounds[newIndex].dsBufferP,soundStartPosition);
|
// IDirectSoundBuffer_SetCurrentPosition(ActiveSounds[newIndex].dsBufferP,soundStartPosition);
|
||||||
// }
|
// }
|
||||||
if (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)
|
void Sound_Stop(int activeSoundNumber)
|
||||||
|
@ -841,7 +851,7 @@ void Save_SoundState(int* soundHandle)
|
||||||
// IDirectSoundBuffer_GetCurrentPosition(sound->dsBufferP,(LPDWORD)&block->position,NULL);
|
// IDirectSoundBuffer_GetCurrentPosition(sound->dsBufferP,(LPDWORD)&block->position,NULL);
|
||||||
// else
|
// else
|
||||||
block->position = 0;
|
block->position = 0;
|
||||||
fprintf(stderr, "Save_SoundState: GetCurrentPosition!\n");
|
printf("Save_SoundState: GetCurrentPosition!\n");
|
||||||
|
|
||||||
strcpy((char*)(block+1),name);
|
strcpy((char*)(block+1),name);
|
||||||
|
|
||||||
|
@ -931,7 +941,7 @@ void Save_SoundsWithNoReference()
|
||||||
// IDirectSoundBuffer_GetCurrentPosition(sound->dsBufferP,(LPDWORD)&block->position,NULL);
|
// IDirectSoundBuffer_GetCurrentPosition(sound->dsBufferP,(LPDWORD)&block->position,NULL);
|
||||||
// else
|
// else
|
||||||
block->position = 0;
|
block->position = 0;
|
||||||
fprintf(stderr, "Save_SoundsWithNoReference: GetCurrentPosition!\n");
|
printf("Save_SoundsWithNoReference: GetCurrentPosition!\n");
|
||||||
|
|
||||||
strcpy((char*)(block+1),name);
|
strcpy((char*)(block+1),name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -855,6 +855,7 @@ int FindAndLoadWavFile(int soundNum,char* wavFileName)
|
||||||
static char sound_name[200];
|
static char sound_name[200];
|
||||||
sprintf (sound_name, "%s%s", FirstSoundDir,wavFileName);
|
sprintf (sound_name, "%s%s", FirstSoundDir,wavFileName);
|
||||||
|
|
||||||
|
printf("FindAndLoadWavFile: %d, %s\n", soundNum, wavFileName);
|
||||||
#if LOAD_SOUND_FROM_FAST_FILE
|
#if LOAD_SOUND_FROM_FAST_FILE
|
||||||
//first look in fast file
|
//first look in fast file
|
||||||
{
|
{
|
||||||
|
@ -903,7 +904,8 @@ int FindAndLoadWavFile(int soundNum,char* wavFileName)
|
||||||
/* Patrick 5/6/97 -------------------------------------------------------------
|
/* Patrick 5/6/97 -------------------------------------------------------------
|
||||||
Sound data loaders
|
Sound data loaders
|
||||||
----------------------------------------------------------------------------*/
|
----------------------------------------------------------------------------*/
|
||||||
#if USE_REBSND_LOADERS
|
//#if USE_REBSND_LOADERS
|
||||||
|
#if 1
|
||||||
extern unsigned char *ExtractWavFile(int soundIndex, unsigned char *bufferPtr);
|
extern unsigned char *ExtractWavFile(int soundIndex, unsigned char *bufferPtr);
|
||||||
void *LoadRebSndFile(char *filename)
|
void *LoadRebSndFile(char *filename)
|
||||||
{
|
{
|
||||||
|
@ -961,12 +963,12 @@ void LoadSounds(char *soundDirectory)
|
||||||
{
|
{
|
||||||
char filename[64];
|
char filename[64];
|
||||||
#if ALIEN_DEMO
|
#if ALIEN_DEMO
|
||||||
strcpy(filename, ".\\alienfastfile");//CommonSoundDirectory);
|
strcpy(filename, "./alienfastfile");//CommonSoundDirectory);
|
||||||
#else
|
#else
|
||||||
strcpy(filename, ".\\fastfile");//CommonSoundDirectory);
|
strcpy(filename, "./fastfile");//CommonSoundDirectory);
|
||||||
#endif
|
#endif
|
||||||
// strcat(filename, soundDirectory);
|
// strcat(filename, soundDirectory);
|
||||||
strcat(filename, "\\");
|
strcat(filename, "/");
|
||||||
// strcat(filename, soundDirectory);
|
// strcat(filename, soundDirectory);
|
||||||
// strcat(filename, ".RebSnd");
|
// strcat(filename, ".RebSnd");
|
||||||
strcat(filename, "common.ffl");
|
strcat(filename, "common.ffl");
|
||||||
|
|
16
src/main.c
16
src/main.c
|
@ -23,8 +23,8 @@
|
||||||
#include "cdtrackselection.h"
|
#include "cdtrackselection.h"
|
||||||
#include "gammacontrol.h"
|
#include "gammacontrol.h"
|
||||||
|
|
||||||
#define MyWidth 1024
|
#define MyWidth 512
|
||||||
#define MyHeight 768
|
#define MyHeight 384
|
||||||
|
|
||||||
char LevelName[] = {"predbit6\0QuiteALongNameActually"}; /* the real way to load levels */
|
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 */
|
/* -w will disable to first fullscreen, -f will turn it on */
|
||||||
// SDL_WM_ToggleFullScreen(surface);
|
// SDL_WM_ToggleFullScreen(surface);
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
// SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
SDL_ShowCursor(0);
|
// SDL_ShowCursor(0);
|
||||||
|
|
||||||
glViewport(0, 0, MyWidth, MyHeight);
|
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.CurrentEnv = AvP.StartingEnv = 0; /* are these even used? */
|
||||||
|
|
||||||
AvP.PlayerType = I_Alien;
|
// AvP.PlayerType = I_Alien;
|
||||||
SetLevelToLoad(AVP_ENVIRONMENT_TEMPLE); /* starting alien level */
|
// SetLevelToLoad(AVP_ENVIRONMENT_TEMPLE); /* starting alien level */
|
||||||
|
|
||||||
// AvP.PlayerType = I_Marine;
|
AvP.PlayerType = I_Marine;
|
||||||
// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
|
// SetLevelToLoad(AVP_ENVIRONMENT_DERELICT); /* starting marine level */
|
||||||
|
|
||||||
// AvP.PlayerType = I_Predator;
|
// AvP.PlayerType = I_Predator;
|
||||||
// SetLevelToLoad(AVP_ENVIRONMENT_WATERFALL); /* starting predator level */
|
// 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 */
|
// SetLevelToLoad(AVP_ENVIRONMENT_E3DEMOSP); /* demo level */
|
||||||
|
|
||||||
|
|
23
src/openal.c
23
src/openal.c
|
@ -112,9 +112,9 @@ int PlatPlaySound(int activeIndex)
|
||||||
if (!PlatSoundHasStopped(activeIndex))
|
if (!PlatSoundHasStopped(activeIndex))
|
||||||
PlatStopSound (activeIndex);
|
PlatStopSound (activeIndex);
|
||||||
|
|
||||||
if (ActiveSounds[activeIndex].loop)
|
// if (ActiveSounds[activeIndex].loop)
|
||||||
alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_TRUE);
|
// alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_TRUE);
|
||||||
else
|
// else
|
||||||
alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_FALSE);
|
alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_LOOPING, AL_FALSE);
|
||||||
|
|
||||||
alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_BUFFER,
|
alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_BUFFER,
|
||||||
|
@ -219,7 +219,7 @@ int PlatChangeSoundPitch(int activeIndex, int pitch)
|
||||||
|
|
||||||
ActiveSounds[activeIndex].pitch = pitch;
|
ActiveSounds[activeIndex].pitch = pitch;
|
||||||
|
|
||||||
alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_PITCH, frequency);
|
// alSourcei (ActiveSounds[activeIndex].ds3DBufferP, AL_PITCH, frequency);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -248,6 +248,7 @@ int PlatDo3dSound(int activeIndex)
|
||||||
VECTORCH relativePosn;
|
VECTORCH relativePosn;
|
||||||
int newPan, newVolume;
|
int newPan, newVolume;
|
||||||
|
|
||||||
|
return;
|
||||||
fprintf(stderr, "PlatDo3dSound(%d)\n", activeIndex);
|
fprintf(stderr, "PlatDo3dSound(%d)\n", activeIndex);
|
||||||
|
|
||||||
relativePosn.vx = ActiveSounds[activeIndex].threedeedata.position.vx -
|
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);
|
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) {
|
&rchan, &rfreq) == NULL) {
|
||||||
fprintf (stderr, "Unable to convert data\n");
|
fprintf (stderr, "Unable to convert data\n");
|
||||||
return (unsigned char *)0;
|
return (unsigned char *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len = rsize;
|
||||||
|
|
||||||
if ((rfmt == AUDIO_U8)) {
|
if ((rfmt == AUDIO_U8)) {
|
||||||
nb = Force8to16 (udata, &len);
|
nb = Force8to16 (udata, &len);
|
||||||
rfmt = AUDIO_S16LSB;
|
rfmt = AUDIO_S16LSB;
|
||||||
|
@ -460,11 +463,9 @@ fprintf (stderr, "Loaded %s\n", GameSounds[soundIndex].wavName);
|
||||||
} else
|
} else
|
||||||
return (unsigned char *)0;
|
return (unsigned char *)0;
|
||||||
|
|
||||||
rsize = len;
|
|
||||||
|
|
||||||
alGenBuffers (1, &(GameSounds[soundIndex].dsBufferP));
|
alGenBuffers (1, &(GameSounds[soundIndex].dsBufferP));
|
||||||
alBufferData (GameSounds[soundIndex].dsBufferP,
|
alBufferData (GameSounds[soundIndex].dsBufferP,
|
||||||
rfmt, udata, rsize, rfreq);
|
rfmt, udata, len, rfreq);
|
||||||
|
|
||||||
GameSounds[soundIndex].loaded = 1;
|
GameSounds[soundIndex].loaded = 1;
|
||||||
GameSounds[soundIndex].flags = SAMPLE_IN_HW;
|
GameSounds[soundIndex].flags = SAMPLE_IN_HW;
|
||||||
|
@ -474,7 +475,10 @@ fprintf (stderr, "Loaded %s\n", GameSounds[soundIndex].wavName);
|
||||||
|
|
||||||
free (udata);
|
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)
|
int LoadWavFromFastFile(int soundNum, char * wavFileName)
|
||||||
|
@ -505,6 +509,7 @@ void PlatUpdatePlayer()
|
||||||
ALfloat vel[3], or[6], pos[3];
|
ALfloat vel[3], or[6], pos[3];
|
||||||
fprintf(stderr, "PlatUpdatePlayer()\n");
|
fprintf(stderr, "PlatUpdatePlayer()\n");
|
||||||
|
|
||||||
|
return;
|
||||||
if (Global_VDB_Ptr) {
|
if (Global_VDB_Ptr) {
|
||||||
extern int NormalFrameTime;
|
extern int NormalFrameTime;
|
||||||
extern int DopplerShiftIsOn;
|
extern int DopplerShiftIsOn;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue