From 6acbb77ac54e33b9cbe9b391ad5185815beed7e0 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Tue, 13 Mar 2018 23:29:35 +0000 Subject: [PATCH] xa.cpp: Fix the crackling noise. git-svn-id: https://svn.eduke32.com/eduke32@6763 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/audiolib/src/xa.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/audiolib/src/xa.cpp b/source/audiolib/src/xa.cpp index 87adb066b..f54a8ed2a 100644 --- a/source/audiolib/src/xa.cpp +++ b/source/audiolib/src/xa.cpp @@ -285,7 +285,10 @@ void MV_SetXAPosition(VoiceNode *voice, int32_t position) xa_data * xad = (xa_data *) voice->rawdataptr; if (position < XA_DATA_START || (size_t)position >= xad->length) + { position = XA_DATA_START; + xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0; + } xad->pos = position; } @@ -308,8 +311,6 @@ static playbackstatus MV_GetNextXABlock voice->Playing = TRUE; - xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0; - do { size_t bytes = xad->length - xad->pos; @@ -348,7 +349,10 @@ static playbackstatus MV_GetNextXABlock if (xad->length == xad->pos) { if (voice->LoopSize > 0) + { xad->pos = XA_DATA_START; + xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0; + } else { voice->Playing = FALSE; @@ -454,6 +458,7 @@ int32_t MV_PlayXA xad->ptr = ptr; xad->pos = XA_DATA_START; + xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0; xad->blocksize = 0; xad->length = ptrlength;