From 97f70ed81db9d903cedd3d900d176aa16fc1241d Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Thu, 12 May 2022 01:27:25 +0000 Subject: DLS: fix loop calculation for 16-bit Support for 16-bit wavetables was added in AOSP CL 9013377 This loop calculation should have been updated but was missed. This CL updates DLS_StartVoice() to match WT_StartVoice(). Thanks to kyungmin.jun at LGE for reporting the bug and suggesting the fix. Bug: 204673472 Test: Play a Jet file with DLS loops. See bug for repo. Test: atest JetPlayerTest Change-Id: I98e73a93296d9af455a51c64c767eb1ac7a5eba6 --- arm-wt-22k/lib_src/eas_dlssynth.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/arm-wt-22k/lib_src/eas_dlssynth.c b/arm-wt-22k/lib_src/eas_dlssynth.c index 8606a29..a07262c 100644 --- a/arm-wt-22k/lib_src/eas_dlssynth.c +++ b/arm-wt-22k/lib_src/eas_dlssynth.c @@ -348,11 +348,24 @@ EAS_RESULT DLS_StartVoice (S_VOICE_MGR *pVoiceMgr, S_SYNTH *pSynth, S_SYNTH_VOIC pWTVoice->phaseAccum = (EAS_U32) pSynth->pDLS->pDLSSamples + pSynth->pDLS->pDLSSampleOffsets[pDLSRegion->wtRegion.waveIndex]; if (pDLSRegion->wtRegion.region.keyGroupAndFlags & REGION_FLAG_IS_LOOPED) { +#if defined (_8_BIT_SAMPLES) pWTVoice->loopStart = pWTVoice->phaseAccum + pDLSRegion->wtRegion.loopStart; pWTVoice->loopEnd = pWTVoice->phaseAccum + pDLSRegion->wtRegion.loopEnd - 1; +#else //_16_BIT_SAMPLES + pWTVoice->loopStart = pWTVoice->phaseAccum + (pDLSRegion->wtRegion.loopStart<<1); + pWTVoice->loopEnd = pWTVoice->phaseAccum + (pDLSRegion->wtRegion.loopEnd<<1) - 2; +#endif } else - pWTVoice->loopStart = pWTVoice->loopEnd = pWTVoice->phaseAccum + pSynth->pDLS->pDLSSampleLen[pDLSRegion->wtRegion.waveIndex] - 1; + { +#if defined (_8_BIT_SAMPLES) + pWTVoice->loopStart = pWTVoice->loopEnd = pWTVoice->phaseAccum + + pSynth->pDLS->pDLSSampleLen[pDLSRegion->wtRegion.waveIndex] - 1; +#else //_16_BIT_SAMPLES + pWTVoice->loopStart = pWTVoice->loopEnd = pWTVoice->phaseAccum + + pSynth->pDLS->pDLSSampleLen[pDLSRegion->wtRegion.waveIndex] - 2; +#endif + } return EAS_SUCCESS; } -- cgit v1.2.3