From 11e0897defc943ca2887797fba4c665bb36c2ca8 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 29 Dec 2012 10:58:09 +0000 Subject: [PATCH] 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 --- polymer/eduke32/source/actors.c | 3 + polymer/eduke32/source/astub.c | 3 + polymer/eduke32/source/jaudiolib/src/flac.c | 55 +++++++++---------- .../eduke32/source/jaudiolib/src/multivoc.c | 20 ++----- polymer/eduke32/source/jaudiolib/src/vorbis.c | 9 +-- 5 files changed, 43 insertions(+), 47 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index 6ffc8b416..8c0ca0d70 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -1267,6 +1267,7 @@ ACTOR_STATIC void G_MoveFX(void) 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) { int32_t j; @@ -1284,7 +1285,9 @@ ACTOR_STATIC void G_MoveFX(void) goto BOLT; } + g_sounds[s->lotag].m |= 1; A_PlaySound(s->lotag,i); + g_sounds[s->lotag].m = om; T1 = 1; } else if (x >= ht && T1 == 1) diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 5ccce9906..eafea43ce 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -2577,6 +2577,7 @@ static void M32_MoveFX(void) x = dist((spritetype *)&pos,s); 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) { for (j = headspritestat[0]; j >= 0; j = nextspritestat[j]) @@ -2591,7 +2592,9 @@ static void M32_MoveFX(void) } if (j == -1) continue; } + g_sounds[s->lotag].m |= 1; A_PlaySound(s->lotag,i); + g_sounds[s->lotag].m = om; T1 |= 1; } if (x >= ht && (T1&1) == 1) diff --git a/polymer/eduke32/source/jaudiolib/src/flac.c b/polymer/eduke32/source/jaudiolib/src/flac.c index 6666a6466..ce5d407d9 100644 --- a/polymer/eduke32/source/jaudiolib/src/flac.c +++ b/polymer/eduke32/source/jaudiolib/src/flac.c @@ -469,6 +469,8 @@ int32_t MV_PlayLoopedFLAC flac_data * fd = 0; FLAC__Metadata_Chain* metadata_chain; + UNREFERENCED_PARAMETER(loopend); + if ( !MV_Installed ) { MV_SetErrorCode( MV_NotInstalled ); @@ -538,8 +540,8 @@ int32_t MV_PlayLoopedFLAC voice->Playing = TRUE; voice->Paused = FALSE; - voice->LoopStart = (char *) (intptr_t)(loopstart >= 0 ? loopstart : 0); - voice->LoopEnd = (char *) (intptr_t)(loopstart >= 0 && loopend > 0 ? loopend : 0); + voice->LoopStart = 0; + voice->LoopEnd = 0; voice->LoopSize = (loopstart >= 0 ? 1 : 0); // parse metadata @@ -585,7 +587,7 @@ int32_t MV_PlayLoopedFLAC } // 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; uint8_t loopTagCount; @@ -617,40 +619,37 @@ int32_t MV_PlayLoopedFLAC } 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); - if (flac_loopstart >= 0) // a loop starting at 0 is valid - { - voice->LoopStart = (const char *) (intptr_t) flac_loopstart; - 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 - voice->LoopEnd = (const char *) (intptr_t) flac_loopend; - } - free(vc_loopend); + const FLAC__int64 flac_loopend = atol(vc_loopend); + if (flac_loopend > 0) // a loop ending at 0 is invalid + voice->LoopEnd = (const char *) (intptr_t) flac_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 - voice->LoopEnd = (const char *) ((intptr_t) flac_looplength + (intptr_t) voice->LoopStart); - } - free(vc_looplength); + const FLAC__int64 flac_looplength = atol(vc_looplength); + 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); } FLAC__metadata_iterator_delete(metadata_iterator); diff --git a/polymer/eduke32/source/jaudiolib/src/multivoc.c b/polymer/eduke32/source/jaudiolib/src/multivoc.c index dcb51349b..7a85d40ac 100644 --- a/polymer/eduke32/source/jaudiolib/src/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/src/multivoc.c @@ -419,7 +419,7 @@ static void MV_ServiceVoc(void) else MV_16BitReverbFast(source, dest, count / 2, MV_ReverbLevel); } - else + else // if (MV_Bits == 8) { if (MV_ReverbTable != NULL) MV_8BitReverb((int8_t *) source, (int8_t *) dest, MV_ReverbTable, count); @@ -1960,7 +1960,7 @@ int32_t MV_PlayLoopedRaw voice->callbackval = callbackval; voice->LoopStart = loopstart; 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_SetVoiceVolume(voice, vol, left, right); @@ -2080,8 +2080,6 @@ int32_t MV_PlayLoopedWAV VoiceNode *voice; int32_t length; - UNREFERENCED_PARAMETER(loopend); - if (!MV_Installed) { MV_SetErrorCode(MV_NotInstalled); @@ -2167,7 +2165,6 @@ int32_t MV_PlayLoopedWAV voice->Playing = TRUE; voice->Paused = FALSE; voice->DemandFeed = NULL; - voice->LoopStart = NULL; voice->LoopCount = 0; voice->position = 0; voice->length = 0; @@ -2179,7 +2176,7 @@ int32_t MV_PlayLoopedWAV voice->callbackval = callbackval; voice->LoopStart = loopstart >= 0 ? voice->NextBlock : NULL; voice->LoopEnd = NULL; - voice->LoopSize = length; + voice->LoopSize = loopend > 0 ? loopend - loopstart + 1 : length; MV_SetVoicePitch(voice, format.nSamplesPerSec, pitchoffset); MV_SetVoiceVolume(voice, vol, left, right); @@ -2328,7 +2325,6 @@ int32_t MV_PlayLoopedVOC voice->GetSound = MV_GetNextVOCBlock; voice->NextBlock = ptr + LITTLE16(*(uint16_t *)(ptr + 0x14)); voice->DemandFeed = NULL; - voice->LoopStart = NULL; voice->LoopCount = 0; voice->BlockLength = 0; voice->PitchScale = PITCH_GetScale(pitchoffset); @@ -2337,16 +2333,10 @@ int32_t MV_PlayLoopedVOC voice->prev = NULL; voice->priority = priority; voice->callbackval = callbackval; - voice->LoopStart = loopstart >= 0 ? voice->NextBlock : 0; - voice->LoopEnd = 0; + voice->LoopStart = loopstart >= 0 ? voice->NextBlock : NULL; + voice->LoopEnd = NULL; voice->LoopSize = loopend - loopstart + 1; - if (loopstart < 0) - { - voice->LoopStart = NULL; - voice->LoopEnd = NULL; - } - MV_SetVoiceVolume(voice, vol, left, right); MV_PlayVoice(voice); diff --git a/polymer/eduke32/source/jaudiolib/src/vorbis.c b/polymer/eduke32/source/jaudiolib/src/vorbis.c index 8e072b136..aa8f5df4a 100644 --- a/polymer/eduke32/source/jaudiolib/src/vorbis.c +++ b/polymer/eduke32/source/jaudiolib/src/vorbis.c @@ -393,6 +393,8 @@ int32_t MV_PlayLoopedVorbis vorbis_data * vd = 0; vorbis_info * vi = 0; + UNREFERENCED_PARAMETER(loopend); + if ( !MV_Installed ) { MV_SetErrorCode( MV_NotInstalled ); @@ -459,13 +461,12 @@ int32_t MV_PlayLoopedVorbis voice->priority = priority; voice->callbackval = callbackval; - voice->LoopStart = (char *) (intptr_t)(loopstart >= 0 ? loopstart : 0); - voice->LoopEnd = (char *) (intptr_t)(loopstart >= 0 && loopend > 0 ? loopend : 0); + voice->LoopStart = 0; + voice->LoopEnd = 0; voice->LoopSize = (loopstart >= 0 ? 1 : 0); // 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->Paused = FALSE;