IMA DO MY ADPCM
This commit is contained in:
parent
83e7b2fbb8
commit
229766c478
7 changed files with 30 additions and 10 deletions
|
|
@ -156,7 +156,7 @@ void DivPlatformNDS::tick(bool sysTick) {
|
|||
if (chan[i].pcm || i<8) {
|
||||
DivSample* s=parent->getSample(chan[i].sample);
|
||||
switch (s->depth) {
|
||||
//case DIV_SAMPLE_DEPTH_YMZ_ADPCM: ctrl=0x40; break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: ctrl=0x40; break;
|
||||
case DIV_SAMPLE_DEPTH_8BIT: ctrl=0x00; break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT: ctrl=0x20; break;
|
||||
default: break;
|
||||
|
|
@ -179,7 +179,7 @@ void DivPlatformNDS::tick(bool sysTick) {
|
|||
}
|
||||
if (chan[i].audPos>0) {
|
||||
switch (s->depth) {
|
||||
//case DIV_SAMPLE_DEPTH_YMZ_ADPCM: start+=chan[i].audPos/2; end-=(chan[i].audPos/8); break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: start+=chan[i].audPos/2; end-=(chan[i].audPos/8); break;
|
||||
case DIV_SAMPLE_DEPTH_8BIT: start+=chan[i].audPos; end-=(chan[i].audPos/4); break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT: start+=chan[i].audPos*2; end-=(chan[i].audPos/2); break;
|
||||
default: break;
|
||||
|
|
@ -188,8 +188,7 @@ void DivPlatformNDS::tick(bool sysTick) {
|
|||
if (s->isLoopable()) {
|
||||
if (chan[i].audPos>0) {
|
||||
switch (s->depth) {
|
||||
/*
|
||||
case DIV_SAMPLE_DEPTH_YMZ_ADPCM:
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM:
|
||||
loopStart=(s->loopStart-chan[i].audPos)/8;
|
||||
loopEnd=(s->loopEnd-s->loopStart)/8;
|
||||
if (chan[i].audPos>(unsigned int)s->loopStart) {
|
||||
|
|
@ -197,7 +196,6 @@ void DivPlatformNDS::tick(bool sysTick) {
|
|||
loopEnd-=(chan[i].audPos-s->loopStart)/8;
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case DIV_SAMPLE_DEPTH_8BIT:
|
||||
loopStart=(s->loopStart-chan[i].audPos)/4;
|
||||
loopEnd=(s->loopEnd-s->loopStart)/4;
|
||||
|
|
@ -218,7 +216,7 @@ void DivPlatformNDS::tick(bool sysTick) {
|
|||
}
|
||||
} else {
|
||||
switch (s->depth) {
|
||||
//case DIV_SAMPLE_DEPTH_YMZ_ADPCM: loopStart=s->loopStart/8; loopEnd=(s->loopEnd-s->loopStart)/8; break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: loopStart=s->loopStart/8; loopEnd=(s->loopEnd-s->loopStart)/8; break;
|
||||
case DIV_SAMPLE_DEPTH_8BIT: loopStart=s->loopStart/4; loopEnd=(s->loopEnd-s->loopStart)/4; break;
|
||||
case DIV_SAMPLE_DEPTH_16BIT: loopStart=s->loopStart/2; loopEnd=(s->loopEnd-s->loopStart)/2; break;
|
||||
default: break;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ extern "C" {
|
|||
#include "../../extern/adpcm/ymb_codec.h"
|
||||
#include "../../extern/adpcm/ymz_codec.h"
|
||||
}
|
||||
#include "../../extern/adpcm-xq/adpcm-lib.h"
|
||||
#include "brrUtils.h"
|
||||
|
||||
DivSampleHistory::~DivSampleHistory() {
|
||||
|
|
@ -599,7 +600,7 @@ bool DivSample::initInternal(DivSampleDepth d, int count) {
|
|||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: // IMA ADPCM
|
||||
if (dataIMA!=NULL) delete[] dataIMA;
|
||||
lengthIMA=(count+1)/2;
|
||||
lengthIMA=4+((count+1)/2);
|
||||
dataIMA=new unsigned char[lengthIMA];
|
||||
memset(dataIMA,0,lengthIMA);
|
||||
break;
|
||||
|
|
@ -1288,7 +1289,7 @@ void DivSample::render(unsigned int formatMask) {
|
|||
}
|
||||
break;
|
||||
case DIV_SAMPLE_DEPTH_IMA_ADPCM: // IMA ADPCM
|
||||
// TODO: decode
|
||||
if (adpcm_decode_block(data16,dataIMA,lengthIMA,1)==0) logE("oh crap!");
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
|
@ -1461,9 +1462,22 @@ void DivSample::render(unsigned int formatMask) {
|
|||
dataC219[i]=x|(negate?0x80:0);
|
||||
}
|
||||
}
|
||||
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_IMA_ADPCM)) { // C219
|
||||
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_IMA_ADPCM)) { // IMA ADPCM
|
||||
if (!initInternal(DIV_SAMPLE_DEPTH_IMA_ADPCM,samples)) return;
|
||||
// TODO: encode
|
||||
int delta[2];
|
||||
delta[0]=0;
|
||||
delta[1]=0;
|
||||
|
||||
void* codec=adpcm_create_context(1,4,NOISE_SHAPING_OFF,delta);
|
||||
if (codec==NULL) {
|
||||
logE("oh no IMA encoder could not be created!");
|
||||
} else {
|
||||
size_t whyPointer=0;
|
||||
adpcm_encode_block(codec,dataIMA,&whyPointer,data16,samples);
|
||||
if (whyPointer!=lengthIMA) logW("IMA length mismatch! %d -> %d!=%d",(int)samples,(int)whyPointer,(int)lengthIMA);
|
||||
|
||||
adpcm_free_context(codec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue