GUI: make playing needles in sample editor work
currently only for YM2612 but I will implement more soon
This commit is contained in:
parent
2e9bc14459
commit
f80a2b8864
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1407,6 +1407,46 @@ void FurnaceGUI::drawSampleEdit() {
|
|||
dl->AddLine(p1,p2,ImGui::GetColorU32(posColor));
|
||||
}
|
||||
|
||||
if (e->isRunning()) {
|
||||
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
||||
DivSamplePos chanPos=e->getSamplePos(i);
|
||||
if (chanPos.sample!=curSample) continue;
|
||||
|
||||
int start=sampleSelStart;
|
||||
int end=sampleSelEnd;
|
||||
if (start>end) {
|
||||
start^=end;
|
||||
end^=start;
|
||||
start^=end;
|
||||
}
|
||||
ImDrawList* dl=ImGui::GetWindowDrawList();
|
||||
ImVec2 p1=rectMin;
|
||||
p1.x+=(chanPos.pos-samplePos)/sampleZoom;
|
||||
ImVec4 posColor=uiColors[GUI_COLOR_SAMPLE_NEEDLE_PLAYING];
|
||||
ImVec4 posTrail1=posColor;
|
||||
ImVec4 posTrail2=posColor;
|
||||
posTrail1.w*=0.5f;
|
||||
posTrail2.w=0.0f;
|
||||
float trailDistance=((float)chanPos.freq/100.0f)/sampleZoom;
|
||||
|
||||
if (p1.x<rectMin.x) p1.x=rectMin.x;
|
||||
if (p1.x>rectMax.x) p1.x=rectMax.x;
|
||||
|
||||
ImVec2 p2=p1;
|
||||
p2.y=rectMax.y;
|
||||
|
||||
dl->AddRectFilledMultiColor(
|
||||
ImVec2(p1.x-trailDistance,p1.y),
|
||||
p2,
|
||||
ImGui::GetColorU32(posTrail2),
|
||||
ImGui::GetColorU32(posTrail1),
|
||||
ImGui::GetColorU32(posTrail1),
|
||||
ImGui::GetColorU32(posTrail2)
|
||||
);
|
||||
dl->AddLine(p1,p2,ImGui::GetColorU32(posColor));
|
||||
}
|
||||
}
|
||||
|
||||
if (drawSelection) {
|
||||
int start=sampleSelStart;
|
||||
int end=sampleSelEnd;
|
||||
|
|
Loading…
Reference in New Issue