GUI: prepare for drawing prev/next pat content

This commit is contained in:
tildearrow 2022-02-16 16:11:15 -05:00
parent b0996371b7
commit 810ee33d11
5 changed files with 117 additions and 8 deletions

View file

@ -4851,6 +4851,20 @@ void* DivEngine::getDispatchChanState(int ch) {
return disCont[dispatchOfChan[ch]].dispatch->getChanState(dispatchChanOfChan[ch]);
}
void DivEngine::enableCommandStream(bool enable) {
cmdStreamEnabled=enable;
}
void DivEngine::getCommandStream(std::vector<DivCommand>& where) {
isBusy.lock();
where.clear();
for (DivCommand& i: cmdStream) {
where.push_back(i);
}
cmdStream.clear();
isBusy.unlock();
}
void DivEngine::playSub(bool preserveDrift, int goalRow) {
reset();
if (preserveDrift && curOrder==0) return;
@ -4900,6 +4914,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
if (!preserveDrift) {
ticks=1;
}
cmdStream.clear();
}
int DivEngine::calcBaseFreq(double clock, double divider, int note, bool period) {

View file

@ -170,6 +170,7 @@ class DivEngine {
bool exporting;
bool halted;
bool forceMono;
bool cmdStreamEnabled;
int ticks, curRow, curOrder, remainingLoops, nextSpeed, divider;
int cycles, clockDrift, stepPlay;
int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
@ -189,6 +190,7 @@ class DivEngine {
String lastError;
String warnings;
std::vector<String> audioDevs;
std::vector<DivCommand> cmdStream;
struct SamplePreview {
int sample;
@ -519,6 +521,12 @@ class DivEngine {
// get dispatch channel state
void* getDispatchChanState(int chan);
// enable command stream dumping
void enableCommandStream(bool enable);
// get command stream
void getCommandStream(std::vector<DivCommand>& where);
// set the audio system.
void setAudio(DivAudioEngines which);
@ -622,6 +630,7 @@ class DivEngine {
exporting(false),
halted(false),
forceMono(false),
cmdStreamEnabled(false),
ticks(0),
curRow(0),
curOrder(0),

View file

@ -132,6 +132,9 @@ int DivEngine::dispatchCmd(DivCommand c) {
printf("%8d | %d: %s(%d, %d)\n",totalTicksR,c.chan,cmdName[c.cmd],c.value,c.value2);
}
totalCmds++;
if (cmdStreamEnabled && cmdStream.size()<2000) {
cmdStream.push_back(c);
}
c.chan=dispatchChanOfChan[c.dis];
return disCont[dispatchOfChan[c.dis]].dispatch->dispatch(c);
}