fix up some q2 sound effects and handle sound delays, misc cleanup

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2270 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-05-10 07:35:19 +00:00
parent e54310e530
commit 0d6d61e31c
5 changed files with 22 additions and 12 deletions

View File

@ -3108,7 +3108,7 @@ void CLQ2_ParseMuzzleFlash (void)
snprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
Q2S_StartSound (NULL, i, CHAN_WEAPON, S_PrecacheSound(soundname), volume, ATTN_NORM, 0);
snprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
Q2S_StartSound (NULL, i, CHAN_WEAPON, S_PrecacheSound(soundname), volume, ATTN_NORM, 0.05);
Q2S_StartSound (NULL, i, CHAN_AUTO, S_PrecacheSound(soundname), volume, ATTN_NORM, 0.05);
break;
case Q2MZ_CHAINGUN3:
dl->radius = 250 + (rand()&31);
@ -3117,9 +3117,9 @@ void CLQ2_ParseMuzzleFlash (void)
snprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
Q2S_StartSound (NULL, i, CHAN_WEAPON, S_PrecacheSound(soundname), volume, ATTN_NORM, 0);
snprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
Q2S_StartSound (NULL, i, CHAN_WEAPON, S_PrecacheSound(soundname), volume, ATTN_NORM, 0.033);
Q2S_StartSound (NULL, i, CHAN_AUTO, S_PrecacheSound(soundname), volume, ATTN_NORM, 0.033);
snprintf(soundname, sizeof(soundname), "weapons/machgf%ib.wav", (rand() % 5) + 1);
Q2S_StartSound (NULL, i, CHAN_WEAPON, S_PrecacheSound(soundname), volume, ATTN_NORM, 0.066);
Q2S_StartSound (NULL, i, CHAN_AUTO, S_PrecacheSound(soundname), volume, ATTN_NORM, 0.066);
break;
case Q2MZ_RAILGUN:

View File

@ -1571,7 +1571,7 @@ static qbyte splash_color[] = {0x00, 0xe0, 0xb0, 0x50, 0xd0, 0xe0, 0xe8};
#define ATTN_STATIC 1
void Q2S_StartSound(vec3_t origin, int entnum, int entchannel, sfx_t *sfx, float fvol, float attenuation, float timeofs)
{
S_StartSound(entnum, entchannel, sfx, origin, fvol, attenuation);
S_StartSoundDelayed(entnum, entchannel, sfx, origin, fvol, attenuation, timeofs);
}
void CLQ2_ParseTEnt (void)
{

View File

@ -194,7 +194,6 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum)
{
snd_pcm_t *pcm;
snd_pcm_uframes_t buffer_size;
extern cvar_t snd_speakers;
soundcardinfo_t *ec; //existing card
char *pcmname;
@ -375,14 +374,14 @@ static int ALSA_InitCard (soundcardinfo_t *sc, int cardnum)
err = psnd_pcm_hw_params_set_buffer_size_near(pcm, hw, &buffer_size);
if (err < 0)
{
Con_Printf ("ALSA: unable to set buffer size. %s\n", psnd_strerror (err));
Con_Printf (S_ERROR "ALSA: unable to set buffer size. %s\n", psnd_strerror (err));
goto error;
}
}
err = psnd_pcm_hw_params_get_buffer_size (hw, &buffer_size);
if (0 > err) {
Con_Printf ("ALSA: unable to get buffer size. %s\n",
Con_Printf (S_ERROR "ALSA: unable to get buffer size. %s\n",
psnd_strerror (err));
goto error;
}

View File

@ -205,8 +205,8 @@ static int SNDDMA_Init(soundcardinfo_t *sc, int *cardnum, int *drivernum)
sc->sn.speed = 8000;
// set requested speaker count
if (snd_speakers.value > 6)
sc->sn.numchannels = 6;
if (snd_speakers.value > MAXSOUNDCHANNELS)
sc->sn.numchannels = MAXSOUNDCHANNELS;
else if (snd_speakers.value > 1)
sc->sn.numchannels = (int)snd_speakers.value;
else
@ -928,6 +928,17 @@ void S_StartSoundCard(soundcardinfo_t *sc, int entnum, int entchannel, sfx_t *sf
}
}
void S_StartSoundDelayed(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs)
{
soundcardinfo_t *sc;
if (!sfx || !*sfx->name) //no named sounds would need specific starting.
return;
for (sc = sndcardinfo; sc; sc = sc->next)
S_StartSoundCard(sc, entnum, entchannel, sfx, origin, fvol, attenuation, -(int)(timeofs * sc->sn.speed));
}
void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
{
soundcardinfo_t *sc;

View File

@ -77,14 +77,13 @@ typedef struct
unsigned char *buffer;
} dma_t;
// !!! if this is changed, it much be changed in asm_i386.h too !!!
typedef struct
{
sfx_t *sfx; // sfx number
int vol[MAXSOUNDCHANNELS]; // 0-255 volume
int delay[MAXSOUNDCHANNELS];
int end; // end time in global paintsamples
int pos; // sample position in sfx
int pos; // sample position in sfx, <0 means delay sound start
int looping; // where to loop, -1 = no looping
int entnum; // to allow overriding a specific sound
int entchannel; //int audio_fd
@ -109,7 +108,8 @@ typedef struct soundcardinfo_s soundcardinfo_t;
void S_Init (void);
void S_Startup (void);
void S_Shutdown (void);
void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation);
void S_StartSoundDelayed(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation, float timeofs);
void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation);
void S_StopSound (int entnum, int entchannel);
void S_StopAllSounds(qboolean clear);