new demo song

by ALTMUS
This commit is contained in:
tildearrow 2025-03-29 22:26:00 -05:00
parent bb2b2e1cc6
commit 13b56870ec
16 changed files with 802 additions and 74 deletions

View file

@ -42,6 +42,8 @@
#include <fmt/printf.h>
#include <chrono>
int curEngineState=-1;
void process(void* u, float** in, float** out, int inChans, int outChans, unsigned int size) {
((DivEngine*)u)->nextBuf(in,out,inChans,outChans,size);
}
@ -4018,6 +4020,31 @@ bool DivEngine::prePreInit() {
logD("config path: %s",configPath.c_str());
configLoaded=true;
curEngineState=-1;
time_t thisMakesNoSense=time(NULL);
struct tm curTime;
#ifdef _WIN32
struct tm* tempTM=localtime(&thisMakesNoSense);
if (tempTM!=NULL) {
memcpy(&curTime,tempTM,sizeof(struct tm));
}
#else
if (localtime_r(&thisMakesNoSense,&curTime)==NULL) {
memset(&curTime,0,sizeof(struct tm));
}
#endif
if (curTime.tm_year==125) {
if (curTime.tm_mon==2 && curTime.tm_mday==31 && curTime.tm_hour>=23) {
curEngineState=curTime.tm_hour;
} else if (curTime.tm_mon==3 && curTime.tm_mday==1) {
curEngineState=curTime.tm_hour;
} else if (curTime.tm_mon==3 && curTime.tm_mday==2 && curTime.tm_hour<6) {
curEngineState=curTime.tm_hour;
} else {
curEngineState=-1;
}
}
return loadConf();
}

View file

@ -432,6 +432,7 @@ enum DivChanTypes {
};
extern const char* cmdName[];
extern int curEngineState;
class DivEngine {
DivDispatchContainer disCont[DIV_MAX_CHIPS];
@ -447,6 +448,7 @@ class DivEngine {
bool playing;
bool freelance;
bool shallStop, shallStopSched;
bool reverse;
bool endOfSong;
bool consoleMode;
bool disableStatusOut;
@ -1400,6 +1402,7 @@ class DivEngine {
freelance(false),
shallStop(false),
shallStopSched(false),
reverse(false),
endOfSong(false),
consoleMode(false),
disableStatusOut(false),

View file

@ -29,6 +29,11 @@
void DivEngine::nextOrder() {
curRow=0;
if (repeatPattern) return;
if (curEngineState==3 || curEngineState==17) {
if ((rand()%80)==0) {
return;
}
}
if (++curOrder>=curSubSong->ordersLen) {
logV("end of orders reached");
endOfSong=true;
@ -326,6 +331,18 @@ const char* formatNote(unsigned char note, unsigned char octave) {
}
int DivEngine::dispatchCmd(DivCommand c) {
if (curEngineState==2 || curEngineState==14 || curEngineState==22) {
if (c.cmd==DIV_CMD_NOTE_ON) {
if ((rand()&255)==0) {
c.value++;
}
}
if (c.cmd==DIV_CMD_NOTE_OFF) {
if ((rand()&127)==0) {
return 0;
}
}
}
if (view==DIV_STATUS_COMMANDS) {
if (!skipping) {
switch (c.cmd) {
@ -1424,13 +1441,26 @@ void DivEngine::nextRow() {
changeOrd=-1;
}
if (haltOn==DIV_HALT_PATTERN) halted=true;
} else if (playing) if (++curRow>=curSubSong->patLen) {
if (shallStopSched) {
curRow=curSubSong->patLen-1;
} else if (playing) {
if (reverse) {
if (--curRow<1) reverse=false;
} else {
nextOrder();
curRow++;
}
if (curRow>=curSubSong->patLen) {
if (shallStopSched) {
curRow=curSubSong->patLen-1;
} else {
nextOrder();
}
if (haltOn==DIV_HALT_PATTERN) halted=true;
}
if ((curEngineState==4 || curEngineState==21) && (curRow&3)==0 && !skipping) {
if ((rand()%600)==0) {
reverse=true;
}
}
if (haltOn==DIV_HALT_PATTERN) halted=true;
}
// new loop detection routine
@ -1459,6 +1489,17 @@ void DivEngine::nextRow() {
nextSpeed=speeds.val[curSpeed];
}
if (curEngineState==3 || curEngineState==17) {
if ((rand()%300)==0) {
ticks++;
nextSpeed++;
}
if ((rand()%15000)==0) {
ticks=128;
nextSpeed+=128;
}
}
/*
if (skipping) {
ticks=1;