From 5e282e6c1340f504315b19793420175ce12ea295 Mon Sep 17 00:00:00 2001 From: dinkc64 <12570148+dinkc64@users.noreply.github.com> Date: Fri, 4 Apr 2014 13:04:23 +0000 Subject: [PATCH] Fix for stuck noise at the end of short samples in games that use the Toaplan samples hack. FireShark, SameSameSame!, Ghox, Vimana and TekiPaki --- src/burn/snd/samples.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/burn/snd/samples.cpp b/src/burn/snd/samples.cpp index 33f1c3e20..d3c39040a 100644 --- a/src/burn/snd/samples.cpp +++ b/src/burn/snd/samples.cpp @@ -382,7 +382,11 @@ void BurnSampleRender(INT16 *pDest, UINT32 pLen) if (pBurnSoundOut == NULL) return; INT32 nFirstSample = 0; - UINT32 *dest = (UINT32*)pDest; + UINT32 *dest = (UINT32*)pDest; + + if (bAddToStream == 0) { + memset(dest, 0, pLen * 4); // clear buffer to get rid of unwanted noise at end of short samples - dink + } for (INT32 i = 0; i < nTotalSamples; i++) { @@ -461,14 +465,13 @@ void BurnSampleRender(INT16 *pDest, UINT32 pLen) if (length <= 0) { if (loop == 0) { - sample_ptr->playing = 0; - continue; + sample_ptr->playing = 0; + continue; } - } + } data += position; if (playlen > length) playlen = length; - if (bAddToStream == 0 && nFirstSample == 0) { INT16 *dst = (INT16*)dest; INT16 *dat = (INT16*)data;