From ef04090a4795382215c5e0667498e31cd6769d0d Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 24 Sep 2022 22:56:43 -0500 Subject: [PATCH 1/3] fix BRR loading corruption --- src/engine/brrUtils.c | 4 ++-- src/engine/sample.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/engine/brrUtils.c b/src/engine/brrUtils.c index a32e51603..2e8503072 100644 --- a/src/engine/brrUtils.c +++ b/src/engine/brrUtils.c @@ -111,10 +111,10 @@ long brrEncode(short* buf, unsigned char* out, long len, long loopStart) { next+=(last1*15)/16; \ break; \ case 8: \ - next+=((last1*61)/32)-((last2*15)/16); \ + next+=((last2*61)/32)-((last1*15)/16); \ break; \ case 12: \ - next+=((last1*115)/64)-((last2*13)/16); \ + next+=((last2*115)/64)-((last1*13)/16); \ break; \ } \ \ diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index 5e994c70b..ecebcfe74 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -852,7 +852,7 @@ void DivSample::render() { } break; case DIV_SAMPLE_DEPTH_BRR: // BRR - brrDecode(dataBRR,data16,samples); + brrDecode(dataBRR,data16,lengthBRR); break; case DIV_SAMPLE_DEPTH_VOX: // VOX oki_decode(dataVOX,data16,samples); From 8d72d2f2d02ccd9fce22cf98d268ac0f0a25c2cf Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 24 Sep 2022 22:58:44 -0500 Subject: [PATCH 2/3] shut Clang up --- src/engine/zsmOps.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/zsmOps.cpp b/src/engine/zsmOps.cpp index 47e819329..21ffd5ecb 100644 --- a/src/engine/zsmOps.cpp +++ b/src/engine/zsmOps.cpp @@ -86,7 +86,7 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) { // Prepare to write song data playSub(false); - size_t tickCount=0; + //size_t tickCount=0; bool done=false; int loopPos=-1; int writeCount=0; @@ -155,7 +155,7 @@ SafeWriter* DivEngine::saveZSM(unsigned int zsmrate, bool loop) { fracWait &= MASTER_CLOCK_MASK; if (totalWait>0) { zsm.tick(totalWait); - tickCount+=totalWait; + //tickCount+=totalWait; } } // end of song From e75f23fa6116a903b8c13751f2325614202b85fd Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 24 Sep 2022 23:16:46 -0500 Subject: [PATCH 3/3] wait what am I doing? --- src/engine/sample.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index ecebcfe74..4d0ec3bb0 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -243,7 +243,7 @@ bool DivSample::save(const char* path) { break; } default: - sf_write_raw(f,data16,length16); + sf_writef_short(f,data16,samples); break; } @@ -909,7 +909,7 @@ void DivSample::render() { data8[i]=data16[i]>>8; } } - if (depth!=DIV_SAMPLE_DEPTH_VOX) { // BRR + if (depth!=DIV_SAMPLE_DEPTH_BRR) { // BRR if (!initInternal(DIV_SAMPLE_DEPTH_BRR,samples)) return; // TODO: loop point brrEncode(data16,dataBRR,samples,0);