Possibly fix ES5506 sample offset command

This commit is contained in:
cam900 2023-02-13 07:52:52 +09:00
parent 21d6f4f6d6
commit 97bb0572b6
2 changed files with 20 additions and 14 deletions

View File

@ -588,6 +588,22 @@ void DivPlatformES5506::tick(bool sysTick) {
} }
chan[i].noteChanged.changed=0; chan[i].noteChanged.changed=0;
} }
if (chan[i].pcm.setPos) {
if (chan[i].active) {
const unsigned int start=chan[i].pcm.start;
const unsigned int end=chan[i].pcm.length;
const unsigned int pos=chan[i].pcm.direction?(end-chan[i].pcm.nextPos):chan[i].pcm.nextPos;
if ((chan[i].pcm.direction && pos>0) || ((!chan[i].pcm.direction) && pos<end)) {
pageWrite(0x20|i,0x03,start+(pos<<11));
}
} else {
// force keyon
chan[i].keyOn=true;
}
chan[i].pcm.setPos=false;
} else {
chan[i].pcm.nextPos=0;
}
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
chan[i].freq=CLAMP(parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,chan[i].pcm.freqOffs),0,0x1ffff); chan[i].freq=CLAMP(parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,chan[i].pcm.freqOffs),0,0x1ffff);
if (chan[i].keyOn) { if (chan[i].keyOn) {
@ -1029,20 +1045,8 @@ int DivPlatformES5506::dispatch(DivCommand c) {
chan[c.chan].inPorta=c.value; chan[c.chan].inPorta=c.value;
break; break;
case DIV_CMD_SAMPLE_POS: { case DIV_CMD_SAMPLE_POS: {
if (chan[c.chan].useWave) break; chan[c.chan].pcm.nextPos=c.value;
if (chan[c.chan].active) { chan[c.chan].pcm.setPos=true;
const unsigned int start=chan[c.chan].pcm.start;
const unsigned int end=chan[c.chan].pcm.length;
const unsigned int pos=chan[c.chan].pcm.direction?(end-c.value):c.value;
if ((chan[c.chan].pcm.direction && pos>0) || ((!chan[c.chan].pcm.direction) && pos<end)) {
pageWrite(0x20|c.chan,0x03,start+(pos<<11));
}
break;
} else {
if (chan[c.chan].pcm.nextPos!=0) {
chan[c.chan].pcm.nextPos=c.value;
}
}
break; break;
} }
case DIV_CMD_SAMPLE_DIR: { case DIV_CMD_SAMPLE_DIR: {

View File

@ -43,6 +43,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
unsigned int loopStart; unsigned int loopStart;
unsigned int loopEnd; unsigned int loopEnd;
unsigned int nextPos; unsigned int nextPos;
bool setPos;
DivSampleLoopMode loopMode; DivSampleLoopMode loopMode;
PCM(): PCM():
isNoteMap(false), isNoteMap(false),
@ -60,6 +61,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
loopStart(0), loopStart(0),
loopEnd(0), loopEnd(0),
nextPos(0), nextPos(0),
setPos(false),
loopMode(DIV_SAMPLE_LOOP_MAX) {} loopMode(DIV_SAMPLE_LOOP_MAX) {}
} pcm; } pcm;
int nextFreq, nextNote, currNote, wave; int nextFreq, nextNote, currNote, wave;