prepare for K05 ADPCM
This commit is contained in:
parent
eaac5cc224
commit
32ec87ca27
|
@ -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; i<sample->getCurBufLen(); i++) {
|
||||
|
|
|
@ -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<samples; i++) {
|
||||
// TODO: ADPCM-K
|
||||
}
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_8BIT: // 8-bit PCM
|
||||
for (unsigned int i=0; i<samples; i++) {
|
||||
data16[i]=data8[i]<<8;
|
||||
|
@ -1282,6 +1306,10 @@ void DivSample::render(unsigned int formatMask) {
|
|||
if (!initInternal(DIV_SAMPLE_DEPTH_ADPCM_B,samples)) return;
|
||||
ymb_encode(data16,dataB,(samples+511)&(~0x1ff));
|
||||
}
|
||||
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_ADPCM_K)) { // K05 ADPCM
|
||||
if (!initInternal(DIV_SAMPLE_DEPTH_ADPCM_K,samples)) return;
|
||||
// TODO: ADPCM-K
|
||||
}
|
||||
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_8BIT)) { // 8-bit PCM
|
||||
if (!initInternal(DIV_SAMPLE_DEPTH_8BIT,samples)) return;
|
||||
if (dither) {
|
||||
|
@ -1362,6 +1390,8 @@ void* DivSample::getCurBuf() {
|
|||
return dataA;
|
||||
case DIV_SAMPLE_DEPTH_ADPCM_B:
|
||||
return dataB;
|
||||
case DIV_SAMPLE_DEPTH_ADPCM_K:
|
||||
return dataK;
|
||||
case DIV_SAMPLE_DEPTH_8BIT:
|
||||
return data8;
|
||||
case DIV_SAMPLE_DEPTH_BRR:
|
||||
|
@ -1394,6 +1424,8 @@ unsigned int DivSample::getCurBufLen() {
|
|||
return lengthA;
|
||||
case DIV_SAMPLE_DEPTH_ADPCM_B:
|
||||
return lengthB;
|
||||
case DIV_SAMPLE_DEPTH_ADPCM_K:
|
||||
return lengthK;
|
||||
case DIV_SAMPLE_DEPTH_8BIT:
|
||||
return length8;
|
||||
case DIV_SAMPLE_DEPTH_BRR:
|
||||
|
@ -1511,6 +1543,7 @@ DivSample::~DivSample() {
|
|||
if (dataQSoundA) delete[] dataQSoundA;
|
||||
if (dataA) delete[] dataA;
|
||||
if (dataB) delete[] dataB;
|
||||
if (dataK) delete[] dataK;
|
||||
if (dataBRR) delete[] dataBRR;
|
||||
if (dataVOX) delete[] dataVOX;
|
||||
if (dataMuLaw) delete[] dataMuLaw;
|
||||
|
|
|
@ -40,6 +40,7 @@ enum DivSampleDepth: unsigned char {
|
|||
DIV_SAMPLE_DEPTH_QSOUND_ADPCM=4,
|
||||
DIV_SAMPLE_DEPTH_ADPCM_A=5,
|
||||
DIV_SAMPLE_DEPTH_ADPCM_B=6,
|
||||
DIV_SAMPLE_DEPTH_ADPCM_K=7,
|
||||
DIV_SAMPLE_DEPTH_8BIT=8,
|
||||
DIV_SAMPLE_DEPTH_BRR=9,
|
||||
DIV_SAMPLE_DEPTH_VOX=10,
|
||||
|
@ -107,6 +108,7 @@ struct DivSample {
|
|||
// - 4: QSound ADPCM
|
||||
// - 5: ADPCM-A
|
||||
// - 6: ADPCM-B
|
||||
// - 7: K053260 4-bit simple ADPCM
|
||||
// - 8: 8-bit PCM
|
||||
// - 9: BRR (SNES)
|
||||
// - 10: VOX ADPCM
|
||||
|
@ -132,12 +134,13 @@ struct DivSample {
|
|||
unsigned char* dataQSoundA; // 4
|
||||
unsigned char* dataA; // 5
|
||||
unsigned char* dataB; // 6
|
||||
unsigned char* dataK; // 7
|
||||
unsigned char* dataBRR; // 9
|
||||
unsigned char* dataVOX; // 10
|
||||
unsigned char* dataMuLaw; // 11
|
||||
unsigned char* dataC219; // 12
|
||||
|
||||
unsigned int length8, length16, length1, lengthDPCM, lengthZ, lengthQSoundA, lengthA, lengthB, lengthBRR, lengthVOX, lengthMuLaw, lengthC219;
|
||||
unsigned int length8, length16, length1, lengthDPCM, lengthZ, lengthQSoundA, lengthA, lengthB, lengthK, lengthBRR, lengthVOX, lengthMuLaw, lengthC219;
|
||||
|
||||
unsigned int samples;
|
||||
|
||||
|
@ -341,6 +344,7 @@ struct DivSample {
|
|||
dataQSoundA(NULL),
|
||||
dataA(NULL),
|
||||
dataB(NULL),
|
||||
dataK(NULL),
|
||||
dataBRR(NULL),
|
||||
dataVOX(NULL),
|
||||
dataMuLaw(NULL),
|
||||
|
@ -353,6 +357,7 @@ struct DivSample {
|
|||
lengthQSoundA(0),
|
||||
lengthA(0),
|
||||
lengthB(0),
|
||||
lengthK(0),
|
||||
lengthBRR(0),
|
||||
lengthVOX(0),
|
||||
lengthMuLaw(0),
|
||||
|
|
|
@ -192,7 +192,7 @@ const char* sampleDepths[DIV_SAMPLE_DEPTH_MAX]={
|
|||
"QSound ADPCM",
|
||||
"ADPCM-A",
|
||||
"ADPCM-B",
|
||||
NULL,
|
||||
"K05 ADPCM",
|
||||
"8-bit PCM",
|
||||
"BRR",
|
||||
"VOX",
|
||||
|
|
Loading…
Reference in New Issue