SNES: implement getSamplePos()

but gotta fix one thing
This commit is contained in:
tildearrow 2023-03-19 04:18:57 -05:00
parent 6cd24a8008
commit 62b9b98300
3 changed files with 22 additions and 0 deletions

View File

@ -681,6 +681,20 @@ DivMacroInt* DivPlatformSNES::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformSNES::getSamplePos(int ch) {
if (ch>=8) return DivSamplePos();
if (!chan[ch].active) return DivSamplePos();
if (chan[ch].sample<0 || chan[ch].sample>=parent->song.sampleLen) return DivSamplePos();
const SPC_DSP::voice_t* v=dsp.get_voice(ch);
// TODO: fix?
if (sampleMem[v->brr_addr&0xffff]==0) return DivSamplePos();
return DivSamplePos(
chan[ch].sample,
((v->brr_addr-sampleOff[chan[ch].sample])*16/9)+v->brr_offset,
(chan[ch].freq*125)/16
);
}
DivDispatchOscBuffer* DivPlatformSNES::getOscBuffer(int ch) {
return oscBuf[ch];
}

View File

@ -97,6 +97,7 @@ class DivPlatformSNES: 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

@ -123,6 +123,9 @@ public:
uint8_t t_envx_out;
sample_t out[2]; // Furnace addition, for per-channel oscilloscope
};
// Furnace addition, gets a voice
const voice_t* get_voice(int n);
private:
enum { brr_block_size = 9 };
@ -298,6 +301,10 @@ inline void SPC_DSP::get_voice_outputs( sample_t* outs )
}
}
inline const SPC_DSP::voice_t* SPC_DSP::get_voice(int n) {
return &m.voices[n];
}
#if !SPC_NO_COPY_STATE_FUNCS
class SPC_State_Copier {