add command line option to see song summary

This commit is contained in:
tildearrow 2023-10-17 14:11:35 -05:00
parent 94213d7cda
commit 06ba12b270
3 changed files with 85 additions and 4 deletions

View file

@ -2307,6 +2307,65 @@ void DivEngine::unmuteAll() {
BUSY_END;
}
void DivEngine::dumpSongInfo() {
printf(
"SONG INFORMATION\n"
"- name: %s\n"
"- author: %s\n"
"- album: %s\n"
"- system: %s\n"
"- %d ins, %d waves, %d samples\n"
"<<<\n%s\n>>>\n\n",
song.name.c_str(),
song.author.c_str(),
song.category.c_str(),
song.systemName.c_str(),
song.insLen,
song.waveLen,
song.sampleLen,
song.notes.c_str()
);
printf("SUB-SONGS\n");
int index=0;
for (DivSubSong* i: song.subsong) {
printf(
"=== %d: %s\n"
"<<<\n%s\n>>>\n",
index,
i->name.c_str(),
i->notes.c_str()
);
index++;
}
if (!song.ins.empty()) {
printf("\nINSTRUMENTS\n");
index=0;
for (DivInstrument* i: song.ins) {
printf(
"- %d: %s\n",
index,
i->name.c_str()
);
index++;
}
}
if (!song.sample.empty()) {
printf("\nSAMPLES\n");
index=0;
for (DivSample* i: song.sample) {
printf(
"- %d: %s\n",
index,
i->name.c_str()
);
index++;
}
}
}
int DivEngine::addInstrument(int refChan, DivInstrumentType fallbackType) {
if (song.ins.size()>=256) return -1;
BUSY_BEGIN;

View file

@ -881,6 +881,9 @@ class DivEngine {
// get ext value
unsigned char getExtValue();
// dump song info to stdout
void dumpSongInfo();
// is playing
bool isPlaying();

View file

@ -78,6 +78,8 @@ bool vgmOutDirect=false;
bool safeMode=false;
bool safeModeWithAudio=false;
bool infoMode=false;
std::vector<TAParam> params;
TAParamResult pHelp(String) {
@ -161,6 +163,11 @@ TAParamResult pDirect(String val) {
return TA_PARAM_SUCCESS;
}
TAParamResult pInfo(String val) {
infoMode=true;
return TA_PARAM_SUCCESS;
}
TAParamResult pLogLevel(String val) {
if (val=="trace") {
logLevel=LOGLEVEL_TRACE;
@ -364,6 +371,7 @@ void initParams() {
params.push_back(TAParam("b","binary",false,pBinary,"","set command stream output format to binary"));
params.push_back(TAParam("L","loglevel",true,pLogLevel,"debug|info|warning|error","set the log level (info by default)"));
params.push_back(TAParam("v","view",true,pView,"pattern|commands|nothing","set visualization (pattern by default)"));
params.push_back(TAParam("i","info",false,pInfo,"","get info about a song"));
params.push_back(TAParam("c","console",false,pConsole,"","enable console mode"));
params.push_back(TAParam("l","loops",true,pLoops,"<count>","set number of loops (-1 means loop forever)"));
@ -525,9 +533,14 @@ int main(int argc, char** argv) {
return 1;
}
if (fileName.empty() && (benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logE("provide a file!");
return 1;
}
#ifdef HAVE_GUI
if (e.preInit(false)) {
if (consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="") {
if (e.preInit(consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
if (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="") {
logW("engine wants safe mode, but Furnace GUI is not going to start.");
} else {
safeMode=true;
@ -539,7 +552,7 @@ int main(int argc, char** argv) {
}
#endif
if (safeMode && (consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
if (safeMode && (consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logE("you can't use safe mode and console/export mode together.");
return 0;
}
@ -548,7 +561,7 @@ int main(int argc, char** argv) {
e.setAudio(DIV_AUDIO_DUMMY);
}
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",false)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
if (!fileName.empty() && ((!e.getConfBool("tutIntroPlayed",false)) || e.getConfInt("alwaysPlayIntro",0)!=3 || consoleMode || benchMode || infoMode || outName!="" || vgmOutName!="" || cmdOutName!="")) {
logI("loading module...");
FILE* f=ps_fopen(fileName.c_str(),"rb");
if (f==NULL) {
@ -601,6 +614,12 @@ int main(int argc, char** argv) {
return 1;
}
}
if (infoMode) {
e.dumpSongInfo();
finishLogFile();
return 0;
}
if (!e.init()) {
if (consoleMode) {
reportError("could not initialize engine!");