temporarily disable audio export
I need to rewrite the audio export code so it becomes possible to export audio from the GUI
This commit is contained in:
parent
12236248dd
commit
3026bf8ba9
|
@ -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 <file>
|
||||
```
|
||||
|
||||
this will render a file to .wav.
|
||||
|
||||
# notes
|
||||
|
||||
> how do I use Neo Geo SSG envelopes?
|
||||
|
|
|
@ -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; h<song.systemLen; h++) {
|
||||
if (disCont[h].dispatch->isStereo()) {
|
||||
for (size_t i=0; i<got.bufsize; i++) {
|
||||
ilBuffer[i<<1]=disCont[h].bbOut[0][i];
|
||||
ilBuffer[1+(i<<1)]=disCont[h].bbOut[1][i];
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<got.bufsize; i++) {
|
||||
ilBuffer[i<<1]=disCont[h].bbOut[0][i];
|
||||
ilBuffer[1+(i<<1)]=disCont[h].bbOut[0][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!remainingLoops) {
|
||||
sf_writef_short(outFile,ilBuffer,totalProcessed);
|
||||
} else {
|
||||
sf_writef_short(outFile,ilBuffer,got.bufsize);
|
||||
}
|
||||
}
|
||||
delete[] ilBuffer;
|
||||
sf_close(outFile);
|
||||
return true;
|
||||
} else {
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating!\n");
|
||||
return false;
|
||||
}
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating!\n");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue