bring command-line audio export back!
This commit is contained in:
parent
5a2a3a03c0
commit
e79a1bd64d
|
@ -27,7 +27,8 @@ bool TAAudio::setRun(bool run) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TAAudio::init(TAAudioDesc& request, TAAudioDesc& response) {
|
bool TAAudio::init(TAAudioDesc& request, TAAudioDesc& response) {
|
||||||
return false;
|
response=request;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAAudio::~TAAudio() {
|
TAAudio::~TAAudio() {
|
||||||
|
|
|
@ -1932,7 +1932,7 @@ void DivEngine::runExportThread() {
|
||||||
|
|
||||||
sf=sf_open(exportPath.c_str(),SFM_WRITE,&si);
|
sf=sf_open(exportPath.c_str(),SFM_WRITE,&si);
|
||||||
if (sf==NULL) {
|
if (sf==NULL) {
|
||||||
logE("could not open file for writing!\n");
|
logE("could not open file for writing! (%s)\n",sf_strerror(NULL));
|
||||||
exporting=false;
|
exporting=false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1946,6 +1946,8 @@ void DivEngine::runExportThread() {
|
||||||
deinitAudioBackend();
|
deinitAudioBackend();
|
||||||
playSub(false);
|
playSub(false);
|
||||||
|
|
||||||
|
logI("rendering to file...\n");
|
||||||
|
|
||||||
while (playing) {
|
while (playing) {
|
||||||
nextBuf(NULL,outBuf,0,2,EXPORT_BUFSIZE);
|
nextBuf(NULL,outBuf,0,2,EXPORT_BUFSIZE);
|
||||||
for (int i=0; i<EXPORT_BUFSIZE; i++) {
|
for (int i=0; i<EXPORT_BUFSIZE; i++) {
|
||||||
|
@ -1979,6 +1981,7 @@ void DivEngine::runExportThread() {
|
||||||
logE("error while activating audio!\n");
|
logE("error while activating audio!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logI("done!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_EXPORT_MODE_MANY_SYS: {
|
case DIV_EXPORT_MODE_MANY_SYS: {
|
||||||
|
@ -1998,9 +2001,10 @@ void DivEngine::runExportThread() {
|
||||||
|
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
fname[i]=fmt::sprintf("%s_s%d.wav",exportPath,i+1);
|
fname[i]=fmt::sprintf("%s_s%d.wav",exportPath,i+1);
|
||||||
|
logI("- %s\n",fname[i].c_str());
|
||||||
sf[i]=sf_open(fname[i].c_str(),SFM_WRITE,&si[i]);
|
sf[i]=sf_open(fname[i].c_str(),SFM_WRITE,&si[i]);
|
||||||
if (sf[i]==NULL) {
|
if (sf[i]==NULL) {
|
||||||
logE("could not open file for writing!\n");
|
logE("could not open file for writing! (%s)\n",sf_strerror(NULL));
|
||||||
for (int j=0; j<i; j++) {
|
for (int j=0; j<i; j++) {
|
||||||
sf_close(sf[i]);
|
sf_close(sf[i]);
|
||||||
}
|
}
|
||||||
|
@ -2017,6 +2021,8 @@ void DivEngine::runExportThread() {
|
||||||
deinitAudioBackend();
|
deinitAudioBackend();
|
||||||
playSub(false);
|
playSub(false);
|
||||||
|
|
||||||
|
logI("rendering to files...\n");
|
||||||
|
|
||||||
while (playing) {
|
while (playing) {
|
||||||
nextBuf(NULL,outBuf,0,2,EXPORT_BUFSIZE);
|
nextBuf(NULL,outBuf,0,2,EXPORT_BUFSIZE);
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
|
@ -2058,6 +2064,7 @@ void DivEngine::runExportThread() {
|
||||||
logE("error while activating audio!\n");
|
logE("error while activating audio!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logI("done!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_EXPORT_MODE_MANY_CHAN: {
|
case DIV_EXPORT_MODE_MANY_CHAN: {
|
||||||
|
@ -2069,18 +2076,21 @@ void DivEngine::runExportThread() {
|
||||||
outBuf[1]=new float[EXPORT_BUFSIZE];
|
outBuf[1]=new float[EXPORT_BUFSIZE];
|
||||||
outBuf[2]=new float[EXPORT_BUFSIZE*2];
|
outBuf[2]=new float[EXPORT_BUFSIZE*2];
|
||||||
int loopCount=remainingLoops;
|
int loopCount=remainingLoops;
|
||||||
|
|
||||||
|
logI("rendering to files...\n");
|
||||||
|
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
SNDFILE* sf;
|
SNDFILE* sf;
|
||||||
SF_INFO si;
|
SF_INFO si;
|
||||||
String fname=fmt::sprintf("%s_c%d.wav",exportPath,i+1);
|
String fname=fmt::sprintf("%s_c%d.wav",exportPath,i+1);
|
||||||
|
logI("- %s\n",fname.c_str());
|
||||||
si.samplerate=got.rate;
|
si.samplerate=got.rate;
|
||||||
si.channels=2;
|
si.channels=2;
|
||||||
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
si.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16;
|
||||||
|
|
||||||
sf=sf_open(fname.c_str(),SFM_WRITE,&si);
|
sf=sf_open(fname.c_str(),SFM_WRITE,&si);
|
||||||
if (sf==NULL) {
|
if (sf==NULL) {
|
||||||
logE("could not open file for writing!\n");
|
logE("could not open file for writing! (%s)\n",sf_strerror(NULL));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2137,6 +2147,7 @@ void DivEngine::runExportThread() {
|
||||||
logE("error while activating audio!\n");
|
logE("error while activating audio!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logI("done!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3540,10 +3551,12 @@ void DivEngine::quitDispatch() {
|
||||||
|
|
||||||
bool DivEngine::initAudioBackend() {
|
bool DivEngine::initAudioBackend() {
|
||||||
// load values
|
// load values
|
||||||
if (getConfString("audioEngine","SDL")=="JACK") {
|
if (audioEngine==DIV_AUDIO_NULL) {
|
||||||
audioEngine=DIV_AUDIO_JACK;
|
if (getConfString("audioEngine","SDL")=="JACK") {
|
||||||
} else {
|
audioEngine=DIV_AUDIO_JACK;
|
||||||
audioEngine=DIV_AUDIO_SDL;
|
} else {
|
||||||
|
audioEngine=DIV_AUDIO_SDL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lowQuality=getConfInt("audioQuality",0);
|
lowQuality=getConfInt("audioQuality",0);
|
||||||
|
@ -3562,6 +3575,9 @@ bool DivEngine::initAudioBackend() {
|
||||||
case DIV_AUDIO_SDL:
|
case DIV_AUDIO_SDL:
|
||||||
output=new TAAudioSDL;
|
output=new TAAudioSDL;
|
||||||
break;
|
break;
|
||||||
|
case DIV_AUDIO_DUMMY:
|
||||||
|
output=new TAAudio;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
logE("invalid audio engine!\n");
|
logE("invalid audio engine!\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -3576,7 +3592,6 @@ bool DivEngine::initAudioBackend() {
|
||||||
|
|
||||||
output->setCallback(process,this);
|
output->setCallback(process,this);
|
||||||
|
|
||||||
logI("initializing audio.\n");
|
|
||||||
if (!output->init(want,got)) {
|
if (!output->init(want,got)) {
|
||||||
logE("error while initializing audio!\n");
|
logE("error while initializing audio!\n");
|
||||||
delete output;
|
delete output;
|
||||||
|
|
|
@ -22,7 +22,9 @@ enum DivStatusView {
|
||||||
|
|
||||||
enum DivAudioEngines {
|
enum DivAudioEngines {
|
||||||
DIV_AUDIO_JACK=0,
|
DIV_AUDIO_JACK=0,
|
||||||
DIV_AUDIO_SDL=1
|
DIV_AUDIO_SDL=1,
|
||||||
|
DIV_AUDIO_NULL=2,
|
||||||
|
DIV_AUDIO_DUMMY=3
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DivAudioExportModes {
|
enum DivAudioExportModes {
|
||||||
|
@ -518,7 +520,7 @@ class DivEngine {
|
||||||
speed1(3),
|
speed1(3),
|
||||||
speed2(3),
|
speed2(3),
|
||||||
view(DIV_STATUS_NOTHING),
|
view(DIV_STATUS_NOTHING),
|
||||||
audioEngine(DIV_AUDIO_SDL),
|
audioEngine(DIV_AUDIO_NULL),
|
||||||
samp_bbInLen(0),
|
samp_bbInLen(0),
|
||||||
samp_temp(0),
|
samp_temp(0),
|
||||||
samp_prevSample(0),
|
samp_prevSample(0),
|
||||||
|
|
33
src/main.cpp
33
src/main.cpp
|
@ -25,6 +25,8 @@ FurnaceGUI g;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
String outName;
|
String outName;
|
||||||
|
int loops=1;
|
||||||
|
DivAudioExportModes outMode=DIV_EXPORT_MODE_ONE;
|
||||||
|
|
||||||
#ifdef HAVE_GUI
|
#ifdef HAVE_GUI
|
||||||
bool consoleMode=false;
|
bool consoleMode=false;
|
||||||
|
@ -48,6 +50,10 @@ bool pHelp(String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pAudio(String val) {
|
bool pAudio(String val) {
|
||||||
|
if (outName!="") {
|
||||||
|
logE("can't use -audio and -output at the same time.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (val=="jack") {
|
if (val=="jack") {
|
||||||
e.setAudio(DIV_AUDIO_JACK);
|
e.setAudio(DIV_AUDIO_JACK);
|
||||||
} else if (val=="sdl") {
|
} else if (val=="sdl") {
|
||||||
|
@ -143,9 +149,9 @@ bool pLoops(String val) {
|
||||||
try {
|
try {
|
||||||
int count=std::stoi(val);
|
int count=std::stoi(val);
|
||||||
if (count<0) {
|
if (count<0) {
|
||||||
e.setLoops(-1);
|
loops=0;
|
||||||
} else {
|
} else {
|
||||||
e.setLoops(count+1);
|
loops=count+1;
|
||||||
}
|
}
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
logE("loop count shall be a number.\n");
|
logE("loop count shall be a number.\n");
|
||||||
|
@ -154,8 +160,23 @@ bool pLoops(String val) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool pOutMode(String val) {
|
||||||
|
if (val=="one") {
|
||||||
|
outMode=DIV_EXPORT_MODE_ONE;
|
||||||
|
} else if (val=="persys") {
|
||||||
|
outMode=DIV_EXPORT_MODE_MANY_SYS;
|
||||||
|
} else if (val=="perchan") {
|
||||||
|
outMode=DIV_EXPORT_MODE_MANY_CHAN;
|
||||||
|
} else {
|
||||||
|
logE("invalid value for outmode! valid values are: one, persys and perchan.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool pOutput(String val) {
|
bool pOutput(String val) {
|
||||||
outName=val;
|
outName=val;
|
||||||
|
e.setAudio(DIV_AUDIO_DUMMY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +199,7 @@ void initParams() {
|
||||||
params.push_back(TAParam("c","console",false,pConsole,"","enable console mode"));
|
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)"));
|
params.push_back(TAParam("l","loops",true,pLoops,"<count>","set number of loops (-1 means loop forever)"));
|
||||||
|
params.push_back(TAParam("o","outmode",true,pOutMode,"one|persys|perchan","set file output mode"));
|
||||||
|
|
||||||
params.push_back(TAParam("V","version",false,pVersion,"","view information about Furnace."));
|
params.push_back(TAParam("V","version",false,pVersion,"","view information about Furnace."));
|
||||||
params.push_back(TAParam("W","warranty",false,pWarranty,"","view warranty disclaimer."));
|
params.push_back(TAParam("W","warranty",false,pWarranty,"","view warranty disclaimer."));
|
||||||
|
@ -298,7 +320,12 @@ int main(int argc, char** argv) {
|
||||||
logE("could not initialize engine!\n");
|
logE("could not initialize engine!\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (outName!="") return 0;
|
if (outName!="") {
|
||||||
|
e.setConsoleMode(true);
|
||||||
|
e.saveAudio(outName.c_str(),loops,outMode);
|
||||||
|
e.waitAudioFile();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (consoleMode) {
|
if (consoleMode) {
|
||||||
logI("playing...\n");
|
logI("playing...\n");
|
||||||
|
|
Loading…
Reference in New Issue