From 32ec87ca27223f2f628b4b7352a8cf230dff2e45 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 29 Aug 2023 04:26:25 -0500 Subject: [PATCH] prepare for K05 ADPCM --- src/engine/fileOpsSample.cpp | 2 ++ src/engine/sample.cpp | 33 +++++++++++++++++++++++++++++++++ src/engine/sample.h | 7 ++++++- src/gui/guiConst.cpp | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/engine/fileOpsSample.cpp b/src/engine/fileOpsSample.cpp index 0cc3d5b56..ac9441adc 100644 --- a/src/engine/fileOpsSample.cpp +++ b/src/engine/fileOpsSample.cpp @@ -390,6 +390,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, case DIV_SAMPLE_DEPTH_QSOUND_ADPCM: case DIV_SAMPLE_DEPTH_ADPCM_A: case DIV_SAMPLE_DEPTH_ADPCM_B: + case DIV_SAMPLE_DEPTH_ADPCM_K: case DIV_SAMPLE_DEPTH_VOX: samples=lenDivided*2; break; @@ -488,6 +489,7 @@ DivSample* DivEngine::sampleFromFileRaw(const char* path, DivSampleDepth depth, case DIV_SAMPLE_DEPTH_QSOUND_ADPCM: case DIV_SAMPLE_DEPTH_ADPCM_A: case DIV_SAMPLE_DEPTH_ADPCM_B: + case DIV_SAMPLE_DEPTH_ADPCM_K: case DIV_SAMPLE_DEPTH_VOX: // swap nibbles for (unsigned int i=0; igetCurBufLen(); i++) { diff --git a/src/engine/sample.cpp b/src/engine/sample.cpp index fe640d270..21738b8aa 100644 --- a/src/engine/sample.cpp +++ b/src/engine/sample.cpp @@ -261,6 +261,9 @@ int DivSample::getSampleOffset(int offset, int length, DivSampleDepth depth) { case DIV_SAMPLE_DEPTH_ADPCM_B: off=(offset+1)/2; break; + case DIV_SAMPLE_DEPTH_ADPCM_K: + off=(offset+1)/2; + break; case DIV_SAMPLE_DEPTH_8BIT: off=offset; break; @@ -311,6 +314,10 @@ int DivSample::getSampleOffset(int offset, int length, DivSampleDepth depth) { off=(offset+1)/2; len=(length+1)/2; break; + case DIV_SAMPLE_DEPTH_ADPCM_K: + off=(offset+1)/2; + len=(length+1)/2; + break; case DIV_SAMPLE_DEPTH_8BIT: off=offset; len=length; @@ -371,6 +378,9 @@ int DivSample::getEndPosition(DivSampleDepth depth) { case DIV_SAMPLE_DEPTH_ADPCM_B: off=lengthB; break; + case DIV_SAMPLE_DEPTH_ADPCM_K: + off=lengthK; + break; case DIV_SAMPLE_DEPTH_8BIT: off=length8; break; @@ -540,6 +550,12 @@ bool DivSample::initInternal(DivSampleDepth d, int count) { dataB=new unsigned char[(lengthB+255)&(~0xff)]; memset(dataB,0,(lengthB+255)&(~0xff)); break; + case DIV_SAMPLE_DEPTH_ADPCM_K: // K05 ADPCM + if (dataK!=NULL) delete[] dataK; + lengthK=(count+1)/2; + dataK=new unsigned char[(lengthK+255)&(~0xff)]; + memset(dataK,0,(lengthK+255)&(~0xff)); + break; case DIV_SAMPLE_DEPTH_8BIT: // 8-bit if (data8!=NULL) delete[] data8; length8=count; @@ -800,6 +816,9 @@ void DivSample::convert(DivSampleDepth newDepth) { case DIV_SAMPLE_DEPTH_ADPCM_B: // ADPCM-B setSampleCount((samples+1)&(~1)); break; + case DIV_SAMPLE_DEPTH_ADPCM_K: // K05 ADPCM + setSampleCount((samples+1)&(~1)); + break; case DIV_SAMPLE_DEPTH_BRR: // BRR setSampleCount(16*(lengthBRR/9)); break; @@ -1209,6 +1228,11 @@ void DivSample::render(unsigned int formatMask) { case DIV_SAMPLE_DEPTH_ADPCM_B: // ADPCM-B ymb_decode(dataB,data16,samples); break; + case DIV_SAMPLE_DEPTH_ADPCM_K: // K05 ADPCM + for (unsigned int i=0; i