Prepare for split sample chip instrument

(MSM6258, MSM6295, QSound, Sega PCM, ADPCM-A, ADPCM-B, YMZ280B, RF5C68)
Instrument color and icons are placeholder.

different volume range, hard panned/soft panned and/or independent volume per output, chip-dependent features (global volume, echo, etc)
Allow use sample in instrument tab for chip with sample support
Prepare to support X1-010 Seta 2 style bankswitch behavior
Prepare to support AY89x0 PCM DAC
Support volume for PCE sample (DAC)
Fix Lynx, Y8950 sample pitch matches to sample preview
Support PCM DAC with backward and pingpong loop mode
Reduce some codes
Add Sega PCM, AY89x0, QSound, PCM DAC, Lynx per-channel debug support
This commit is contained in:
cam900 2022-08-27 16:27:36 +09:00
parent 86baa8c014
commit 4cc79fb49d
53 changed files with 2928 additions and 1301 deletions

View file

@ -36,26 +36,71 @@ void DivPlatformPCMDAC::acquire(short* bufL, short* bufR, size_t start, size_t l
continue;
}
if (chan.useWave || (chan.sample>=0 && chan.sample<parent->song.sampleLen)) {
chan.audPos+=chan.freq>>16;
chan.audPos+=((!chan.useWave) && chan.audDir)?-(chan.freq>>16):(chan.freq>>16);
chan.audSub+=(chan.freq&0xffff);
if (chan.audSub>=0x10000) {
chan.audSub-=0x10000;
chan.audPos+=1;
chan.audPos+=((!chan.useWave) && chan.audDir)?-1:1;
}
if (chan.useWave) {
if (chan.audPos>=(unsigned int)(chan.audLen<<1)) {
chan.audPos=0;
if (chan.audPos>=(int)chan.audLen) {
chan.audPos%=chan.audLen;
chan.audDir=false;
}
output=(chan.ws.output[chan.audPos]^0x80)<<8;
} else {
DivSample* s=parent->getSample(chan.sample);
if (s->getEndPosition()>0) {
if (s->isLoopable() && chan.audPos>=(unsigned int)s->getLoopEndPosition()) {
chan.audPos=s->getLoopStartPosition();
} else if (chan.audPos>=(unsigned int)s->getEndPosition()) {
chan.sample=-1;
if (chan.audDir) {
if (s->isLoopable()) {
switch (s->loopMode) {
case DIV_SAMPLE_LOOP_FORWARD:
case DIV_SAMPLE_LOOP_PINGPONG:
if (chan.audPos<s->getLoopStartPosition()) {
chan.audPos=s->getLoopStartPosition()+(s->getLoopStartPosition()-chan.audPos);
chan.audDir=false;
}
break;
case DIV_SAMPLE_LOOP_BACKWARD:
if (chan.audPos<s->getLoopStartPosition()) {
chan.audPos=s->getLoopEndPosition()-1-(s->getLoopStartPosition()-chan.audPos);
chan.audDir=true;
}
default:
if (chan.audPos<0) {
chan.sample=-1;
}
break;
}
} else if (chan.audPos>=s->getEndPosition()) {
chan.sample=-1;
}
} else {
if (s->isLoopable()) {
switch (s->loopMode) {
case DIV_SAMPLE_LOOP_FORWARD:
if (chan.audPos>=s->getLoopEndPosition()) {
chan.audPos=(chan.audPos+s->getLoopStartPosition())-s->getLoopEndPosition();
chan.audDir=false;
}
break;
case DIV_SAMPLE_LOOP_BACKWARD:
case DIV_SAMPLE_LOOP_PINGPONG:
if (chan.audPos>=s->getLoopEndPosition()) {
chan.audPos=s->getLoopEndPosition()-1-(s->getLoopEndPosition()-1-chan.audPos);
chan.audDir=true;
}
default:
if (chan.audPos>=s->getEndPosition()) {
chan.sample=-1;
}
break;
}
} else if (chan.audPos>=s->getEndPosition()) {
chan.sample=-1;
}
}
if (chan.audPos<(unsigned int)s->getEndPosition()) {
if (chan.audPos>=0 && chan.audPos<s->getEndPosition()) {
output=s->data16[chan.audPos];
}
} else {
@ -125,6 +170,7 @@ void DivPlatformPCMDAC::tick(bool sysTick) {
}
if (chan.std.phaseReset.had) {
if (chan.std.phaseReset.val==1) {
chan.audDir=false;
chan.audPos=0;
}
}
@ -156,11 +202,11 @@ int DivPlatformPCMDAC::dispatch(DivCommand c) {
DivInstrument* ins=parent->getIns(chan.ins,DIV_INS_AMIGA);
if (ins->amiga.useWave) {
chan.useWave=true;
chan.audLen=(ins->amiga.waveLen+1)>>1;
chan.audLen=ins->amiga.waveLen;
if (chan.insChanged) {
if (chan.wave<0) {
chan.wave=0;
chan.ws.setWidth(chan.audLen<<1);
chan.ws.setWidth(chan.audLen);
chan.ws.changeWave1(chan.wave);
}
}
@ -177,6 +223,7 @@ int DivPlatformPCMDAC::dispatch(DivCommand c) {
if (chan.setPos) {
chan.setPos=false;
} else {
chan.audDir=false;
chan.audPos=0;
}
chan.audSub=0;
@ -191,7 +238,7 @@ int DivPlatformPCMDAC::dispatch(DivCommand c) {
chan.envVol=64;
}
if (chan.useWave) {
chan.ws.init(ins,chan.audLen<<1,255,chan.insChanged);
chan.ws.init(ins,chan.audLen,255,chan.insChanged);
}
chan.insChanged=false;
break;
@ -298,6 +345,7 @@ void DivPlatformPCMDAC::muteChannel(int ch, bool mute) {
void DivPlatformPCMDAC::forceIns() {
chan.insChanged=true;
chan.freqChanged=true;
chan.audDir=false;
chan.audPos=0;
chan.sample=-1;
}