Fix the gap between loops of ambient MUSICANDSFX sounds like BAR_MUSIC.

git-svn-id: https://svn.eduke32.com/eduke32@3336 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2012-12-29 10:58:09 +00:00
parent 3933471e4b
commit 11e0897def
5 changed files with 43 additions and 47 deletions

View file

@ -1267,6 +1267,7 @@ ACTOR_STATIC void G_MoveFX(void)
if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1)) if (x < ht && T1 == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1))
{ {
char om = g_sounds[s->lotag].m;
if (g_numEnvSoundsPlaying == ud.config.NumVoices) if (g_numEnvSoundsPlaying == ud.config.NumVoices)
{ {
int32_t j; int32_t j;
@ -1284,7 +1285,9 @@ ACTOR_STATIC void G_MoveFX(void)
goto BOLT; goto BOLT;
} }
g_sounds[s->lotag].m |= 1;
A_PlaySound(s->lotag,i); A_PlaySound(s->lotag,i);
g_sounds[s->lotag].m = om;
T1 = 1; T1 = 1;
} }
else if (x >= ht && T1 == 1) else if (x >= ht && T1 == 1)

View file

@ -2577,6 +2577,7 @@ static void M32_MoveFX(void)
x = dist((spritetype *)&pos,s); x = dist((spritetype *)&pos,s);
if (x < ht && (T1&1) == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1)) if (x < ht && (T1&1) == 0 && FX_VoiceAvailable(g_sounds[s->lotag].pr-1))
{ {
char om = g_sounds[s->lotag].m;
if (g_numEnvSoundsPlaying == NumVoices) if (g_numEnvSoundsPlaying == NumVoices)
{ {
for (j = headspritestat[0]; j >= 0; j = nextspritestat[j]) for (j = headspritestat[0]; j >= 0; j = nextspritestat[j])
@ -2591,7 +2592,9 @@ static void M32_MoveFX(void)
} }
if (j == -1) continue; if (j == -1) continue;
} }
g_sounds[s->lotag].m |= 1;
A_PlaySound(s->lotag,i); A_PlaySound(s->lotag,i);
g_sounds[s->lotag].m = om;
T1 |= 1; T1 |= 1;
} }
if (x >= ht && (T1&1) == 1) if (x >= ht && (T1&1) == 1)

View file

@ -469,6 +469,8 @@ int32_t MV_PlayLoopedFLAC
flac_data * fd = 0; flac_data * fd = 0;
FLAC__Metadata_Chain* metadata_chain; FLAC__Metadata_Chain* metadata_chain;
UNREFERENCED_PARAMETER(loopend);
if ( !MV_Installed ) if ( !MV_Installed )
{ {
MV_SetErrorCode( MV_NotInstalled ); MV_SetErrorCode( MV_NotInstalled );
@ -538,8 +540,8 @@ int32_t MV_PlayLoopedFLAC
voice->Playing = TRUE; voice->Playing = TRUE;
voice->Paused = FALSE; voice->Paused = FALSE;
voice->LoopStart = (char *) (intptr_t)(loopstart >= 0 ? loopstart : 0); voice->LoopStart = 0;
voice->LoopEnd = (char *) (intptr_t)(loopstart >= 0 && loopend > 0 ? loopend : 0); voice->LoopEnd = 0;
voice->LoopSize = (loopstart >= 0 ? 1 : 0); voice->LoopSize = (loopstart >= 0 ? 1 : 0);
// parse metadata // parse metadata
@ -585,7 +587,7 @@ int32_t MV_PlayLoopedFLAC
} }
// load loop tags from metadata // load loop tags from metadata
if (tags->type == FLAC__METADATA_TYPE_VORBIS_COMMENT && loopstart < 1) if (tags->type == FLAC__METADATA_TYPE_VORBIS_COMMENT)
{ {
FLAC__uint32 comment; FLAC__uint32 comment;
uint8_t loopTagCount; uint8_t loopTagCount;
@ -617,40 +619,37 @@ int32_t MV_PlayLoopedFLAC
} }
while (FLAC__metadata_iterator_next(metadata_iterator)); while (FLAC__metadata_iterator_next(metadata_iterator));
if (loopstart < 1) if (vc_loopstart != NULL)
{ {
if (vc_loopstart != NULL)
{ {
const FLAC__int64 flac_loopstart = atol(vc_loopstart);
if (flac_loopstart >= 0) // a loop starting at 0 is valid
{ {
const FLAC__int64 flac_loopstart = atol(vc_loopstart); voice->LoopStart = (const char *) (intptr_t) flac_loopstart;
if (flac_loopstart >= 0) // a loop starting at 0 is valid voice->LoopSize = 1;
{
voice->LoopStart = (const char *) (intptr_t) flac_loopstart;
voice->LoopSize = 1;
}
} }
free(vc_loopstart);
} }
if (vc_loopend != NULL) free(vc_loopstart);
}
if (vc_loopend != NULL)
{
if (voice->LoopSize > 0)
{ {
if (voice->LoopSize > 0) const FLAC__int64 flac_loopend = atol(vc_loopend);
{ if (flac_loopend > 0) // a loop ending at 0 is invalid
const FLAC__int64 flac_loopend = atol(vc_loopend); voice->LoopEnd = (const char *) (intptr_t) flac_loopend;
if (flac_loopend > 0) // a loop ending at 0 is invalid
voice->LoopEnd = (const char *) (intptr_t) flac_loopend;
}
free(vc_loopend);
} }
if (vc_looplength != NULL) free(vc_loopend);
}
if (vc_looplength != NULL)
{
if (voice->LoopSize > 0 && voice->LoopEnd == 0)
{ {
if (voice->LoopSize > 0 && voice->LoopEnd == 0) const FLAC__int64 flac_looplength = atol(vc_looplength);
{ if (flac_looplength > 0) // a loop of length 0 is invalid
const FLAC__int64 flac_looplength = atol(vc_looplength); voice->LoopEnd = (const char *) ((intptr_t) flac_looplength + (intptr_t) voice->LoopStart);
if (flac_looplength > 0) // a loop of length 0 is invalid
voice->LoopEnd = (const char *) ((intptr_t) flac_looplength + (intptr_t) voice->LoopStart);
}
free(vc_looplength);
} }
free(vc_looplength);
} }
FLAC__metadata_iterator_delete(metadata_iterator); FLAC__metadata_iterator_delete(metadata_iterator);

View file

@ -419,7 +419,7 @@ static void MV_ServiceVoc(void)
else else
MV_16BitReverbFast(source, dest, count / 2, MV_ReverbLevel); MV_16BitReverbFast(source, dest, count / 2, MV_ReverbLevel);
} }
else else // if (MV_Bits == 8)
{ {
if (MV_ReverbTable != NULL) if (MV_ReverbTable != NULL)
MV_8BitReverb((int8_t *) source, (int8_t *) dest, MV_ReverbTable, count); MV_8BitReverb((int8_t *) source, (int8_t *) dest, MV_ReverbTable, count);
@ -1960,7 +1960,7 @@ int32_t MV_PlayLoopedRaw
voice->callbackval = callbackval; voice->callbackval = callbackval;
voice->LoopStart = loopstart; voice->LoopStart = loopstart;
voice->LoopEnd = loopend; voice->LoopEnd = loopend;
voice->LoopSize = (voice->LoopEnd - voice->LoopStart) + 1; voice->LoopSize = loopend > (char*) 0 ? (uintptr_t) loopend - (uintptr_t) loopstart + 1 : length;
MV_SetVoicePitch(voice, rate, pitchoffset); MV_SetVoicePitch(voice, rate, pitchoffset);
MV_SetVoiceVolume(voice, vol, left, right); MV_SetVoiceVolume(voice, vol, left, right);
@ -2080,8 +2080,6 @@ int32_t MV_PlayLoopedWAV
VoiceNode *voice; VoiceNode *voice;
int32_t length; int32_t length;
UNREFERENCED_PARAMETER(loopend);
if (!MV_Installed) if (!MV_Installed)
{ {
MV_SetErrorCode(MV_NotInstalled); MV_SetErrorCode(MV_NotInstalled);
@ -2167,7 +2165,6 @@ int32_t MV_PlayLoopedWAV
voice->Playing = TRUE; voice->Playing = TRUE;
voice->Paused = FALSE; voice->Paused = FALSE;
voice->DemandFeed = NULL; voice->DemandFeed = NULL;
voice->LoopStart = NULL;
voice->LoopCount = 0; voice->LoopCount = 0;
voice->position = 0; voice->position = 0;
voice->length = 0; voice->length = 0;
@ -2179,7 +2176,7 @@ int32_t MV_PlayLoopedWAV
voice->callbackval = callbackval; voice->callbackval = callbackval;
voice->LoopStart = loopstart >= 0 ? voice->NextBlock : NULL; voice->LoopStart = loopstart >= 0 ? voice->NextBlock : NULL;
voice->LoopEnd = NULL; voice->LoopEnd = NULL;
voice->LoopSize = length; voice->LoopSize = loopend > 0 ? loopend - loopstart + 1 : length;
MV_SetVoicePitch(voice, format.nSamplesPerSec, pitchoffset); MV_SetVoicePitch(voice, format.nSamplesPerSec, pitchoffset);
MV_SetVoiceVolume(voice, vol, left, right); MV_SetVoiceVolume(voice, vol, left, right);
@ -2328,7 +2325,6 @@ int32_t MV_PlayLoopedVOC
voice->GetSound = MV_GetNextVOCBlock; voice->GetSound = MV_GetNextVOCBlock;
voice->NextBlock = ptr + LITTLE16(*(uint16_t *)(ptr + 0x14)); voice->NextBlock = ptr + LITTLE16(*(uint16_t *)(ptr + 0x14));
voice->DemandFeed = NULL; voice->DemandFeed = NULL;
voice->LoopStart = NULL;
voice->LoopCount = 0; voice->LoopCount = 0;
voice->BlockLength = 0; voice->BlockLength = 0;
voice->PitchScale = PITCH_GetScale(pitchoffset); voice->PitchScale = PITCH_GetScale(pitchoffset);
@ -2337,16 +2333,10 @@ int32_t MV_PlayLoopedVOC
voice->prev = NULL; voice->prev = NULL;
voice->priority = priority; voice->priority = priority;
voice->callbackval = callbackval; voice->callbackval = callbackval;
voice->LoopStart = loopstart >= 0 ? voice->NextBlock : 0; voice->LoopStart = loopstart >= 0 ? voice->NextBlock : NULL;
voice->LoopEnd = 0; voice->LoopEnd = NULL;
voice->LoopSize = loopend - loopstart + 1; voice->LoopSize = loopend - loopstart + 1;
if (loopstart < 0)
{
voice->LoopStart = NULL;
voice->LoopEnd = NULL;
}
MV_SetVoiceVolume(voice, vol, left, right); MV_SetVoiceVolume(voice, vol, left, right);
MV_PlayVoice(voice); MV_PlayVoice(voice);

View file

@ -393,6 +393,8 @@ int32_t MV_PlayLoopedVorbis
vorbis_data * vd = 0; vorbis_data * vd = 0;
vorbis_info * vi = 0; vorbis_info * vi = 0;
UNREFERENCED_PARAMETER(loopend);
if ( !MV_Installed ) if ( !MV_Installed )
{ {
MV_SetErrorCode( MV_NotInstalled ); MV_SetErrorCode( MV_NotInstalled );
@ -459,13 +461,12 @@ int32_t MV_PlayLoopedVorbis
voice->priority = priority; voice->priority = priority;
voice->callbackval = callbackval; voice->callbackval = callbackval;
voice->LoopStart = (char *) (intptr_t)(loopstart >= 0 ? loopstart : 0); voice->LoopStart = 0;
voice->LoopEnd = (char *) (intptr_t)(loopstart >= 0 && loopend > 0 ? loopend : 0); voice->LoopEnd = 0;
voice->LoopSize = (loopstart >= 0 ? 1 : 0); voice->LoopSize = (loopstart >= 0 ? 1 : 0);
// load loop tags from metadata // load loop tags from metadata
if (loopstart < 1) MV_GetVorbisCommentLoops(voice, ov_comment(&vd->vf, 0));
MV_GetVorbisCommentLoops(voice, ov_comment(&vd->vf, 0));
voice->Playing = TRUE; voice->Playing = TRUE;
voice->Paused = FALSE; voice->Paused = FALSE;