Hacky System for efx reverb tail
Since theres no direct way of getting this lets hack around it :D
This commit is contained in:
parent
3777d9a6b4
commit
3b7939347c
5 changed files with 53 additions and 2 deletions
|
|
@ -287,6 +287,7 @@ boolean I_FadeOutStopSong(UINT32 ms);
|
|||
boolean I_FadeInPlaySong(UINT32 ms, boolean looping);
|
||||
|
||||
efx_t *I_CreateEFX(efx_t *efx);
|
||||
float I_GetEFXTail(efx_t *efx);
|
||||
void I_DeleteEFX(efx_t *efx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
|
|
@ -3234,11 +3234,12 @@ void A_AttractChase(void *thing)
|
|||
actor->target->player->ringboost += K_GetKartRingPower(actor->target->player, true);
|
||||
actor->target->player->ringtime += K_GetKartRingPower(actor->target->player, true);
|
||||
|
||||
//#define EFXTEST
|
||||
#define EFXTEST
|
||||
#ifdef EFXTEST
|
||||
efx_t efx;
|
||||
S_InitEFXArray(&efx);
|
||||
efx.type = EFFECT_REVERB;
|
||||
efx.var5 = 5.9;
|
||||
S_StartSoundAtVolumeEx(actor->target, sfx_s1b5, actor->target->player->ringvolume, &efx);
|
||||
#else
|
||||
S_StartSoundAtVolume(actor->target, sfx_s1b5, actor->target->player->ringvolume);
|
||||
|
|
|
|||
|
|
@ -316,7 +316,10 @@ static void SetChannelsNum(void)
|
|||
for (i = 0; i < numofchannels; i++)
|
||||
{
|
||||
channels[i].sfxinfo = 0;
|
||||
channels[i].duration = 0;
|
||||
channels[i].endtime = 0;
|
||||
channels[i].origin = NULL;
|
||||
channels[i].efxtail = 0;
|
||||
channels[i].efx = NULL;
|
||||
}
|
||||
|
||||
|
|
@ -735,6 +738,7 @@ void S_StartSoundAtVolumeEx(const void *origin_p, sfxenum_t sfx_id, INT32 volume
|
|||
if (efx != NULL && efx->type != EFFECT_NONE)
|
||||
{
|
||||
channels[cnum].efx = I_CreateEFX(efx);
|
||||
channels[cnum].efxtail = I_GetEFXTail(efx);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -890,9 +894,19 @@ notinlevel:
|
|||
// if channel is allocated but sound has stopped, free it
|
||||
if (!I_SoundIsPlaying(c->handle))
|
||||
{
|
||||
S_StopChannel(cnum);
|
||||
c->endtime += 1;
|
||||
if (c->efx == NULL || c->endtime > c->efxtail + c->duration)
|
||||
{
|
||||
CONS_Printf("endtime: %f efxtail: %f duration: %f \n", c->endtime, c->efxtail, c->duration);
|
||||
S_StopChannel(cnum);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
c->duration += 1;
|
||||
c->endtime += 1;
|
||||
}
|
||||
|
||||
if (gamestate != GS_LEVEL || c->origin == NULL)
|
||||
continue;
|
||||
|
|
@ -962,7 +976,9 @@ notinlevel:
|
|||
}
|
||||
|
||||
if (audible)
|
||||
{
|
||||
I_UpdateSoundParams(c->handle, S_GetSoundVolume(c->sfxinfo, volume), sep, pitch, c->efx);
|
||||
}
|
||||
else
|
||||
S_StopChannel(cnum);
|
||||
}
|
||||
|
|
@ -1031,8 +1047,11 @@ static void S_StopChannel(INT32 cnum)
|
|||
c->sfxinfo = 0;
|
||||
}
|
||||
|
||||
c->duration = 0;
|
||||
c->endtime = 0;
|
||||
c->origin = NULL;
|
||||
I_DeleteEFX(c->efx);
|
||||
c->efxtail = 0;
|
||||
c->efx = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,8 +88,13 @@ struct channel_t
|
|||
// handle of the sound being played
|
||||
INT32 handle;
|
||||
|
||||
// length sound has been playing
|
||||
float duration;
|
||||
float endtime;
|
||||
|
||||
// EFX
|
||||
efx_t *efx;
|
||||
float efxtail;
|
||||
};
|
||||
|
||||
struct caption_t {
|
||||
|
|
|
|||
|
|
@ -1971,6 +1971,31 @@ efx_t *I_CreateEFX(efx_t *efx)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
float I_GetEFXTail(efx_t *efx)
|
||||
{
|
||||
LOCKAUDIO;
|
||||
|
||||
if (efx == NULL)
|
||||
return 0;
|
||||
|
||||
float tailtime = 0;
|
||||
switch(efx->type)
|
||||
{
|
||||
case EFFECT_REVERB:
|
||||
if (efx->var5 != 255)
|
||||
tailtime = efx->var5;
|
||||
else
|
||||
tailtime = 1.49;
|
||||
break;
|
||||
|
||||
default:
|
||||
tailtime = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return tailtime*TICRATE;
|
||||
}
|
||||
|
||||
void I_DeleteEFX(efx_t *efx)
|
||||
{
|
||||
LOCKAUDIO;
|
||||
|
|
|
|||
Loading…
Reference in a new issue