diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 50fbc9bd0..2e55d5137 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -869,6 +869,8 @@ void DivEngine::renderSamples() { s->rendLength=(double)s->length/samplePitches[s->pitch]; s->rendData=new short[s->rendLength]; size_t adpcmLen=((s->rendLength>>1)+255)&0xffffff00; + s->adpcmRendLength=adpcmLen; + printf("al: %x\n",s->adpcmRendLength); s->adpcmRendData=new unsigned char[adpcmLen]; memset(s->adpcmRendData,0,adpcmLen); diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index a0d75cbe5..e9a4fa235 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -187,10 +187,10 @@ int DivPlatformYM2610::dispatch(DivCommand c) { } writes.emplace(0x110+c.chan-7,0); writes.emplace(0x118+c.chan-7,c.value%12); - int sampleLen=(parent->song.sample[12*sampleBank+c.value%12]->rendLength+255)>>8; + int sampleLen=(parent->song.sample[12*sampleBank+c.value%12]->adpcmRendLength-1)>>8; writes.emplace(0x120+c.chan-7,sampleLen&0xff); writes.emplace(0x128+c.chan-7,(c.value%12)+(sampleLen>>8)); - writes.emplace(0x108+c.chan-7,0xff); + writes.emplace(0x108+(c.chan-7),0xc0|chan[c.chan].vol); writes.emplace(0x100,0x00|(1<<(c.chan-7))); break; } @@ -251,7 +251,11 @@ int DivPlatformYM2610::dispatch(DivCommand c) { case DIV_CMD_VOLUME: { chan[c.chan].vol=c.value; DivInstrument* ins=parent->getIns(chan[c.chan].ins); - if (c.chan>3) { + if (c.chan>6) { // ADPCM + writes.emplace(0x108+(c.chan-7),0xc0|chan[c.chan].vol); + break; + } + if (c.chan>3) { // PSG if (!chan[c.chan].std.hasVol) { chan[c.chan].outVol=c.value; } diff --git a/src/engine/sample.h b/src/engine/sample.h index fc0daeb1e..0917461df 100644 --- a/src/engine/sample.h +++ b/src/engine/sample.h @@ -4,7 +4,7 @@ struct DivSample { signed char vol, pitch; unsigned char depth; short* data; - int rendLength; + int rendLength, adpcmRendLength; short* rendData; unsigned char* adpcmRendData; @@ -17,6 +17,7 @@ struct DivSample { depth(16), data(NULL), rendLength(0), + adpcmRendLength(0), rendData(NULL), adpcmRendData(NULL) {} };