improve logging facility
we have a log viewer within the program now
This commit is contained in:
parent
4ae13c15e6
commit
fddd05dc1a
33 changed files with 556 additions and 386 deletions
|
|
@ -32,13 +32,13 @@ bool DivEngine::saveConf() {
|
|||
configFile=configPath+String(CONFIG_FILE);
|
||||
FILE* f=ps_fopen(configFile.c_str(),"wb");
|
||||
if (f==NULL) {
|
||||
logW("could not write config file! %s\n",strerror(errno));
|
||||
logW("could not write config file! %s",strerror(errno));
|
||||
return false;
|
||||
}
|
||||
for (auto& i: conf) {
|
||||
String toWrite=fmt::sprintf("%s=%s\n",i.first,i.second);
|
||||
if (fwrite(toWrite.c_str(),1,toWrite.size(),f)!=toWrite.size()) {
|
||||
logW("could not write config file! %s\n",strerror(errno));
|
||||
logW("could not write config file! %s",strerror(errno));
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -52,10 +52,10 @@ bool DivEngine::loadConf() {
|
|||
configFile=configPath+String(CONFIG_FILE);
|
||||
FILE* f=ps_fopen(configFile.c_str(),"rb");
|
||||
if (f==NULL) {
|
||||
logI("creating default config.\n");
|
||||
logI("creating default config.");
|
||||
return saveConf();
|
||||
}
|
||||
logI("loading config.\n");
|
||||
logI("loading config.");
|
||||
while (!feof(f)) {
|
||||
String key="";
|
||||
String value="";
|
||||
|
|
|
|||
|
|
@ -148,13 +148,13 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
|
|||
|
||||
bb[0]=blip_new(32768);
|
||||
if (bb[0]==NULL) {
|
||||
logE("not enough memory!\n");
|
||||
logE("not enough memory!");
|
||||
return;
|
||||
}
|
||||
|
||||
bb[1]=blip_new(32768);
|
||||
if (bb[1]==NULL) {
|
||||
logE("not enough memory!\n");
|
||||
logE("not enough memory!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
|
|||
dispatch=new DivPlatformMMC5;
|
||||
break;
|
||||
default:
|
||||
logW("this system is not supported yet! using dummy platform.\n");
|
||||
logW("this system is not supported yet! using dummy platform.");
|
||||
dispatch=new DivPlatformDummy;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ void DivEngine::runExportThread() {
|
|||
|
||||
sf=sf_open(exportPath.c_str(),SFM_WRITE,&si);
|
||||
if (sf==NULL) {
|
||||
logE("could not open file for writing! (%s)\n",sf_strerror(NULL));
|
||||
logE("could not open file for writing! (%s)",sf_strerror(NULL));
|
||||
exporting=false;
|
||||
return;
|
||||
}
|
||||
|
|
@ -207,7 +207,7 @@ void DivEngine::runExportThread() {
|
|||
deinitAudioBackend();
|
||||
playSub(false);
|
||||
|
||||
logI("rendering to file...\n");
|
||||
logI("rendering to file...");
|
||||
|
||||
while (playing) {
|
||||
nextBuf(NULL,outBuf,0,2,EXPORT_BUFSIZE);
|
||||
|
|
@ -216,10 +216,10 @@ void DivEngine::runExportThread() {
|
|||
outBuf[2][1+(i<<1)]=MAX(-1.0f,MIN(1.0f,outBuf[1][i]));
|
||||
}
|
||||
if (totalProcessed>EXPORT_BUFSIZE) {
|
||||
logE("error: total processed is bigger than export bufsize! %d>%d\n",totalProcessed,EXPORT_BUFSIZE);
|
||||
logE("error: total processed is bigger than export bufsize! %d>%d",totalProcessed,EXPORT_BUFSIZE);
|
||||
}
|
||||
if (sf_writef_float(sf,outBuf[2],totalProcessed)!=(int)totalProcessed) {
|
||||
logE("error: failed to write entire buffer!\n");
|
||||
logE("error: failed to write entire buffer!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -229,7 +229,7 @@ void DivEngine::runExportThread() {
|
|||
delete[] outBuf[2];
|
||||
|
||||
if (sf_close(sf)!=0) {
|
||||
logE("could not close audio file!\n");
|
||||
logE("could not close audio file!");
|
||||
}
|
||||
exporting=false;
|
||||
|
||||
|
|
@ -239,10 +239,10 @@ void DivEngine::runExportThread() {
|
|||
disCont[i].setQuality(lowQuality);
|
||||
}
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating audio!\n");
|
||||
logE("error while activating audio!");
|
||||
}
|
||||
}
|
||||
logI("done!\n");
|
||||
logI("done!");
|
||||
break;
|
||||
}
|
||||
case DIV_EXPORT_MODE_MANY_SYS: {
|
||||
|
|
@ -262,10 +262,10 @@ void DivEngine::runExportThread() {
|
|||
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
fname[i]=fmt::sprintf("%s_s%02d.wav",exportPath,i+1);
|
||||
logI("- %s\n",fname[i].c_str());
|
||||
logI("- %s",fname[i].c_str());
|
||||
sf[i]=sf_open(fname[i].c_str(),SFM_WRITE,&si[i]);
|
||||
if (sf[i]==NULL) {
|
||||
logE("could not open file for writing! (%s)\n",sf_strerror(NULL));
|
||||
logE("could not open file for writing! (%s)",sf_strerror(NULL));
|
||||
for (int j=0; j<i; j++) {
|
||||
sf_close(sf[i]);
|
||||
}
|
||||
|
|
@ -282,7 +282,7 @@ void DivEngine::runExportThread() {
|
|||
deinitAudioBackend();
|
||||
playSub(false);
|
||||
|
||||
logI("rendering to files...\n");
|
||||
logI("rendering to files...");
|
||||
|
||||
while (playing) {
|
||||
nextBuf(NULL,outBuf,0,2,EXPORT_BUFSIZE);
|
||||
|
|
@ -296,10 +296,10 @@ void DivEngine::runExportThread() {
|
|||
}
|
||||
}
|
||||
if (totalProcessed>EXPORT_BUFSIZE) {
|
||||
logE("error: total processed is bigger than export bufsize! (%d) %d>%d\n",i,totalProcessed,EXPORT_BUFSIZE);
|
||||
logE("error: total processed is bigger than export bufsize! (%d) %d>%d",i,totalProcessed,EXPORT_BUFSIZE);
|
||||
}
|
||||
if (sf_writef_short(sf[i],sysBuf,totalProcessed)!=(int)totalProcessed) {
|
||||
logE("error: failed to write entire buffer! (%d)\n",i);
|
||||
logE("error: failed to write entire buffer! (%d)",i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -311,7 +311,7 @@ void DivEngine::runExportThread() {
|
|||
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
if (sf_close(sf[i])!=0) {
|
||||
logE("could not close audio file!\n");
|
||||
logE("could not close audio file!");
|
||||
}
|
||||
}
|
||||
exporting=false;
|
||||
|
|
@ -322,10 +322,10 @@ void DivEngine::runExportThread() {
|
|||
disCont[i].setQuality(lowQuality);
|
||||
}
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating audio!\n");
|
||||
logE("error while activating audio!");
|
||||
}
|
||||
}
|
||||
logI("done!\n");
|
||||
logI("done!");
|
||||
break;
|
||||
}
|
||||
case DIV_EXPORT_MODE_MANY_CHAN: {
|
||||
|
|
@ -338,20 +338,20 @@ void DivEngine::runExportThread() {
|
|||
outBuf[2]=new float[EXPORT_BUFSIZE*2];
|
||||
int loopCount=remainingLoops;
|
||||
|
||||
logI("rendering to files...\n");
|
||||
logI("rendering to files...");
|
||||
|
||||
for (int i=0; i<chans; i++) {
|
||||
SNDFILE* sf;
|
||||
SF_INFO si;
|
||||
String fname=fmt::sprintf("%s_c%02d.wav",exportPath,i+1);
|
||||
logI("- %s\n",fname.c_str());
|
||||
logI("- %s",fname.c_str());
|
||||
si.samplerate=got.rate;
|
||||
si.channels=2;
|
||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||
|
||||
sf=sf_open(fname.c_str(),SFM_WRITE,&si);
|
||||
if (sf==NULL) {
|
||||
logE("could not open file for writing! (%s)\n",sf_strerror(NULL));
|
||||
logE("could not open file for writing! (%s)",sf_strerror(NULL));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -374,16 +374,16 @@ void DivEngine::runExportThread() {
|
|||
outBuf[2][1+(j<<1)]=MAX(-1.0f,MIN(1.0f,outBuf[1][j]));
|
||||
}
|
||||
if (totalProcessed>EXPORT_BUFSIZE) {
|
||||
logE("error: total processed is bigger than export bufsize! %d>%d\n",totalProcessed,EXPORT_BUFSIZE);
|
||||
logE("error: total processed is bigger than export bufsize! %d>%d",totalProcessed,EXPORT_BUFSIZE);
|
||||
}
|
||||
if (sf_writef_float(sf,outBuf[2],totalProcessed)!=(int)totalProcessed) {
|
||||
logE("error: failed to write entire buffer!\n");
|
||||
logE("error: failed to write entire buffer!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sf_close(sf)!=0) {
|
||||
logE("could not close audio file!\n");
|
||||
logE("could not close audio file!");
|
||||
}
|
||||
}
|
||||
exporting=false;
|
||||
|
|
@ -405,10 +405,10 @@ void DivEngine::runExportThread() {
|
|||
disCont[i].setQuality(lowQuality);
|
||||
}
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating audio!\n");
|
||||
logE("error while activating audio!");
|
||||
}
|
||||
}
|
||||
logI("done!\n");
|
||||
logI("done!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -479,12 +479,12 @@ void DivEngine::renderSamples() {
|
|||
memPos=(memPos+0xfffff)&0xf00000;
|
||||
}
|
||||
if (memPos>=16777216) {
|
||||
logW("out of ADPCM-A memory for sample %d!\n",i);
|
||||
logW("out of ADPCM-A memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+paddedLen>=16777216) {
|
||||
memcpy(adpcmAMem+memPos,s->dataA,16777216-memPos);
|
||||
logW("out of ADPCM-A memory for sample %d!\n",i);
|
||||
logW("out of ADPCM-A memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(adpcmAMem+memPos,s->dataA,paddedLen);
|
||||
}
|
||||
|
|
@ -504,12 +504,12 @@ void DivEngine::renderSamples() {
|
|||
memPos=(memPos+0xfffff)&0xf00000;
|
||||
}
|
||||
if (memPos>=16777216) {
|
||||
logW("out of ADPCM-B memory for sample %d!\n",i);
|
||||
logW("out of ADPCM-B memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+paddedLen>=16777216) {
|
||||
memcpy(adpcmBMem+memPos,s->dataB,16777216-memPos);
|
||||
logW("out of ADPCM-B memory for sample %d!\n",i);
|
||||
logW("out of ADPCM-B memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(adpcmBMem+memPos,s->dataB,paddedLen);
|
||||
}
|
||||
|
|
@ -533,14 +533,14 @@ void DivEngine::renderSamples() {
|
|||
memPos=(memPos+0xffff)&0xff0000;
|
||||
}
|
||||
if (memPos>=16777216) {
|
||||
logW("out of QSound PCM memory for sample %d!\n",i);
|
||||
logW("out of QSound PCM memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+length>=16777216) {
|
||||
for (unsigned int i=0; i<16777216-(memPos+length); i++) {
|
||||
qsoundMem[(memPos+i)^0x8000]=s->data8[i];
|
||||
}
|
||||
logW("out of QSound PCM memory for sample %d!\n",i);
|
||||
logW("out of QSound PCM memory for sample %d!",i);
|
||||
} else {
|
||||
for (int i=0; i<length; i++) {
|
||||
qsoundMem[(memPos+i)^0x8000]=s->data8[i];
|
||||
|
|
@ -567,12 +567,12 @@ void DivEngine::renderSamples() {
|
|||
memPos=(memPos+0x1ffff)&0xfe0000;
|
||||
}
|
||||
if (memPos>=1048576) {
|
||||
logW("out of X1-010 memory for sample %d!\n",i);
|
||||
logW("out of X1-010 memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+paddedLen>=1048576) {
|
||||
memcpy(x1_010Mem+memPos,s->data8,1048576-memPos);
|
||||
logW("out of X1-010 memory for sample %d!\n",i);
|
||||
logW("out of X1-010 memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(x1_010Mem+memPos,s->data8,paddedLen);
|
||||
}
|
||||
|
|
@ -824,7 +824,7 @@ void DivEngine::playSub(bool preserveDrift, int goalRow) {
|
|||
skipping=false;
|
||||
cmdStream.clear();
|
||||
std::chrono::high_resolution_clock::time_point timeEnd=std::chrono::high_resolution_clock::now();
|
||||
logV("playSub() tool %dµs\n",std::chrono::duration_cast<std::chrono::microseconds>(timeEnd-timeStart).count());
|
||||
logV("playSub() tool %dµs",std::chrono::duration_cast<std::chrono::microseconds>(timeEnd-timeStart).count());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -1346,7 +1346,7 @@ bool DivEngine::addWaveFromFile(const char* path) {
|
|||
}
|
||||
buf=new unsigned char[len];
|
||||
if (fread(buf,1,len,f)!=(size_t)len) {
|
||||
logW("did not read entire wavetable file buffer!\n");
|
||||
logW("did not read entire wavetable file buffer!");
|
||||
delete[] buf;
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1386,22 +1386,22 @@ bool DivEngine::addWaveFromFile(const char* path) {
|
|||
wave->max=(unsigned char)reader.readC();
|
||||
if (wave->max==255) { // new wavetable format
|
||||
unsigned char waveVersion=reader.readC();
|
||||
logI("reading modern .dmw...\n");
|
||||
logD("wave version %d\n",waveVersion);
|
||||
logI("reading modern .dmw...");
|
||||
logD("wave version %d",waveVersion);
|
||||
wave->max=reader.readC();
|
||||
for (int i=0; i<len; i++) {
|
||||
wave->data[i]=reader.readI();
|
||||
}
|
||||
} else if (reader.size()==(size_t)(len+5)) {
|
||||
// read as .dmw
|
||||
logI("reading .dmw...\n");
|
||||
logI("reading .dmw...");
|
||||
if (len>256) len=256;
|
||||
for (int i=0; i<len; i++) {
|
||||
wave->data[i]=(unsigned char)reader.readC();
|
||||
}
|
||||
} else {
|
||||
// read as binary
|
||||
logI("reading binary...\n");
|
||||
logI("reading binary...");
|
||||
len=reader.size();
|
||||
if (len>256) len=256;
|
||||
reader.seek(0,SEEK_SET);
|
||||
|
|
@ -1414,7 +1414,7 @@ bool DivEngine::addWaveFromFile(const char* path) {
|
|||
} catch (EndOfFileException& e) {
|
||||
// read as binary
|
||||
len=reader.size();
|
||||
logI("reading binary for being too small...\n");
|
||||
logI("reading binary for being too small...");
|
||||
if (len>256) len=256;
|
||||
reader.seek(0,SEEK_SET);
|
||||
for (int i=0; i<len; i++) {
|
||||
|
|
@ -1488,7 +1488,7 @@ int DivEngine::addSampleFromFile(const char* path) {
|
|||
}
|
||||
short* buf=new short[si.channels*si.frames];
|
||||
if (sf_readf_short(f,buf,si.frames)!=si.frames) {
|
||||
logW("sample read size mismatch!\n");
|
||||
logW("sample read size mismatch!");
|
||||
}
|
||||
DivSample* sample=new DivSample;
|
||||
int sampleCount=(int)song.sample.size();
|
||||
|
|
@ -1623,18 +1623,18 @@ void DivEngine::deepCloneOrder(bool where) {
|
|||
BUSY_BEGIN_SOFT;
|
||||
for (int i=0; i<chans; i++) {
|
||||
bool didNotFind=true;
|
||||
logD("channel %d\n",i);
|
||||
logD("channel %d",i);
|
||||
order[i]=song.orders.ord[i][curOrder];
|
||||
// find free slot
|
||||
for (int j=0; j<256; j++) {
|
||||
logD("finding free slot in %d...\n",j);
|
||||
logD("finding free slot in %d...",j);
|
||||
if (song.pat[i].data[j]==NULL) {
|
||||
int origOrd=order[i];
|
||||
order[i]=j;
|
||||
DivPattern* oldPat=song.pat[i].getPattern(origOrd,false);
|
||||
DivPattern* pat=song.pat[i].getPattern(j,true);
|
||||
memcpy(pat->data,oldPat->data,256*32*sizeof(short));
|
||||
logD("found at %d\n",j);
|
||||
logD("found at %d",j);
|
||||
didNotFind=false;
|
||||
break;
|
||||
}
|
||||
|
|
@ -1953,7 +1953,7 @@ bool DivEngine::switchMaster() {
|
|||
disCont[i].setQuality(lowQuality);
|
||||
}
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating audio!\n");
|
||||
logE("error while activating audio!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -2071,9 +2071,9 @@ void DivEngine::quitDispatch() {
|
|||
#define CHECK_CONFIG_DIR_MAC() \
|
||||
configPath+="/Library/Application Support/Furnace"; \
|
||||
if (stat(configPath.c_str(),&st)<0) { \
|
||||
logI("creating config dir...\n"); \
|
||||
logI("creating config dir..."); \
|
||||
if (mkdir(configPath.c_str(),0755)<0) { \
|
||||
logW("could not make config dir! (%s)\n",strerror(errno)); \
|
||||
logW("could not make config dir! (%s)",strerror(errno)); \
|
||||
configPath="."; \
|
||||
} \
|
||||
}
|
||||
|
|
@ -2081,18 +2081,18 @@ void DivEngine::quitDispatch() {
|
|||
#define CHECK_CONFIG_DIR() \
|
||||
configPath+="/.config"; \
|
||||
if (stat(configPath.c_str(),&st)<0) { \
|
||||
logI("creating user config dir...\n"); \
|
||||
logI("creating user config dir..."); \
|
||||
if (mkdir(configPath.c_str(),0755)<0) { \
|
||||
logW("could not make user config dir! (%s)\n",strerror(errno)); \
|
||||
logW("could not make user config dir! (%s)",strerror(errno)); \
|
||||
configPath="."; \
|
||||
} \
|
||||
} \
|
||||
if (configPath!=".") { \
|
||||
configPath+="/furnace"; \
|
||||
if (stat(configPath.c_str(),&st)<0) { \
|
||||
logI("creating config dir...\n"); \
|
||||
logI("creating config dir..."); \
|
||||
if (mkdir(configPath.c_str(),0755)<0) { \
|
||||
logW("could not make config dir! (%s)\n",strerror(errno)); \
|
||||
logW("could not make config dir! (%s)",strerror(errno)); \
|
||||
configPath="."; \
|
||||
} \
|
||||
} \
|
||||
|
|
@ -2114,7 +2114,7 @@ bool DivEngine::initAudioBackend() {
|
|||
switch (audioEngine) {
|
||||
case DIV_AUDIO_JACK:
|
||||
#ifndef HAVE_JACK
|
||||
logE("Furnace was not compiled with JACK support!\n");
|
||||
logE("Furnace was not compiled with JACK support!");
|
||||
setConf("audioEngine","SDL");
|
||||
saveConf();
|
||||
output=new TAAudioSDL;
|
||||
|
|
@ -2129,7 +2129,7 @@ bool DivEngine::initAudioBackend() {
|
|||
output=new TAAudio;
|
||||
break;
|
||||
default:
|
||||
logE("invalid audio engine!\n");
|
||||
logE("invalid audio engine!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2147,7 +2147,7 @@ bool DivEngine::initAudioBackend() {
|
|||
output->setCallback(process,this);
|
||||
|
||||
if (!output->init(want,got)) {
|
||||
logE("error while initializing audio!\n");
|
||||
logE("error while initializing audio!");
|
||||
delete output;
|
||||
output=NULL;
|
||||
audioEngine=DIV_AUDIO_NULL;
|
||||
|
|
@ -2158,15 +2158,15 @@ bool DivEngine::initAudioBackend() {
|
|||
midiIns=output->midiIn->listDevices();
|
||||
midiOuts=output->midiOut->listDevices();
|
||||
} else {
|
||||
logW("error while initializing MIDI!\n");
|
||||
logW("error while initializing MIDI!");
|
||||
}
|
||||
if (output->midiIn) {
|
||||
String inName=getConfString("midiInDevice","");
|
||||
if (!inName.empty()) {
|
||||
// try opening device
|
||||
logI("opening MIDI input.\n");
|
||||
logI("opening MIDI input.");
|
||||
if (!output->midiIn->openDevice(inName)) {
|
||||
logW("could not open MIDI input device!\n");
|
||||
logW("could not open MIDI input device!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2174,9 +2174,9 @@ bool DivEngine::initAudioBackend() {
|
|||
String outName=getConfString("midiOutDevice","");
|
||||
if (!outName.empty()) {
|
||||
// try opening device
|
||||
logI("opening MIDI output.\n");
|
||||
logI("opening MIDI output.");
|
||||
if (!output->midiOut->openDevice(outName)) {
|
||||
logW("could not open MIDI output device!\n");
|
||||
logW("could not open MIDI output device!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2188,13 +2188,13 @@ bool DivEngine::deinitAudioBackend() {
|
|||
if (output!=NULL) {
|
||||
if (output->midiIn) {
|
||||
if (output->midiIn->isDeviceOpen()) {
|
||||
logI("closing MIDI input.\n");
|
||||
logI("closing MIDI input.");
|
||||
output->midiIn->closeDevice();
|
||||
}
|
||||
}
|
||||
if (output->midiOut) {
|
||||
if (output->midiOut->isDeviceOpen()) {
|
||||
logI("closing MIDI output.\n");
|
||||
logI("closing MIDI output.");
|
||||
output->midiOut->closeDevice();
|
||||
}
|
||||
}
|
||||
|
|
@ -2222,7 +2222,7 @@ bool DivEngine::init() {
|
|||
int uid=getuid();
|
||||
struct passwd* entry=getpwuid(uid);
|
||||
if (entry==NULL) {
|
||||
logW("unable to determine config directory! (%s)\n",strerror(errno));
|
||||
logW("unable to determine config directory! (%s)",strerror(errno));
|
||||
configPath=".";
|
||||
} else {
|
||||
configPath=entry->pw_dir;
|
||||
|
|
@ -2241,21 +2241,21 @@ bool DivEngine::init() {
|
|||
#endif
|
||||
}
|
||||
#endif
|
||||
logD("config path: %s\n",configPath.c_str());
|
||||
logD("config path: %s",configPath.c_str());
|
||||
|
||||
loadConf();
|
||||
|
||||
// init the rest of engine
|
||||
bool haveAudio=false;
|
||||
if (!initAudioBackend()) {
|
||||
logE("no audio output available!\n");
|
||||
logE("no audio output available!");
|
||||
} else {
|
||||
haveAudio=true;
|
||||
}
|
||||
|
||||
samp_bb=blip_new(32768);
|
||||
if (samp_bb==NULL) {
|
||||
logE("not enough memory!\n");
|
||||
logE("not enough memory!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2290,7 +2290,7 @@ bool DivEngine::init() {
|
|||
return false;
|
||||
} else {
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating!\n");
|
||||
logE("error while activating!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -2300,7 +2300,7 @@ bool DivEngine::init() {
|
|||
bool DivEngine::quit() {
|
||||
deinitAudioBackend();
|
||||
quitDispatch();
|
||||
logI("saving config.\n");
|
||||
logI("saving config.");
|
||||
saveConf();
|
||||
active=false;
|
||||
delete[] oscBuf[0];
|
||||
|
|
|
|||
|
|
@ -62,15 +62,15 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
ds.isDMF=true;
|
||||
|
||||
if (!reader.seek(16,SEEK_SET)) {
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
lastError="incomplete file";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
ds.version=(unsigned char)reader.readC();
|
||||
logI("module version %d (0x%.2x)\n",ds.version,ds.version);
|
||||
logI("module version %d (0x%.2x)",ds.version,ds.version);
|
||||
if (ds.version>0x1a) {
|
||||
logE("this version is not supported by Furnace yet!\n");
|
||||
logE("this version is not supported by Furnace yet!");
|
||||
lastError="this version is not supported by Furnace yet";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -106,23 +106,23 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
ds.manInfo=reader.readString((unsigned char)reader.readC());
|
||||
ds.createdDate=reader.readString((unsigned char)reader.readC());
|
||||
ds.revisionDate=reader.readString((unsigned char)reader.readC());
|
||||
logI("%s by %s\n",ds.name.c_str(),ds.author.c_str());
|
||||
logI("has YMU-specific data:\n");
|
||||
logI("- carrier: %s\n",ds.carrier.c_str());
|
||||
logI("- category: %s\n",ds.category.c_str());
|
||||
logI("- vendor: %s\n",ds.vendor.c_str());
|
||||
logI("- writer: %s\n",ds.writer.c_str());
|
||||
logI("- composer: %s\n",ds.composer.c_str());
|
||||
logI("- arranger: %s\n",ds.arranger.c_str());
|
||||
logI("- copyright: %s\n",ds.copyright.c_str());
|
||||
logI("- management group: %s\n",ds.manGroup.c_str());
|
||||
logI("- management info: %s\n",ds.manInfo.c_str());
|
||||
logI("- created on: %s\n",ds.createdDate.c_str());
|
||||
logI("- revision date: %s\n",ds.revisionDate.c_str());
|
||||
logI("%s by %s",ds.name.c_str(),ds.author.c_str());
|
||||
logI("has YMU-specific data:");
|
||||
logI("- carrier: %s",ds.carrier.c_str());
|
||||
logI("- category: %s",ds.category.c_str());
|
||||
logI("- vendor: %s",ds.vendor.c_str());
|
||||
logI("- writer: %s",ds.writer.c_str());
|
||||
logI("- composer: %s",ds.composer.c_str());
|
||||
logI("- arranger: %s",ds.arranger.c_str());
|
||||
logI("- copyright: %s",ds.copyright.c_str());
|
||||
logI("- management group: %s",ds.manGroup.c_str());
|
||||
logI("- management info: %s",ds.manInfo.c_str());
|
||||
logI("- created on: %s",ds.createdDate.c_str());
|
||||
logI("- revision date: %s",ds.revisionDate.c_str());
|
||||
} else {
|
||||
ds.name=reader.readString((unsigned char)reader.readC());
|
||||
ds.author=reader.readString((unsigned char)reader.readC());
|
||||
logI("%s by %s\n",ds.name.c_str(),ds.author.c_str());
|
||||
logI("%s by %s",ds.name.c_str(),ds.author.c_str());
|
||||
}
|
||||
|
||||
// compatibility flags
|
||||
|
|
@ -164,7 +164,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
ds.tuning=443.23;
|
||||
}
|
||||
|
||||
logI("reading module data...\n");
|
||||
logI("reading module data...");
|
||||
if (ds.version>0x0c) {
|
||||
ds.hilightA=reader.readC();
|
||||
ds.hilightB=reader.readC();
|
||||
|
|
@ -186,7 +186,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
try {
|
||||
ds.hz=std::stoi(hz);
|
||||
} catch (std::exception& e) {
|
||||
logW("invalid custom Hz!\n");
|
||||
logW("invalid custom Hz!");
|
||||
ds.hz=60;
|
||||
}
|
||||
}
|
||||
|
|
@ -199,25 +199,25 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
ds.ordersLen=(unsigned char)reader.readC();
|
||||
|
||||
if (ds.patLen<0) {
|
||||
logE("pattern length is negative!\n");
|
||||
logE("pattern length is negative!");
|
||||
lastError="pattern lengrh is negative!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.patLen>256) {
|
||||
logE("pattern length is too large!\n");
|
||||
logE("pattern length is too large!");
|
||||
lastError="pattern length is too large!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.ordersLen<0) {
|
||||
logE("song length is negative!\n");
|
||||
logE("song length is negative!");
|
||||
lastError="song length is negative!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.ordersLen>127) {
|
||||
logE("song is too long!\n");
|
||||
logE("song is too long!");
|
||||
lastError="song is too long!";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -258,12 +258,12 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
addWarning("Yamaha YMU759 emulation is incomplete! please migrate your song to the OPL3 system.");
|
||||
}
|
||||
|
||||
logI("reading pattern matrix (%d)...\n",ds.ordersLen);
|
||||
logI("reading pattern matrix (%d)...",ds.ordersLen);
|
||||
for (int i=0; i<getChannelCount(ds.system[0]); i++) {
|
||||
for (int j=0; j<ds.ordersLen; j++) {
|
||||
ds.orders.ord[i][j]=reader.readC();
|
||||
if (ds.orders.ord[i][j]>0x7f) {
|
||||
logE("order at %d, %d out of range! (%d)\n",i,j,ds.orders.ord[i][j]);
|
||||
logE("order at %d, %d out of range! (%d)",i,j,ds.orders.ord[i][j]);
|
||||
lastError=fmt::sprintf("order at %d, %d out of range! (%d)",i,j,ds.orders.ord[i][j]);
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -279,19 +279,19 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
} else {
|
||||
ds.insLen=16;
|
||||
}
|
||||
logI("reading instruments (%d)...\n",ds.insLen);
|
||||
logI("reading instruments (%d)...",ds.insLen);
|
||||
for (int i=0; i<ds.insLen; i++) {
|
||||
DivInstrument* ins=new DivInstrument;
|
||||
if (ds.version>0x03) {
|
||||
ins->name=reader.readString((unsigned char)reader.readC());
|
||||
}
|
||||
logD("%d name: %s\n",i,ins->name.c_str());
|
||||
logD("%d name: %s",i,ins->name.c_str());
|
||||
if (ds.version<0x0b) {
|
||||
// instruments in ancient versions were all FM or STD.
|
||||
ins->mode=1;
|
||||
} else {
|
||||
unsigned char mode=reader.readC();
|
||||
if (mode>1) logW("%d: invalid instrument mode %d!\n",i,mode);
|
||||
if (mode>1) logW("%d: invalid instrument mode %d!",i,mode);
|
||||
ins->mode=mode;
|
||||
}
|
||||
ins->type=ins->mode?DIV_INS_FM:DIV_INS_STD;
|
||||
|
|
@ -336,7 +336,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
ins->fm.ops=4;
|
||||
}
|
||||
if (ins->fm.ops!=2 && ins->fm.ops!=4) {
|
||||
logE("invalid op count %d. did we read it wrong?\n",ins->fm.ops);
|
||||
logE("invalid op count %d. did we read it wrong?",ins->fm.ops);
|
||||
lastError="file is corrupt or unreadable at operators";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -399,7 +399,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
logD("OP%d: AM %d AR %d DAM %d DR %d DVB %d EGT %d KSL %d MULT %d RR %d SL %d SUS %d TL %d VIB %d WS %d RS %d DT %d D2R %d SSG-EG %d\n",j,
|
||||
logD("OP%d: AM %d AR %d DAM %d DR %d DVB %d EGT %d KSL %d MULT %d RR %d SL %d SUS %d TL %d VIB %d WS %d RS %d DT %d D2R %d SSG-EG %d",j,
|
||||
ins->fm.op[j].am,
|
||||
ins->fm.op[j].ar,
|
||||
ins->fm.op[j].dam,
|
||||
|
|
@ -532,7 +532,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
ins->gb.soundLen=reader.readC();
|
||||
ins->std.volMacro.open=false;
|
||||
|
||||
logD("GB data: vol %d dir %d len %d sl %d\n",ins->gb.envVol,ins->gb.envDir,ins->gb.envLen,ins->gb.soundLen);
|
||||
logD("GB data: vol %d dir %d len %d sl %d",ins->gb.envVol,ins->gb.envDir,ins->gb.envLen,ins->gb.soundLen);
|
||||
} else if (ds.system[0]==DIV_SYSTEM_GB) {
|
||||
// try to convert macro to envelope
|
||||
if (ins->std.volMacro.len>0) {
|
||||
|
|
@ -553,7 +553,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
|
||||
if (ds.version>0x0b) {
|
||||
ds.waveLen=(unsigned char)reader.readC();
|
||||
logI("reading wavetables (%d)...\n",ds.waveLen);
|
||||
logI("reading wavetables (%d)...",ds.waveLen);
|
||||
for (int i=0; i<ds.waveLen; i++) {
|
||||
DivWavetable* wave=new DivWavetable;
|
||||
wave->len=(unsigned char)reader.readI();
|
||||
|
|
@ -564,12 +564,12 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
wave->max=63;
|
||||
}
|
||||
if (wave->len>65) {
|
||||
logE("invalid wave length %d. are we doing something wrong?\n",wave->len);
|
||||
logE("invalid wave length %d. are we doing something wrong?",wave->len);
|
||||
lastError="file is corrupt or unreadable at wavetables";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
logD("%d length %d\n",i,wave->len);
|
||||
logD("%d length %d",i,wave->len);
|
||||
for (int j=0; j<wave->len; j++) {
|
||||
if (ds.version<0x0e) {
|
||||
wave->data[j]=reader.readC();
|
||||
|
|
@ -588,7 +588,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
logI("reading patterns (%d channels, %d orders)...\n",getChannelCount(ds.system[0]),ds.ordersLen);
|
||||
logI("reading patterns (%d channels, %d orders)...",getChannelCount(ds.system[0]),ds.ordersLen);
|
||||
for (int i=0; i<getChannelCount(ds.system[0]); i++) {
|
||||
DivChannelData& chan=ds.pat[i];
|
||||
if (ds.version<0x0a) {
|
||||
|
|
@ -597,9 +597,9 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
chan.effectRows=reader.readC();
|
||||
|
||||
}
|
||||
logD("%d fx rows: %d\n",i,chan.effectRows);
|
||||
logD("%d fx rows: %d",i,chan.effectRows);
|
||||
if (chan.effectRows>4 || chan.effectRows<1) {
|
||||
logE("invalid effect row count %d. are you sure everything is ok?\n",chan.effectRows);
|
||||
logE("invalid effect row count %d. are you sure everything is ok?",chan.effectRows);
|
||||
lastError="file is corrupt or unreadable at effect rows";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -629,7 +629,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
pat->data[k][1]+=2;
|
||||
}
|
||||
if (pat->data[k][0]==0 && pat->data[k][1]!=0) {
|
||||
logD("what? %d:%d:%d note %d octave %d\n",i,j,k,pat->data[k][0],pat->data[k][1]);
|
||||
logD("what? %d:%d:%d note %d octave %d",i,j,k,pat->data[k][0],pat->data[k][1]);
|
||||
pat->data[k][0]=12;
|
||||
pat->data[k][1]--;
|
||||
}
|
||||
|
|
@ -676,7 +676,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
}
|
||||
|
||||
ds.sampleLen=(unsigned char)reader.readC();
|
||||
logI("reading samples (%d)...\n",ds.sampleLen);
|
||||
logI("reading samples (%d)...",ds.sampleLen);
|
||||
if (ds.version<0x0b && ds.sampleLen>0) { // TODO what is this for?
|
||||
reader.readC();
|
||||
}
|
||||
|
|
@ -687,7 +687,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
int vol=50;
|
||||
short* data;
|
||||
if (length<0) {
|
||||
logE("invalid sample length %d. are we doing something wrong?\n",length);
|
||||
logE("invalid sample length %d. are we doing something wrong?",length);
|
||||
lastError="file is corrupt or unreadable at samples";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -697,7 +697,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
} else {
|
||||
sample->name="";
|
||||
}
|
||||
logD("%d name %s (%d)\n",i,sample->name.c_str(),length);
|
||||
logD("%d name %s (%d)",i,sample->name.c_str(),length);
|
||||
sample->rate=22050;
|
||||
if (ds.version>=0x0b) {
|
||||
sample->rate=fileToDivRate(reader.readC());
|
||||
|
|
@ -707,7 +707,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
if (ds.version>0x15) {
|
||||
sample->depth=reader.readC();
|
||||
if (sample->depth!=8 && sample->depth!=16) {
|
||||
logW("%d: sample depth is wrong! (%d)\n",i,sample->depth);
|
||||
logW("%d: sample depth is wrong! (%d)",i,sample->depth);
|
||||
sample->depth=16;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -724,12 +724,12 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
}
|
||||
|
||||
if (pitch!=5) {
|
||||
logD("%d: scaling from %d...\n",i,pitch);
|
||||
logD("%d: scaling from %d...",i,pitch);
|
||||
}
|
||||
|
||||
// render data
|
||||
if (!sample->init((double)length/samplePitches[pitch])) {
|
||||
logE("%d: error while initializing sample!\n",i);
|
||||
logE("%d: error while initializing sample!",i);
|
||||
}
|
||||
|
||||
unsigned int k=0;
|
||||
|
|
@ -754,7 +754,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
|
||||
if (reader.tell()<reader.size()) {
|
||||
if ((reader.tell()+1)!=reader.size()) {
|
||||
logW("premature end of song (we are at %x, but size is %x)\n",reader.tell(),reader.size());
|
||||
logW("premature end of song (we are at %x, but size is %x)",reader.tell(),reader.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -806,7 +806,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
|
|||
syncReset();
|
||||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
lastError="incomplete file";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -828,16 +828,16 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
DivSong ds;
|
||||
|
||||
if (!reader.seek(16,SEEK_SET)) {
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
lastError="incomplete file";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
ds.version=reader.readS();
|
||||
logI("module version %d (0x%.2x)\n",ds.version,ds.version);
|
||||
logI("module version %d (0x%.2x)",ds.version,ds.version);
|
||||
|
||||
if (ds.version>DIV_ENGINE_VERSION) {
|
||||
logW("this module was created with a more recent version of Furnace!\n");
|
||||
logW("this module was created with a more recent version of Furnace!");
|
||||
addWarning("this module was created with a more recent version of Furnace!");
|
||||
}
|
||||
|
||||
|
|
@ -903,7 +903,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
int infoSeek=reader.readI();
|
||||
|
||||
if (!reader.seek(infoSeek,SEEK_SET)) {
|
||||
logE("couldn't seek to info header at %d!\n",infoSeek);
|
||||
logE("couldn't seek to info header at %d!",infoSeek);
|
||||
lastError="couldn't seek to info header!";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -912,7 +912,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
// read header
|
||||
reader.read(magic,4);
|
||||
if (strcmp(magic,"INFO")!=0) {
|
||||
logE("invalid info header!\n");
|
||||
logE("invalid info header!");
|
||||
lastError="invalid info header!";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -939,49 +939,49 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
int numberOfPats=reader.readI();
|
||||
|
||||
if (ds.patLen<0) {
|
||||
logE("pattern length is negative!\n");
|
||||
logE("pattern length is negative!");
|
||||
lastError="pattern lengrh is negative!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.patLen>256) {
|
||||
logE("pattern length is too large!\n");
|
||||
logE("pattern length is too large!");
|
||||
lastError="pattern length is too large!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.ordersLen<0) {
|
||||
logE("song length is negative!\n");
|
||||
logE("song length is negative!");
|
||||
lastError="song length is negative!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.ordersLen>256) {
|
||||
logE("song is too long!\n");
|
||||
logE("song is too long!");
|
||||
lastError="song is too long!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.insLen<0 || ds.insLen>256) {
|
||||
logE("invalid instrument count!\n");
|
||||
logE("invalid instrument count!");
|
||||
lastError="invalid instrument count!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.waveLen<0 || ds.waveLen>256) {
|
||||
logE("invalid wavetable count!\n");
|
||||
logE("invalid wavetable count!");
|
||||
lastError="invalid wavetable count!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (ds.sampleLen<0 || ds.sampleLen>256) {
|
||||
logE("invalid sample count!\n");
|
||||
logE("invalid sample count!");
|
||||
lastError="invalid sample count!";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (numberOfPats<0) {
|
||||
logE("invalid pattern count!\n");
|
||||
logE("invalid pattern count!");
|
||||
lastError="invalid pattern count!";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -991,7 +991,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
unsigned char sysID=reader.readC();
|
||||
ds.system[i]=systemFromFileFur(sysID);
|
||||
if (sysID!=0 && systemToFileFur(ds.system[i])==0) {
|
||||
logE("unrecognized system ID %.2x\n",ds.system[i]);
|
||||
logE("unrecognized system ID %.2x",ds.system[i]);
|
||||
lastError=fmt::sprintf("unrecognized system ID %.2x!",ds.system[i]);
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -1004,7 +1004,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
}
|
||||
if (tchans>DIV_MAX_CHANS) {
|
||||
tchans=DIV_MAX_CHANS;
|
||||
logW("too many channels!\n");
|
||||
logW("too many channels!");
|
||||
}
|
||||
|
||||
// system volume
|
||||
|
|
@ -1061,7 +1061,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
|
||||
ds.name=reader.readString();
|
||||
ds.author=reader.readString();
|
||||
logI("%s by %s\n",ds.name.c_str(),ds.author.c_str());
|
||||
logI("%s by %s",ds.name.c_str(),ds.author.c_str());
|
||||
|
||||
if (ds.version>=33) {
|
||||
ds.tuning=reader.readF();
|
||||
|
|
@ -1167,7 +1167,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
reader.read(samplePtr,ds.sampleLen*4);
|
||||
for (int i=0; i<numberOfPats; i++) patPtr.push_back(reader.readI());
|
||||
|
||||
logD("reading orders (%d)...\n",ds.ordersLen);
|
||||
logD("reading orders (%d)...",ds.ordersLen);
|
||||
for (int i=0; i<tchans; i++) {
|
||||
for (int j=0; j<ds.ordersLen; j++) {
|
||||
ds.orders.ord[i][j]=reader.readC();
|
||||
|
|
@ -1177,7 +1177,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
for (int i=0; i<tchans; i++) {
|
||||
ds.pat[i].effectRows=reader.readC();
|
||||
if (ds.pat[i].effectRows<1 || ds.pat[i].effectRows>8) {
|
||||
logE("channel %d has zero or too many effect columns! (%d)\n",i,ds.pat[i].effectRows);
|
||||
logE("channel %d has zero or too many effect columns! (%d)",i,ds.pat[i].effectRows);
|
||||
lastError=fmt::sprintf("channel %d has too many effect columns! (%d)",i,ds.pat[i].effectRows);
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -1242,9 +1242,9 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
// read instruments
|
||||
for (int i=0; i<ds.insLen; i++) {
|
||||
DivInstrument* ins=new DivInstrument;
|
||||
logD("reading instrument %d at %x...\n",i,insPtr[i]);
|
||||
logD("reading instrument %d at %x...",i,insPtr[i]);
|
||||
if (!reader.seek(insPtr[i],SEEK_SET)) {
|
||||
logE("couldn't seek to instrument %d!\n",i);
|
||||
logE("couldn't seek to instrument %d!",i);
|
||||
lastError=fmt::sprintf("couldn't seek to instrument %d!",i);
|
||||
ds.unload();
|
||||
delete ins;
|
||||
|
|
@ -1266,9 +1266,9 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
// read wavetables
|
||||
for (int i=0; i<ds.waveLen; i++) {
|
||||
DivWavetable* wave=new DivWavetable;
|
||||
logD("reading wavetable %d at %x...\n",i,wavePtr[i]);
|
||||
logD("reading wavetable %d at %x...",i,wavePtr[i]);
|
||||
if (!reader.seek(wavePtr[i],SEEK_SET)) {
|
||||
logE("couldn't seek to wavetable %d!\n",i);
|
||||
logE("couldn't seek to wavetable %d!",i);
|
||||
lastError=fmt::sprintf("couldn't seek to wavetable %d!",i);
|
||||
ds.unload();
|
||||
delete wave;
|
||||
|
|
@ -1293,7 +1293,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
int pitch=0;
|
||||
|
||||
if (!reader.seek(samplePtr[i],SEEK_SET)) {
|
||||
logE("couldn't seek to sample %d!\n",i);
|
||||
logE("couldn't seek to sample %d!",i);
|
||||
lastError=fmt::sprintf("couldn't seek to sample %d!",i);
|
||||
ds.unload();
|
||||
delete[] file;
|
||||
|
|
@ -1302,7 +1302,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
|
||||
reader.read(magic,4);
|
||||
if (strcmp(magic,"SMPL")!=0) {
|
||||
logE("%d: invalid sample header!\n",i);
|
||||
logE("%d: invalid sample header!",i);
|
||||
lastError="invalid sample header!";
|
||||
ds.unload();
|
||||
delete[] file;
|
||||
|
|
@ -1310,7 +1310,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
}
|
||||
reader.readI();
|
||||
DivSample* sample=new DivSample;
|
||||
logD("reading sample %d at %x...\n",i,samplePtr[i]);
|
||||
logD("reading sample %d at %x...",i,samplePtr[i]);
|
||||
|
||||
sample->name=reader.readString();
|
||||
sample->samples=reader.readI();
|
||||
|
|
@ -1348,12 +1348,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
reader.read(data,2*length);
|
||||
|
||||
if (pitch!=5) {
|
||||
logD("%d: scaling from %d...\n",i,pitch);
|
||||
logD("%d: scaling from %d...",i,pitch);
|
||||
}
|
||||
|
||||
// render data
|
||||
if (sample->depth!=8 && sample->depth!=16) {
|
||||
logW("%d: sample depth is wrong! (%d)\n",i,sample->depth);
|
||||
logW("%d: sample depth is wrong! (%d)",i,sample->depth);
|
||||
sample->depth=16;
|
||||
}
|
||||
sample->samples=(double)sample->samples/samplePitches[pitch];
|
||||
|
|
@ -1383,16 +1383,16 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
// read patterns
|
||||
for (int i: patPtr) {
|
||||
if (!reader.seek(i,SEEK_SET)) {
|
||||
logE("couldn't seek to pattern in %x!\n",i);
|
||||
logE("couldn't seek to pattern in %x!",i);
|
||||
lastError=fmt::sprintf("couldn't seek to pattern in %x!",i);
|
||||
ds.unload();
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
reader.read(magic,4);
|
||||
logD("reading pattern in %x...\n",i);
|
||||
logD("reading pattern in %x...",i);
|
||||
if (strcmp(magic,"PATR")!=0) {
|
||||
logE("%x: invalid pattern header!\n",i);
|
||||
logE("%x: invalid pattern header!",i);
|
||||
lastError="invalid pattern header!";
|
||||
ds.unload();
|
||||
delete[] file;
|
||||
|
|
@ -1404,17 +1404,17 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
int index=reader.readS();
|
||||
reader.readI();
|
||||
|
||||
logD("- %d, %d\n",chan,index);
|
||||
logD("- %d, %d",chan,index);
|
||||
|
||||
if (chan<0 || chan>=tchans) {
|
||||
logE("pattern channel out of range!\n",i);
|
||||
logE("pattern channel out of range!",i);
|
||||
lastError="pattern channel out of range!";
|
||||
ds.unload();
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
if (index<0 || index>255) {
|
||||
logE("pattern index out of range!\n",i);
|
||||
logE("pattern index out of range!",i);
|
||||
lastError="pattern index out of range!";
|
||||
ds.unload();
|
||||
delete[] file;
|
||||
|
|
@ -1440,7 +1440,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
|
||||
if (reader.tell()<reader.size()) {
|
||||
if ((reader.tell()+1)!=reader.size()) {
|
||||
logW("premature end of song (we are at %x, but size is %x)\n",reader.tell(),reader.size());
|
||||
logW("premature end of song (we are at %x, but size is %x)",reader.tell(),reader.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1458,7 +1458,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
|||
syncReset();
|
||||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
lastError="incomplete file";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -1501,28 +1501,28 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) {
|
|||
|
||||
// check mod magic bytes
|
||||
if (!reader.seek(1080,SEEK_SET)) {
|
||||
logD("couldn't seek to 1080\n");
|
||||
logD("couldn't seek to 1080");
|
||||
throw EndOfFileException(&reader,reader.tell());
|
||||
}
|
||||
reader.read(magic,4);
|
||||
if (memcmp(magic,"M.K.",4)==0 || memcmp(magic,"M!K!",4)==0 || memcmp(magic,"M&K!",4)==0) {
|
||||
logD("detected a ProTracker module\n");
|
||||
logD("detected a ProTracker module");
|
||||
chCount=4;
|
||||
} else if (memcmp(magic,"CD81",4)==0 || memcmp(magic,"OKTA",4)==0 || memcmp(magic,"OCTA",4)==0) {
|
||||
logD("detected an Oktalyzer/Octalyzer/OctaMED module\n");
|
||||
logD("detected an Oktalyzer/Octalyzer/OctaMED module");
|
||||
chCount=8;
|
||||
} else if (memcmp(magic+1,"CHN",3)==0 && magic[0]>='1' && magic[0]<='9') {
|
||||
logD("detected a FastTracker module\n");
|
||||
logD("detected a FastTracker module");
|
||||
chCount=magic[0]-'0';
|
||||
} else if (memcmp(magic,"FLT",3)==0 && magic[3]>='1' && magic[3]<='9') {
|
||||
logD("detected a Fairlight module\n");
|
||||
logD("detected a Fairlight module");
|
||||
chCount=magic[3]-'0';
|
||||
} else if (memcmp(magic,"TDZ",3)==0 && magic[3]>='1' && magic[3]<='9') {
|
||||
logD("detected a TakeTracker module\n");
|
||||
logD("detected a TakeTracker module");
|
||||
chCount=magic[3]-'0';
|
||||
} else if ((memcmp(magic+2,"CH",2)==0 || memcmp(magic+2,"CN",2)==0) &&
|
||||
(magic[0]>='1' && magic[0]<='9' && magic[1]>='0' && magic[1]<='9')) {
|
||||
logD("detected a Fast/TakeTracker module\n");
|
||||
logD("detected a Fast/TakeTracker module");
|
||||
chCount=((magic[0]-'0')*10)+(magic[1]-'0');
|
||||
} else {
|
||||
// TODO: Soundtracker MOD?
|
||||
|
|
@ -1832,10 +1832,10 @@ bool DivEngine::loadMod(unsigned char* file, size_t len) {
|
|||
}
|
||||
success=true;
|
||||
} catch (EndOfFileException& e) {
|
||||
//logE("premature end of file!\n");
|
||||
//logE("premature end of file!");
|
||||
lastError="incomplete file";
|
||||
} catch (InvalidHeaderException& e) {
|
||||
//logE("invalid info header!\n");
|
||||
//logE("invalid info header!");
|
||||
lastError="invalid info header!";
|
||||
}
|
||||
return success;
|
||||
|
|
@ -1853,14 +1853,14 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
if (memcmp(f,DIV_DMF_MAGIC,16)!=0 && memcmp(f,DIV_FUR_MAGIC,16)!=0) {
|
||||
// try loading as a .mod first before trying to decompress
|
||||
// TODO: move to a different location?
|
||||
logD("loading as .mod...\n");
|
||||
logD("loading as .mod...");
|
||||
if (loadMod(f,slen)) {
|
||||
delete[] f;
|
||||
return true;
|
||||
}
|
||||
|
||||
lastError="not a .mod song";
|
||||
logD("loading as zlib...\n");
|
||||
logD("loading as zlib...");
|
||||
// try zlib
|
||||
z_stream zl;
|
||||
memset(&zl,0,sizeof(z_stream));
|
||||
|
|
@ -1875,9 +1875,9 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
nextErr=inflateInit(&zl);
|
||||
if (nextErr!=Z_OK) {
|
||||
if (zl.msg==NULL) {
|
||||
logE("zlib error: unknown! %d\n",nextErr);
|
||||
logE("zlib error: unknown! %d",nextErr);
|
||||
} else {
|
||||
logE("zlib error: %s\n",zl.msg);
|
||||
logE("zlib error: %s",zl.msg);
|
||||
}
|
||||
inflateEnd(&zl);
|
||||
delete[] f;
|
||||
|
|
@ -1894,10 +1894,10 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
nextErr=inflate(&zl,Z_SYNC_FLUSH);
|
||||
if (nextErr!=Z_OK && nextErr!=Z_STREAM_END) {
|
||||
if (zl.msg==NULL) {
|
||||
logE("zlib error: unknown error! %d\n",nextErr);
|
||||
logE("zlib error: unknown error! %d",nextErr);
|
||||
lastError="unknown decompression error";
|
||||
} else {
|
||||
logE("zlib inflate: %s\n",zl.msg);
|
||||
logE("zlib inflate: %s",zl.msg);
|
||||
lastError=fmt::sprintf("decompression error: %s",zl.msg);
|
||||
}
|
||||
for (InflateBlock* i: blocks) delete i;
|
||||
|
|
@ -1916,10 +1916,10 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
nextErr=inflateEnd(&zl);
|
||||
if (nextErr!=Z_OK) {
|
||||
if (zl.msg==NULL) {
|
||||
logE("zlib end error: unknown error! %d\n",nextErr);
|
||||
logE("zlib end error: unknown error! %d",nextErr);
|
||||
lastError="unknown decompression finish error";
|
||||
} else {
|
||||
logE("zlib end: %s\n",zl.msg);
|
||||
logE("zlib end: %s",zl.msg);
|
||||
lastError=fmt::sprintf("decompression finish error: %s",zl.msg);
|
||||
}
|
||||
for (InflateBlock* i: blocks) delete i;
|
||||
|
|
@ -1934,7 +1934,7 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
finalSize+=i->blockSize;
|
||||
}
|
||||
if (finalSize<1) {
|
||||
logE("compressed too small!\n");
|
||||
logE("compressed too small!");
|
||||
lastError="file too small";
|
||||
for (InflateBlock* i: blocks) delete i;
|
||||
blocks.clear();
|
||||
|
|
@ -1951,7 +1951,7 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
len=finalSize;
|
||||
delete[] f;
|
||||
} else {
|
||||
logD("loading as uncompressed\n");
|
||||
logD("loading as uncompressed");
|
||||
file=(unsigned char*)f;
|
||||
len=slen;
|
||||
}
|
||||
|
|
@ -1960,7 +1960,7 @@ bool DivEngine::load(unsigned char* f, size_t slen) {
|
|||
} else if (memcmp(file,DIV_FUR_MAGIC,16)==0) {
|
||||
return loadFur(file,len);
|
||||
}
|
||||
logE("not a valid module!\n");
|
||||
logE("not a valid module!");
|
||||
lastError="not a compatible song";
|
||||
delete[] file;
|
||||
return false;
|
||||
|
|
@ -2227,7 +2227,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
|||
SafeWriter* DivEngine::saveDMF(unsigned char version) {
|
||||
// fail if version is not supported
|
||||
if (version<24 || version>26) {
|
||||
logE("cannot save in this version!\n");
|
||||
logE("cannot save in this version!");
|
||||
lastError="invalid version to save in! this is a bug!";
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2255,60 +2255,60 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
|
|||
}
|
||||
// fail if more than one system
|
||||
if (!isFlat && song.systemLen!=1) {
|
||||
logE("cannot save multiple systems in this format!\n");
|
||||
logE("cannot save multiple systems in this format!");
|
||||
lastError="multiple systems not possible on .dmf";
|
||||
return NULL;
|
||||
}
|
||||
// fail if this is an YMU759 song
|
||||
if (song.system[0]==DIV_SYSTEM_YMU759) {
|
||||
logE("cannot save YMU759 song!\n");
|
||||
logE("cannot save YMU759 song!");
|
||||
lastError="YMU759 song saving is not supported";
|
||||
return NULL;
|
||||
}
|
||||
// fail if the system is SMS+OPLL and version<25
|
||||
if (version<25 && song.system[0]==DIV_SYSTEM_SMS && song.system[1]==DIV_SYSTEM_OPLL) {
|
||||
logE("Master System FM expansion not supported in 1.0/legacy .dmf!\n");
|
||||
logE("Master System FM expansion not supported in 1.0/legacy .dmf!");
|
||||
lastError="Master System FM expansion not supported in 1.0/legacy .dmf!";
|
||||
return NULL;
|
||||
}
|
||||
// fail if the system is NES+VRC7 and version<25
|
||||
if (version<25 && song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_VRC7) {
|
||||
logE("NES + VRC7 not supported in 1.0/legacy .dmf!\n");
|
||||
logE("NES + VRC7 not supported in 1.0/legacy .dmf!");
|
||||
lastError="NES + VRC7 not supported in 1.0/legacy .dmf!";
|
||||
return NULL;
|
||||
}
|
||||
// fail if the system is FDS and version<25
|
||||
if (version<25 && song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_FDS) {
|
||||
logE("FDS not supported in 1.0/legacy .dmf!\n");
|
||||
logE("FDS not supported in 1.0/legacy .dmf!");
|
||||
lastError="FDS not supported in 1.0/legacy .dmf!";
|
||||
return NULL;
|
||||
}
|
||||
// fail if the system is Furnace-exclusive
|
||||
if (!isFlat && systemToFileDMF(song.system[0])==0) {
|
||||
logE("cannot save Furnace-exclusive system song!\n");
|
||||
logE("cannot save Furnace-exclusive system song!");
|
||||
lastError="this system is not possible on .dmf";
|
||||
return NULL;
|
||||
}
|
||||
// fail if values are out of range
|
||||
if (song.ordersLen>127) {
|
||||
logE("maximum .dmf song length is 127!\n");
|
||||
logE("maximum .dmf song length is 127!");
|
||||
lastError="maximum .dmf song length is 127";
|
||||
return NULL;
|
||||
}
|
||||
if (song.ins.size()>128) {
|
||||
logE("maximum number of instruments in .dmf is 128!\n");
|
||||
logE("maximum number of instruments in .dmf is 128!");
|
||||
lastError="maximum number of instruments in .dmf is 128";
|
||||
return NULL;
|
||||
}
|
||||
if (song.wave.size()>64) {
|
||||
logE("maximum number of wavetables in .dmf is 64!\n");
|
||||
logE("maximum number of wavetables in .dmf is 64!");
|
||||
lastError="maximum number of wavetables in .dmf is 64";
|
||||
return NULL;
|
||||
}
|
||||
for (int i=0; i<chans; i++) {
|
||||
for (int j=0; j<song.ordersLen; j++) {
|
||||
if (song.orders.ord[i][j]>0x7f) {
|
||||
logE("order %d, %d is out of range (0-127)!\n",song.orders.ord[i][j]);
|
||||
logE("order %d, %d is out of range (0-127)!",song.orders.ord[i][j]);
|
||||
lastError=fmt::sprintf("order %d, %d is out of range (0-127)",song.orders.ord[i][j]);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -2486,7 +2486,7 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) {
|
|||
w->writeC(i->c64.s);
|
||||
w->writeC(i->c64.r);
|
||||
|
||||
logW("duty and cutoff precision will be lost!\n");
|
||||
logW("duty and cutoff precision will be lost!");
|
||||
w->writeC((i->c64.duty*100)/4095);
|
||||
|
||||
w->writeC(i->c64.ringMod);
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
try {
|
||||
reader.seek(0,SEEK_SET);
|
||||
version=reader.readC();
|
||||
logD(".dmp version %d\n",version);
|
||||
logD(".dmp version %d",version);
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -64,38 +64,38 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
switch (sys) {
|
||||
case 1: // YMU759
|
||||
ins->type=DIV_INS_FM;
|
||||
logD("instrument type is YMU759\n");
|
||||
logD("instrument type is YMU759");
|
||||
break;
|
||||
case 2: // Genesis
|
||||
ins->type=DIV_INS_FM;
|
||||
logD("instrument type is Genesis\n");
|
||||
logD("instrument type is Genesis");
|
||||
break;
|
||||
case 3: // SMS
|
||||
ins->type=DIV_INS_STD;
|
||||
logD("instrument type is SMS\n");
|
||||
logD("instrument type is SMS");
|
||||
break;
|
||||
case 4: // Game Boy
|
||||
ins->type=DIV_INS_GB;
|
||||
logD("instrument type is Game Boy\n");
|
||||
logD("instrument type is Game Boy");
|
||||
break;
|
||||
case 5: // PC Engine
|
||||
ins->type=DIV_INS_PCE;
|
||||
logD("instrument type is PC Engine\n");
|
||||
logD("instrument type is PC Engine");
|
||||
break;
|
||||
case 6: // NES
|
||||
ins->type=DIV_INS_STD;
|
||||
logD("instrument type is NES\n");
|
||||
logD("instrument type is NES");
|
||||
break;
|
||||
case 7: case 0x17: // C64
|
||||
ins->type=DIV_INS_C64;
|
||||
logD("instrument type is C64\n");
|
||||
logD("instrument type is C64");
|
||||
break;
|
||||
case 8: // Arcade
|
||||
ins->type=DIV_INS_FM;
|
||||
logD("instrument type is Arcade\n");
|
||||
logD("instrument type is Arcade");
|
||||
break;
|
||||
default:
|
||||
logD("instrument type is unknown\n");
|
||||
logD("instrument type is unknown");
|
||||
lastError="unknown instrument type!";
|
||||
delete ins;
|
||||
return;
|
||||
|
|
@ -103,7 +103,7 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -113,7 +113,7 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
bool mode=true;
|
||||
if (version>1) {
|
||||
mode=reader.readC();
|
||||
logD("instrument mode is %d\n",mode);
|
||||
logD("instrument mode is %d",mode);
|
||||
if (mode==0) {
|
||||
if (version<11) {
|
||||
ins->type=DIV_INS_STD;
|
||||
|
|
@ -126,7 +126,7 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
|
||||
if (mode) { // FM
|
||||
logD("reading FM data...\n");
|
||||
logD("reading FM data...");
|
||||
if (version<10) {
|
||||
if (version>1) {
|
||||
// bullcrap! no way to determine the instrument type other than a vague FM/STD!
|
||||
|
|
@ -151,7 +151,7 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
if (sys!=1) ins->fm.ams=reader.readC();
|
||||
|
||||
for (int j=0; j<ins->fm.ops; j++) {
|
||||
logD("OP%d is at %d\n",j,reader.tell());
|
||||
logD("OP%d is at %d",j,reader.tell());
|
||||
ins->fm.op[j].mult=reader.readC();
|
||||
ins->fm.op[j].tl=reader.readC();
|
||||
ins->fm.op[j].ar=reader.readC();
|
||||
|
|
@ -179,7 +179,7 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
}
|
||||
} else { // STD
|
||||
logD("reading STD data...\n");
|
||||
logD("reading STD data...");
|
||||
if (ins->type!=DIV_INS_GB) {
|
||||
ins->std.volMacro.len=reader.readC();
|
||||
if (version>5) {
|
||||
|
|
@ -295,7 +295,7 @@ void DivEngine::loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -330,7 +330,7 @@ void DivEngine::loadTFI(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -372,7 +372,7 @@ void DivEngine::loadVGI(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ void DivEngine::loadS3I(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
};
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError = "premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -623,7 +623,7 @@ void DivEngine::loadSBI(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError = "premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
return;
|
||||
}
|
||||
|
|
@ -640,7 +640,7 @@ void DivEngine::loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, St
|
|||
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -695,7 +695,7 @@ std::vector<DivInstrument*> DivEngine::instrumentFromFile(const char* path) {
|
|||
}
|
||||
buf=new unsigned char[len];
|
||||
if (fread(buf,1,len,f)!=(size_t)len) {
|
||||
logW("did not read entire instrument file buffer!\n");
|
||||
logW("did not read entire instrument file buffer!");
|
||||
lastError="did not read entire instrument file!";
|
||||
delete[] buf;
|
||||
return ret;
|
||||
|
|
@ -738,7 +738,7 @@ std::vector<DivInstrument*> DivEngine::instrumentFromFile(const char* path) {
|
|||
}
|
||||
} catch (EndOfFileException& e) {
|
||||
lastError="premature end of file";
|
||||
logE("premature end of file!\n");
|
||||
logE("premature end of file!");
|
||||
delete ins;
|
||||
delete[] buf;
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ float* DivFilterTables::sincIntegralTable=NULL;
|
|||
// licensed under same license as this program.
|
||||
float* DivFilterTables::getCubicTable() {
|
||||
if (cubicTable==NULL) {
|
||||
logD("initializing cubic spline table.\n");
|
||||
logD("initializing cubic spline table.");
|
||||
cubicTable=new float[4096];
|
||||
|
||||
for (int i=0; i<1024; i++) {
|
||||
|
|
@ -46,7 +46,7 @@ float* DivFilterTables::getCubicTable() {
|
|||
|
||||
float* DivFilterTables:: getSincTable() {
|
||||
if (sincTable==NULL) {
|
||||
logD("initializing sinc table.\n");
|
||||
logD("initializing sinc table.");
|
||||
sincTable=new float[65536];
|
||||
|
||||
sincTable[0]=1.0f;
|
||||
|
|
@ -66,7 +66,7 @@ float* DivFilterTables:: getSincTable() {
|
|||
|
||||
float* DivFilterTables::getSincIntegralTable() {
|
||||
if (sincIntegralTable==NULL) {
|
||||
logD("initializing sinc integral table.\n");
|
||||
logD("initializing sinc integral table.");
|
||||
sincIntegralTable=new float[65536];
|
||||
|
||||
sincIntegralTable[0]=-0.5f;
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
|
|||
char magic[4];
|
||||
reader.read(magic,4);
|
||||
if (memcmp(magic,"INST",4)!=0) {
|
||||
logE("invalid instrument header!\n");
|
||||
logE("invalid instrument header!");
|
||||
return DIV_DATA_INVALID_HEADER;
|
||||
}
|
||||
reader.readI();
|
||||
|
|
@ -949,12 +949,12 @@ bool DivInstrument::save(const char* path) {
|
|||
|
||||
FILE* outFile=ps_fopen(path,"wb");
|
||||
if (outFile==NULL) {
|
||||
logE("could not save instrument: %s!\n",strerror(errno));
|
||||
logE("could not save instrument: %s!",strerror(errno));
|
||||
w->finish();
|
||||
return false;
|
||||
}
|
||||
if (fwrite(w->getFinalBuf(),1,w->size(),outFile)!=w->size()) {
|
||||
logW("did not write entire instrument!\n");
|
||||
logW("did not write entire instrument!");
|
||||
}
|
||||
fclose(outFile);
|
||||
w->finish();
|
||||
|
|
|
|||
|
|
@ -431,11 +431,11 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
if (c.value) { // port B
|
||||
ioPortB=true;
|
||||
portBVal=c.value2;
|
||||
logI("AY I/O port B write: %x\n",portBVal);
|
||||
logI("AY I/O port B write: %x",portBVal);
|
||||
} else { // port A
|
||||
ioPortA=true;
|
||||
portAVal=c.value2;
|
||||
logI("AY I/O port A write: %x\n",portAVal);
|
||||
logI("AY I/O port A write: %x",portAVal);
|
||||
}
|
||||
updateOutSel(true);
|
||||
immWrite(14+(c.value?1:0),(c.value?portBVal:portAVal));
|
||||
|
|
|
|||
|
|
@ -456,11 +456,11 @@ int DivPlatformAY8930::dispatch(DivCommand c) {
|
|||
if (c.value) { // port B
|
||||
ioPortB=true;
|
||||
portBVal=c.value2;
|
||||
logI("AY I/O port B write: %x\n",portBVal);
|
||||
logI("AY I/O port B write: %x",portBVal);
|
||||
} else { // port A
|
||||
ioPortA=true;
|
||||
portAVal=c.value2;
|
||||
logI("AY I/O port A write: %x\n",portAVal);
|
||||
logI("AY I/O port A write: %x",portAVal);
|
||||
}
|
||||
updateOutSel(true);
|
||||
immWrite(14+(c.value?1:0),(c.value?portBVal:portAVal));
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ void DivPlatformQSound::tick() {
|
|||
rWrite(q1_reg_map[Q1V_LOOP][i], qsound_loop);
|
||||
rWrite(q1_reg_map[Q1V_START][i], qsound_addr);
|
||||
rWrite(q1_reg_map[Q1V_PHASE][i], 0x8000);
|
||||
//logW("ch %d bank=%04x, addr=%04x, end=%04x, loop=%04x!\n",i,qsound_bank,qsound_addr,qsound_end,qsound_loop);
|
||||
//logV("ch %d bank=%04x, addr=%04x, end=%04x, loop=%04x!",i,qsound_bank,qsound_addr,qsound_end,qsound_loop);
|
||||
// Write sample address. Enable volume
|
||||
if (!chan[i].std.vol.had) {
|
||||
rWrite(q1_reg_map[Q1V_VOL][i], chan[i].vol << 4);
|
||||
|
|
@ -347,7 +347,7 @@ void DivPlatformQSound::tick() {
|
|||
rWrite(q1_reg_map[Q1V_VOL][i], 0);
|
||||
rWrite(q1_reg_map[Q1V_FREQ][i], 0);
|
||||
} else if (chan[i].active) {
|
||||
//logW("ch %d frequency set to %04x, off=%f, note=%d, %04x!\n",i,chan[i].freq,off,chan[i].note,QS_NOTE_FREQUENCY(chan[i].note));
|
||||
//logV("ch %d frequency set to %04x, off=%f, note=%d, %04x!",i,chan[i].freq,off,chan[i].note,QS_NOTE_FREQUENCY(chan[i].note));
|
||||
rWrite(q1_reg_map[Q1V_FREQ][i], chan[i].freq);
|
||||
}
|
||||
if (chan[i].keyOn) chan[i].keyOn=false;
|
||||
|
|
|
|||
|
|
@ -1660,7 +1660,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
|
||||
if (softLocked) {
|
||||
if (!isBusy.try_lock()) {
|
||||
logV("audio is soft-locked (%d)\n",softLockCount++);
|
||||
logV("audio is soft-locked (%d)",softLockCount++);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1712,7 +1712,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
}
|
||||
}
|
||||
}
|
||||
logD("%.2x\n",msg.type);
|
||||
logD("%.2x",msg.type);
|
||||
output->midiIn->queue.pop();
|
||||
}
|
||||
|
||||
|
|
@ -1845,7 +1845,7 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
if (remainingLoops>0) {
|
||||
remainingLoops--;
|
||||
if (!remainingLoops) {
|
||||
logI("end of song!\n");
|
||||
logI("end of song!");
|
||||
remainingLoops=-1;
|
||||
playing=false;
|
||||
freelance=false;
|
||||
|
|
@ -1881,9 +1881,9 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
|
|||
return;
|
||||
}
|
||||
|
||||
//logD("attempts: %d\n",attempts);
|
||||
//logD("attempts: %d",attempts);
|
||||
if (attempts>=100) {
|
||||
logE("hang detected! stopping! at %d seconds %d micro\n",totalSeconds,totalTicks);
|
||||
logE("hang detected! stopping! at %d seconds %d micro",totalSeconds,totalTicks);
|
||||
freelance=false;
|
||||
playing=false;
|
||||
extValuePresent=false;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ size_t SafeReader::size() {
|
|||
|
||||
int SafeReader::read(void* where, size_t count) {
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: reading %d bytes at %x\n",count,curSeek);
|
||||
logD("SR: reading %d bytes at %x",count,curSeek);
|
||||
#endif
|
||||
if (count==0) return 0;
|
||||
if (curSeek+count>len) throw EndOfFileException(this,len);
|
||||
|
|
@ -68,23 +68,23 @@ int SafeReader::read(void* where, size_t count) {
|
|||
|
||||
signed char SafeReader::readC() {
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: reading char %x:\n",curSeek);
|
||||
logD("SR: reading char %x:",curSeek);
|
||||
#endif
|
||||
if (curSeek+1>len) throw EndOfFileException(this,len);
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: %.2x\n",buf[curSeek]);
|
||||
logD("SR: %.2x",buf[curSeek]);
|
||||
#endif
|
||||
return (signed char)buf[curSeek++];
|
||||
}
|
||||
|
||||
short SafeReader::readS() {
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: reading short %x:\n",curSeek);
|
||||
logD("SR: reading short %x:",curSeek);
|
||||
#endif
|
||||
if (curSeek+2>len) throw EndOfFileException(this,len);
|
||||
short ret=*(short*)(&buf[curSeek]);
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: %.4x\n",ret);
|
||||
logD("SR: %.4x",ret);
|
||||
#endif
|
||||
curSeek+=2;
|
||||
return ret;
|
||||
|
|
@ -99,13 +99,13 @@ short SafeReader::readS_BE() {
|
|||
|
||||
int SafeReader::readI() {
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: reading int %x:\n",curSeek);
|
||||
logD("SR: reading int %x:",curSeek);
|
||||
#endif
|
||||
if (curSeek+4>len) throw EndOfFileException(this,len);
|
||||
int ret=*(int*)(&buf[curSeek]);
|
||||
curSeek+=4;
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: %.8x\n",ret);
|
||||
logD("SR: %.8x",ret);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -141,7 +141,7 @@ double SafeReader::readD() {
|
|||
String SafeReader::readString(size_t stlen) {
|
||||
String ret;
|
||||
#ifdef READ_DEBUG
|
||||
logD("SR: reading string len %d at %x\n",stlen,curSeek);
|
||||
logD("SR: reading string len %d at %x",stlen,curSeek);
|
||||
#endif
|
||||
size_t curPos=0;
|
||||
while (curPos<stlen) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ bool DivSample::save(const char* path) {
|
|||
f=sf_open(path,SFM_WRITE,&si);
|
||||
|
||||
if (f==NULL) {
|
||||
logE("could not open wave file for saving! %s\n",sf_error_number(sf_error(f)));
|
||||
logE("could not open wave file for saving! %s",sf_error_number(sf_error(f)));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -822,7 +822,7 @@ DivSampleHistory* DivSample::prepareUndo(bool data, bool doNotPush) {
|
|||
initInternal(h->depth,h->samples); \
|
||||
samples=h->samples; \
|
||||
\
|
||||
if (h->length!=getCurBufLen()) logW("undo buffer length not equal to current buffer length! %d != %d\n",h->length,getCurBufLen()); \
|
||||
if (h->length!=getCurBufLen()) logW("undo buffer length not equal to current buffer length! %d != %d",h->length,getCurBufLen()); \
|
||||
\
|
||||
void* buf=getCurBuf(); \
|
||||
\
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
}
|
||||
if (write.addr>=0xffff0000) { // Furnace special command
|
||||
unsigned char streamID=streamOff+((write.addr&0xff00)>>8);
|
||||
logD("writing stream command %x:%x with stream ID %d\n",write.addr,write.val,streamID);
|
||||
logD("writing stream command %x:%x with stream ID %d",write.addr,write.val,streamID);
|
||||
switch (write.addr&0xff) {
|
||||
case 0: // play sample
|
||||
if (write.val<song.sampleLen) {
|
||||
|
|
@ -599,7 +599,7 @@ void DivEngine::performVGMWrite(SafeWriter* w, DivSystem sys, DivRegWrite& write
|
|||
}
|
||||
break;
|
||||
default:
|
||||
logW("write not handled!\n");
|
||||
logW("write not handled!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -620,7 +620,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) {
|
|||
int loopRow=0;
|
||||
int loopEnd=0;
|
||||
walkSong(loopOrder,loopRow,loopEnd);
|
||||
logI("loop point: %d %d\n",loopOrder,loopRow);
|
||||
logI("loop point: %d %d",loopOrder,loopRow);
|
||||
warnings="";
|
||||
|
||||
curOrder=0;
|
||||
|
|
@ -1162,7 +1162,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) {
|
|||
unsigned int sampleSeek=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* sample=song.sample[i];
|
||||
logI("setting seek to %d\n",sampleSeek);
|
||||
logI("setting seek to %d",sampleSeek);
|
||||
sample->off8=sampleSeek;
|
||||
sampleSeek+=sample->length8;
|
||||
}
|
||||
|
|
@ -1447,7 +1447,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) {
|
|||
if (waitTime>0) {
|
||||
w->writeC(0x61);
|
||||
w->writeS(waitTime);
|
||||
printf("wait is: %f\n",waitTime);
|
||||
logV("wait is: %f",waitTime);
|
||||
totalWait-=waitTime;
|
||||
tickCount+=waitTime;
|
||||
}
|
||||
|
|
@ -1561,7 +1561,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version) {
|
|||
freelance=false;
|
||||
extValuePresent=false;
|
||||
|
||||
logI("%d register writes total.\n",writeCount);
|
||||
logI("%d register writes total.",writeCount);
|
||||
|
||||
BUSY_END;
|
||||
return w;
|
||||
|
|
|
|||
|
|
@ -73,12 +73,12 @@ bool DivWavetable::save(const char* path) {
|
|||
|
||||
FILE* outFile=ps_fopen(path,"wb");
|
||||
if (outFile==NULL) {
|
||||
logE("could not save wavetable: %s!\n",strerror(errno));
|
||||
logE("could not save wavetable: %s!",strerror(errno));
|
||||
w->finish();
|
||||
return false;
|
||||
}
|
||||
if (fwrite(w->getFinalBuf(),1,w->size(),outFile)!=w->size()) {
|
||||
logW("did not write entire wavetable!\n");
|
||||
logW("did not write entire wavetable!");
|
||||
}
|
||||
fclose(outFile);
|
||||
w->finish();
|
||||
|
|
|
|||
|
|
@ -33,15 +33,15 @@ String getWinConfigPath() {
|
|||
configPath=path;
|
||||
configPath+=L"\\furnace";
|
||||
if (!PathIsDirectoryW(configPath.c_str())) {
|
||||
logI("creating config dir...\n");
|
||||
logI("creating config dir...");
|
||||
int mkdirRet;
|
||||
if ((mkdirRet=SHCreateDirectory(NULL,configPath.c_str()))!=ERROR_SUCCESS) {
|
||||
logW("could not make config dir! (%.8x)\n",mkdirRet);
|
||||
logW("could not make config dir! (%.8x)",mkdirRet);
|
||||
configPath=L".";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logW("unable to determine config directory! (%.8x)\n",configHR);
|
||||
logW("unable to determine config directory! (%.8x)",configHR);
|
||||
configPath=L".";
|
||||
}
|
||||
return utf16To8(configPath.c_str());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue