Browse Source

Some additional cleanup

console
Nico de Poel 5 years ago
parent
commit
afa6333078
  1. 29
      engine/Quake/snd_fmod.c

29
engine/Quake/snd_fmod.c

@ -242,7 +242,6 @@ static void SND_FMOD_SetChannelAttributes(FMOD_CHANNEL *channel, sfx_t *sfx, vec
FMOD_VectorCopy(origin, position); FMOD_VectorCopy(origin, position);
FMOD_Channel_Set3DAttributes(channel, &position, NULL); FMOD_Channel_Set3DAttributes(channel, &position, NULL);
FMOD_Channel_SetVolume(channel, vol); FMOD_Channel_SetVolume(channel, vol);
FMOD_Channel_SetVolumeRamp(channel, 1); // This *might* help somewhat with slight audio pops (esp. noticable on the Nailgun)
if (sfx->loopstart >= 0) if (sfx->loopstart >= 0)
{ {
@ -388,7 +387,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
int i; int i;
FMOD_CHANNEL *channel; FMOD_CHANNEL *channel;
FMOD_RESULT result; FMOD_RESULT result;
soundslot_t *userdata;
soundslot_t *slot;
unsigned long long dspclock; unsigned long long dspclock;
if (!fmod_system || !sfx) if (!fmod_system || !sfx)
@ -403,7 +402,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
// Choose a slot to play the sound on, and stop any conflicting sound on the same entchannel // Choose a slot to play the sound on, and stop any conflicting sound on the same entchannel
// Do this before playing the new sound, so that any previous sound will be stopped in time // Do this before playing the new sound, so that any previous sound will be stopped in time
userdata = SND_PickSoundSlot(entnum, entchannel);
slot = SND_PickSoundSlot(entnum, entchannel);
result = FMOD_System_PlaySound(fmod_system, sfx->sound, sfx_channelGroup, 1, &channel); result = FMOD_System_PlaySound(fmod_system, sfx->sound, sfx_channelGroup, 1, &channel);
if (result != FMOD_OK) if (result != FMOD_OK)
@ -415,9 +414,9 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float f
SND_FMOD_SetChannelAttributes(channel, sfx, origin, fvol); SND_FMOD_SetChannelAttributes(channel, sfx, origin, fvol);
// Set up callback data for rolloff and cleanup // Set up callback data for rolloff and cleanup
userdata->channel = channel;
userdata->dist_mult = attenuation / sound_nominal_clip_dist;
FMOD_Channel_SetUserData(channel, userdata);
slot->channel = channel;
slot->dist_mult = attenuation / sound_nominal_clip_dist;
FMOD_Channel_SetUserData(channel, slot);
FMOD_Channel_SetCallback(channel, &SND_FMOD_Callback); FMOD_Channel_SetCallback(channel, &SND_FMOD_Callback);
// Anything coming from the view entity will always be full volume, and entchannel -1 is used for local sounds (e.g. menu sounds) // Anything coming from the view entity will always be full volume, and entchannel -1 is used for local sounds (e.g. menu sounds)
@ -457,7 +456,7 @@ void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation) // N
{ {
FMOD_CHANNEL *channel; FMOD_CHANNEL *channel;
FMOD_RESULT result; FMOD_RESULT result;
soundslot_t *userdata;
soundslot_t *slot;
unsigned long long dspclock; unsigned long long dspclock;
if (!fmod_system || !sfx) if (!fmod_system || !sfx)
@ -467,6 +466,12 @@ void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation) // N
if (!sfx->sound) if (!sfx->sound)
return; return;
if (sfx->loopstart < 0)
{
Con_Printf("Sound %s not looped\n", sfx->name);
return;
}
result = FMOD_System_PlaySound(fmod_system, sfx->sound, sfx_channelGroup, 1, &channel); result = FMOD_System_PlaySound(fmod_system, sfx->sound, sfx_channelGroup, 1, &channel);
if (result != FMOD_OK) if (result != FMOD_OK)
{ {
@ -477,10 +482,10 @@ void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation) // N
SND_FMOD_SetChannelAttributes(channel, sfx, origin, vol / 255); SND_FMOD_SetChannelAttributes(channel, sfx, origin, vol / 255);
// Set up attenuation info for use by the rolloff callback // Set up attenuation info for use by the rolloff callback
userdata = SND_PickSoundSlot(-1, -1);
userdata->channel = channel;
userdata->dist_mult = (attenuation / 64) / sound_nominal_clip_dist;
FMOD_Channel_SetUserData(channel, userdata);
slot = SND_PickSoundSlot(-1, -1);
slot->channel = channel;
slot->dist_mult = (attenuation / 64) / sound_nominal_clip_dist;
FMOD_Channel_SetUserData(channel, slot);
FMOD_Channel_SetCallback(channel, &SND_FMOD_Callback); FMOD_Channel_SetCallback(channel, &SND_FMOD_Callback);
// Add a random delay so that similar sounds don't phase together // Add a random delay so that similar sounds don't phase together
@ -524,7 +529,7 @@ void S_StopAllSounds(qboolean clear)
// Stopping all sounds also ensures that any associated zone memory is freed // Stopping all sounds also ensures that any associated zone memory is freed
FMOD_ChannelGroup_Stop(sfx_channelGroup); FMOD_ChannelGroup_Stop(sfx_channelGroup);
if (clear)
if (clear) // We're abusing the clear flag to also mean "keep ambients alive"
{ {
S_ClearBuffer(); S_ClearBuffer();

Loading…
Cancel
Save