prepare for IMA ADPCM
This commit is contained in:
parent
8b3c48d42e
commit
83e7b2fbb8
|
@ -564,9 +564,13 @@ size | description
|
|||
| - 4: QSound ADPCM
|
||||
| - 5: ADPCM-A
|
||||
| - 6: ADPCM-B
|
||||
| - 7: K05 ADPCM
|
||||
| - 8: 8-bit PCM
|
||||
| - 9: BRR (SNES)
|
||||
| - 10: VOX
|
||||
| - 11: 8-bit μ-law PCM
|
||||
| - 12: C219 PCM
|
||||
| - 13: IMA ADPCM
|
||||
| - 16: 16-bit PCM
|
||||
1 | loop direction (>=123) or reserved
|
||||
| - 0: forward
|
||||
|
|
|
@ -124,6 +124,8 @@ the following instrument types are available:
|
|||
- 55: ESFM
|
||||
- 56: PowerNoise (noise)
|
||||
- 57: PowerNoise (slope)
|
||||
- 58: Dave
|
||||
- 59: NDS
|
||||
|
||||
the following feature codes are recognized:
|
||||
|
||||
|
|
|
@ -279,6 +279,9 @@ int DivSample::getSampleOffset(int offset, int length, DivSampleDepth depth) {
|
|||
case DIV_SAMPLE_DEPTH_C219:
|
||||
off=offset;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
off=(offset+1)/2;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
off=offset*2;
|
||||
break;
|
||||
|
@ -338,6 +341,10 @@ int DivSample::getSampleOffset(int offset, int length, DivSampleDepth depth) {
|
|||
off=offset;
|
||||
len=length;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
off=(offset+1)/2;
|
||||
len=(length+1)/2;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
off=offset*2;
|
||||
len=length*2;
|
||||
|
@ -396,6 +403,9 @@ int DivSample::getEndPosition(DivSampleDepth depth) {
|
|||
case DIV_SAMPLE_DEPTH_C219:
|
||||
off=lengthC219;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
off=lengthIMA;
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
off=length16;
|
||||
break;
|
||||
|
@ -587,6 +597,12 @@ bool DivSample::initInternal(DivSampleDepth d, int count) {
|
|||
dataC219=new unsigned char[(count+4095)&(~0xfff)];
|
||||
memset(dataC219,0,(count+4095)&(~0xfff));
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: // IMA ADPCM
|
||||
if (dataIMA!=NULL) delete[] dataIMA;
|
||||
lengthIMA=(count+1)/2;
|
||||
dataIMA=new unsigned char[lengthIMA];
|
||||
memset(dataIMA,0,lengthIMA);
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT: // 16-bit
|
||||
if (data16!=NULL) delete[] data16;
|
||||
length16=count*2;
|
||||
|
@ -1271,6 +1287,9 @@ void DivSample::render(unsigned int formatMask) {
|
|||
if (dataC219[i]&0x80) data16[i]=-data16[i];
|
||||
}
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: // IMA ADPCM
|
||||
// TODO: decode
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
@ -1442,6 +1461,10 @@ void DivSample::render(unsigned int formatMask) {
|
|||
dataC219[i]=x|(negate?0x80:0);
|
||||
}
|
||||
}
|
||||
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_IMA_ADPCM)) { // C219
|
||||
if (!initInternal(DIV_SAMPLE_DEPTH_IMA_ADPCM,samples)) return;
|
||||
// TODO: encode
|
||||
}
|
||||
}
|
||||
|
||||
void* DivSample::getCurBuf() {
|
||||
|
@ -1470,6 +1493,8 @@ void* DivSample::getCurBuf() {
|
|||
return dataMuLaw;
|
||||
case DIV_SAMPLE_DEPTH_C219:
|
||||
return dataC219;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
return dataIMA;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
return data16;
|
||||
default:
|
||||
|
@ -1504,6 +1529,8 @@ unsigned int DivSample::getCurBufLen() {
|
|||
return lengthMuLaw;
|
||||
case DIV_SAMPLE_DEPTH_C219:
|
||||
return lengthC219;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
return lengthIMA;
|
||||
case DIV_SAMPLE_DEPTH_16BIT:
|
||||
return length16;
|
||||
default:
|
||||
|
@ -1616,4 +1643,5 @@ DivSample::~DivSample() {
|
|||
if (dataVOX) delete[] dataVOX;
|
||||
if (dataMuLaw) delete[] dataMuLaw;
|
||||
if (dataC219) delete[] dataC219;
|
||||
if (dataIMA) delete[] dataIMA;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ enum DivSampleDepth: unsigned char {
|
|||
DIV_SAMPLE_DEPTH_VOX=10,
|
||||
DIV_SAMPLE_DEPTH_MULAW=11,
|
||||
DIV_SAMPLE_DEPTH_C219=12,
|
||||
DIV_SAMPLE_DEPTH_IMA_ADPCM=13,
|
||||
DIV_SAMPLE_DEPTH_16BIT=16,
|
||||
DIV_SAMPLE_DEPTH_MAX // boundary for sample depth
|
||||
};
|
||||
|
@ -114,6 +115,7 @@ struct DivSample {
|
|||
// - 10: VOX ADPCM
|
||||
// - 11: 8-bit µ-law PCM
|
||||
// - 12: C219 "µ-law" PCM
|
||||
// - 13: IMA ADPCM
|
||||
// - 16: 16-bit PCM
|
||||
DivSampleDepth depth;
|
||||
bool loop, brrEmphasis, dither;
|
||||
|
@ -139,8 +141,9 @@ struct DivSample {
|
|||
unsigned char* dataVOX; // 10
|
||||
unsigned char* dataMuLaw; // 11
|
||||
unsigned char* dataC219; // 12
|
||||
unsigned char* dataIMA; // 13
|
||||
|
||||
unsigned int length8, length16, length1, lengthDPCM, lengthZ, lengthQSoundA, lengthA, lengthB, lengthK, lengthBRR, lengthVOX, lengthMuLaw, lengthC219;
|
||||
unsigned int length8, length16, length1, lengthDPCM, lengthZ, lengthQSoundA, lengthA, lengthB, lengthK, lengthBRR, lengthVOX, lengthMuLaw, lengthC219, lengthIMA;
|
||||
|
||||
unsigned int samples;
|
||||
|
||||
|
@ -349,6 +352,7 @@ struct DivSample {
|
|||
dataVOX(NULL),
|
||||
dataMuLaw(NULL),
|
||||
dataC219(NULL),
|
||||
dataIMA(NULL),
|
||||
length8(0),
|
||||
length16(0),
|
||||
length1(0),
|
||||
|
@ -362,6 +366,7 @@ struct DivSample {
|
|||
lengthVOX(0),
|
||||
lengthMuLaw(0),
|
||||
lengthC219(0),
|
||||
lengthIMA(0),
|
||||
samples(0) {
|
||||
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||
for (int j=0; j<DIV_MAX_SAMPLE_TYPE; j++) {
|
||||
|
|
|
@ -2022,7 +2022,7 @@ void DivEngine::registerSystems() {
|
|||
);
|
||||
|
||||
sysDefs[DIV_SYSTEM_NDS]=new DivSysDef(
|
||||
"NDS", NULL, 0xd6, 0, 16, false, true, 0, false, (1U<<DIV_SAMPLE_DEPTH_8BIT)|(1U<<DIV_SAMPLE_DEPTH_16BIT), 32, 32,
|
||||
"NDS", NULL, 0xd6, 0, 16, false, true, 0, false, (1U<<DIV_SAMPLE_DEPTH_8BIT)|(1U<<DIV_SAMPLE_DEPTH_IMA_ADPCM)|(1U<<DIV_SAMPLE_DEPTH_16BIT), 32, 32,
|
||||
"a handheld video game console with two screens. it uses a stylus.",
|
||||
{"Channel 1", "Channel 2", "Channel 3", "Channel 4", "Channel 5", "Channel 6", "Channel 7", "Channel 8", "Channel 9", "Channel 10", "Channel 11", "Channel 12", "Channel 13", "Channel 14", "Channel 15", "Channel 16"},
|
||||
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"},
|
||||
|
|
|
@ -203,7 +203,7 @@ const char* sampleDepths[DIV_SAMPLE_DEPTH_MAX]={
|
|||
"VOX",
|
||||
"8-bit µ-law PCM",
|
||||
"C219 PCM",
|
||||
NULL,
|
||||
"IMA ADPCM",
|
||||
NULL,
|
||||
NULL,
|
||||
"16-bit PCM"
|
||||
|
|
Loading…
Reference in a new issue