implement getSamplePos() on some chips

Amiga, AY, Lynx, PCE, PCM DAC and VRC6
This commit is contained in:
tildearrow 2023-03-19 03:56:13 -05:00
parent f80a2b8864
commit 6cd24a8008
15 changed files with 75 additions and 0 deletions

View File

@ -765,6 +765,16 @@ DivMacroInt* DivPlatformAmiga::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformAmiga::getSamplePos(int ch) {
if (ch>=4) return DivSamplePos();
if (chan[ch].sample<0 || chan[ch].sample>=parent->song.sampleLen) return DivSamplePos();
return DivSamplePos(
chan[ch].sample,
amiga.dmaLoc[ch]-sampleOff[chan[ch].sample],
chipClock/amiga.audPer[ch]
);
}
void DivPlatformAmiga::notifyInsChange(int ins) {
for (int i=0; i<4; i++) {
if (chan[i].ins==ins) {

View File

@ -137,6 +137,7 @@ class DivPlatformAmiga: public DivDispatch {
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
void setFlags(const DivConfig& flags);
void notifyInsChange(int ins);
void notifyWaveChange(int wave);

View File

@ -700,6 +700,15 @@ DivMacroInt* DivPlatformAY8910::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformAY8910::getSamplePos(int ch) {
if (ch>=3) return DivSamplePos();
return DivSamplePos(
chan[ch].dac.sample,
chan[ch].dac.pos,
chan[ch].dac.rate
);
}
DivDispatchOscBuffer* DivPlatformAY8910::getOscBuffer(int ch) {
return oscBuf[ch];
}

View File

@ -143,6 +143,7 @@ class DivPlatformAY8910: public DivDispatch {
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
bool getDCOffRequired();
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);

View File

@ -696,6 +696,15 @@ DivMacroInt* DivPlatformAY8930::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformAY8930::getSamplePos(int ch) {
if (ch>=3) return DivSamplePos();
return DivSamplePos(
chan[ch].dac.sample,
chan[ch].dac.pos,
chan[ch].dac.rate
);
}
DivDispatchOscBuffer* DivPlatformAY8930::getOscBuffer(int ch) {
return oscBuf[ch];
}

View File

@ -145,6 +145,7 @@ class DivPlatformAY8930: public DivDispatch {
int getOutputCount();
bool keyOffAffectsArp(int ch);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist);

View File

@ -1210,6 +1210,7 @@ DivMacroInt* DivPlatformGenesis::getChanMacroInt(int ch) {
}
DivSamplePos DivPlatformGenesis::getSamplePos(int ch) {
if (!chan[5].dacMode) return DivSamplePos();
if (ch<5) return DivSamplePos();
if (ch>5 && !softPCM) return DivSamplePos();
return DivSamplePos(

View File

@ -415,6 +415,16 @@ DivMacroInt* DivPlatformLynx::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformLynx::getSamplePos(int ch) {
if (ch>=4) return DivSamplePos();
if (!chan[ch].pcm) return DivSamplePos();
return DivSamplePos(
chan[ch].sample,
chan[ch].samplePos,
chan[ch].sampleFreq
);
}
DivDispatchOscBuffer* DivPlatformLynx::getOscBuffer(int ch) {
return oscBuf[ch];
}

View File

@ -72,6 +72,7 @@ class DivPlatformLynx: public DivDispatch {
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();

View File

@ -505,6 +505,16 @@ DivMacroInt* DivPlatformPCE::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformPCE::getSamplePos(int ch) {
if (ch>=6) return DivSamplePos();
if (!chan[ch].pcm) return DivSamplePos();
return DivSamplePos(
chan[ch].dacSample,
chan[ch].dacPos,
chan[ch].dacRate
);
}
DivDispatchOscBuffer* DivPlatformPCE::getOscBuffer(int ch) {
return oscBuf[ch];
}

View File

@ -81,6 +81,7 @@ class DivPlatformPCE: public DivDispatch {
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();

View File

@ -441,6 +441,15 @@ DivMacroInt* DivPlatformPCMDAC::getChanMacroInt(int ch) {
return &chan[0].std;
}
DivSamplePos DivPlatformPCMDAC::getSamplePos(int ch) {
if (ch>=1) return DivSamplePos();
return DivSamplePos(
chan[ch].sample,
chan[ch].audPos,
chan[ch].freq
);
}
void DivPlatformPCMDAC::notifyInsChange(int ins) {
if (chan[0].ins==ins) {
chan[0].insChanged=true;

View File

@ -79,6 +79,7 @@ class DivPlatformPCMDAC: public DivDispatch {
void muteChannel(int ch, bool mute);
int getOutputCount();
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
void setFlags(const DivConfig& flags);
void notifyInsChange(int ins);
void notifyWaveChange(int wave);

View File

@ -448,6 +448,16 @@ DivMacroInt* DivPlatformVRC6::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformVRC6::getSamplePos(int ch) {
if (ch>=2) return DivSamplePos();
if (!chan[ch].pcm) return DivSamplePos();
return DivSamplePos(
chan[ch].dacSample,
chan[ch].dacPos,
chan[ch].dacRate
);
}
DivDispatchOscBuffer* DivPlatformVRC6::getOscBuffer(int ch) {
return oscBuf[ch];
}

View File

@ -65,6 +65,7 @@ class DivPlatformVRC6: public DivDispatch, public vrcvi_intf {
int dispatch(DivCommand c);
void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch);
DivSamplePos getSamplePos(int ch);
DivDispatchOscBuffer* getOscBuffer(int chan);
unsigned char* getRegisterPool();
int getRegisterPoolSize();