GUI: make playing needles in sample editor work

currently only for YM2612 but I will implement more soon
This commit is contained in:
tildearrow 2023-03-19 03:12:08 -05:00
parent 2e9bc14459
commit f80a2b8864
7 changed files with 87 additions and 1 deletions

View file

@ -293,6 +293,18 @@ struct DivDelayedWrite {
write(a,v) {}
};
struct DivSamplePos {
int sample, pos, freq;
DivSamplePos(int s, int p, int f):
sample(s),
pos(p),
freq(f) {}
DivSamplePos():
sample(-1),
pos(0),
freq(0) {}
};
struct DivDispatchOscBuffer {
bool follow;
unsigned int rate;
@ -371,18 +383,29 @@ class DivDispatch {
/**
* get the state of a channel.
* @param chan the channel.
* @return a pointer, or NULL.
*/
virtual void* getChanState(int chan);
/**
* get the DivMacroInt of a chanmel.
* get the DivMacroInt of a channel.
* @param chan the channel.
* @return a pointer, or NULL.
*/
virtual DivMacroInt* getChanMacroInt(int chan);
/**
* get currently playing sample (and its position).
* @param chan the channel.
* @return a DivSamplePos. if sample is -1 then nothing is playing or the
* channel doesn't play samples.
*/
virtual DivSamplePos getSamplePos(int chan);
/**
* get an oscilloscope buffer for a channel.
* @param chan the channel.
* @return a pointer to a DivDispatchOscBuffer, or NULL if not supported.
*/
virtual DivDispatchOscBuffer* getOscBuffer(int chan);

View file

@ -2119,6 +2119,11 @@ DivMacroInt* DivEngine::getMacroInt(int chan) {
return disCont[dispatchOfChan[chan]].dispatch->getChanMacroInt(dispatchChanOfChan[chan]);
}
DivSamplePos DivEngine::getSamplePos(int chan) {
if (chan<0 || chan>=chans) return DivSamplePos();
return disCont[dispatchOfChan[chan]].dispatch->getSamplePos(dispatchChanOfChan[chan]);
}
DivDispatchOscBuffer* DivEngine::getOscBuffer(int chan) {
if (chan<0 || chan>=chans) return NULL;
return disCont[dispatchOfChan[chan]].dispatch->getOscBuffer(dispatchChanOfChan[chan]);

View file

@ -914,6 +914,9 @@ class DivEngine {
// get macro interpreter
DivMacroInt* getMacroInt(int chan);
// get sample position
DivSamplePos getSamplePos(int chan);
// get osc buffer
DivDispatchOscBuffer* getOscBuffer(int chan);

View file

@ -37,6 +37,10 @@ DivMacroInt* DivDispatch::getChanMacroInt(int chan) {
return NULL;
}
DivSamplePos DivDispatch::getSamplePos(int chan) {
return DivSamplePos();
}
DivDispatchOscBuffer* DivDispatch::getOscBuffer(int chan) {
return NULL;
}

View file

@ -1209,6 +1209,16 @@ DivMacroInt* DivPlatformGenesis::getChanMacroInt(int ch) {
return &chan[ch].std;
}
DivSamplePos DivPlatformGenesis::getSamplePos(int ch) {
if (ch<5) return DivSamplePos();
if (ch>5 && !softPCM) return DivSamplePos();
return DivSamplePos(
chan[ch].dacSample,
chan[ch].dacPos,
chan[ch].dacRate
);
}
DivDispatchOscBuffer* DivPlatformGenesis::getOscBuffer(int ch) {
return oscBuf[ch];
}

View file

@ -105,6 +105,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
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();