diff --git a/README.md b/README.md index 88774b976..79d83c401 100644 --- a/README.md +++ b/README.md @@ -95,12 +95,6 @@ this will play a compatible file. this will play a compatible file and enable the commands view. -``` -./furnace -output audio.wav -``` - -this will render a file to .wav. - # notes > how do I use Neo Geo SSG envelopes? diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 165f439f6..57458d081 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -3229,7 +3229,7 @@ void DivEngine::quitDispatch() { #include "winStuff.h" #endif -bool DivEngine::init(String outName) { +bool DivEngine::init() { // init config #ifdef _WIN32 configPath=getWinConfigPath(); @@ -3263,56 +3263,38 @@ bool DivEngine::init(String outName) { } // init the rest of engine - SNDFILE* outFile=NULL; - SF_INFO outInfo; - if (outName!="") { - // init out file - got.bufsize=2048; - got.rate=44100; - - outInfo.samplerate=got.rate; - outInfo.channels=2; - outInfo.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16; - - outFile=sf_open(outName.c_str(),SFM_WRITE,&outInfo); - if (outFile==NULL) { - logE("could not open file for writing!\n"); + switch (audioEngine) { + case DIV_AUDIO_JACK: +#ifndef HAVE_JACK + logE("Furnace was not compiled with JACK support!\n"); + setConf("audioEngine","SDL"); + saveConf(); return false; - } - } else { - switch (audioEngine) { - case DIV_AUDIO_JACK: - #ifndef HAVE_JACK - logE("Furnace was not compiled with JACK support!\n"); - setConf("audioEngine","SDL"); - saveConf(); - return false; - #else - output=new TAAudioJACK; - #endif - break; - case DIV_AUDIO_SDL: - output=new TAAudioSDL; - break; - default: - logE("invalid audio engine!\n"); - return false; - } - want.bufsize=getConfInt("audioBufSize",1024); - want.rate=getConfInt("audioRate",44100); - want.fragments=2; - want.inChans=0; - want.outChans=2; - want.outFormat=TA_AUDIO_FORMAT_F32; - want.name="Furnace"; - - output->setCallback(process,this); - - logI("initializing audio.\n"); - if (!output->init(want,got)) { - logE("error while initializing audio!\n"); +#else + output=new TAAudioJACK; +#endif + break; + case DIV_AUDIO_SDL: + output=new TAAudioSDL; + break; + default: + logE("invalid audio engine!\n"); return false; - } + } + want.bufsize=getConfInt("audioBufSize",1024); + want.rate=getConfInt("audioRate",44100); + want.fragments=2; + want.inChans=0; + want.outChans=2; + want.outFormat=TA_AUDIO_FORMAT_F32; + want.name="Furnace"; + + output->setCallback(process,this); + + logI("initializing audio.\n"); + if (!output->init(want,got)) { + logE("error while initializing audio!\n"); + return false; } samp_bb=blip_new(32768); @@ -3340,42 +3322,9 @@ bool DivEngine::init(String outName) { reset(); active=true; - if (outName!="") { - short* ilBuffer=new short[got.bufsize*2]; - // render to file - remainingLoops=1; - play(); - while (remainingLoops) { - nextBuf(NULL,NULL,0,2,got.bufsize); - - for (int h=0; hisStereo()) { - for (size_t i=0; isetRun(true)) { - logE("error while activating!\n"); - return false; - } + if (!output->setRun(true)) { + logE("error while activating!\n"); + return false; } return true; } diff --git a/src/engine/engine.h b/src/engine/engine.h index 322026a81..f817c3d3d 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -194,6 +194,10 @@ class DivEngine { SafeWriter* buildROM(int sys); // dump to VGM (TODO). SafeWriter* saveVGM(); + // export to an audio file + bool saveAudio(const char* path); + // stop audio file export + bool haltAudioFile(); // save config bool saveConf(); @@ -423,7 +427,7 @@ class DivEngine { void quitDispatch(); // initialize the engine. optionally provide an output file name. - bool init(String outName=""); + bool init(); // terminate the engine. bool quit(); diff --git a/src/main.cpp b/src/main.cpp index c1d2fdce7..1dcaea785 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -292,7 +292,7 @@ int main(int argc, char** argv) { return 1; } } - if (!e.init(outName)) { + if (!e.init()) { logE("could not initialize engine!\n"); return 1; }