add "force mono audio" option and fix flags not be

ing set after a dispatch reset
This commit is contained in:
tildearrow 2022-02-04 17:04:36 -05:00
parent 16f497fcf1
commit a93a9c19f3
6 changed files with 22 additions and 3 deletions

View file

@ -88,7 +88,7 @@ void DivDispatchContainer::clear() {
prevSample[1]=temp[1];*/ prevSample[1]=temp[1];*/
} }
void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, double gotRate, bool pal) { void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, double gotRate, unsigned int flags) {
if (dispatch!=NULL) return; if (dispatch!=NULL) return;
bb[0]=blip_new(32768); bb[0]=blip_new(32768);
@ -170,7 +170,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
dispatch=new DivPlatformDummy; dispatch=new DivPlatformDummy;
break; break;
} }
dispatch->init(eng,chanCount,gotRate,pal); dispatch->init(eng,chanCount,gotRate,flags);
} }
void DivDispatchContainer::quit() { void DivDispatchContainer::quit() {

View file

@ -5993,6 +5993,7 @@ bool DivEngine::initAudioBackend() {
} }
lowQuality=getConfInt("audioQuality",0); lowQuality=getConfInt("audioQuality",0);
forceMono=getConfInt("forceMono",0);
switch (audioEngine) { switch (audioEngine) {
case DIV_AUDIO_JACK: case DIV_AUDIO_JACK:

View file

@ -116,7 +116,7 @@ struct DivDispatchContainer {
void acquire(size_t offset, size_t count); void acquire(size_t offset, size_t count);
void fillBuf(size_t runtotal, size_t size); void fillBuf(size_t runtotal, size_t size);
void clear(); void clear();
void init(DivSystem sys, DivEngine* eng, int chanCount, double gotRate, bool pal); void init(DivSystem sys, DivEngine* eng, int chanCount, double gotRate, unsigned int flags);
void quit(); void quit();
DivDispatchContainer(): DivDispatchContainer():
dispatch(NULL), dispatch(NULL),
@ -148,6 +148,7 @@ class DivEngine {
bool metronome; bool metronome;
bool exporting; bool exporting;
bool halted; bool halted;
bool forceMono;
int ticks, curRow, curOrder, remainingLoops, nextSpeed, divider; int ticks, curRow, curOrder, remainingLoops, nextSpeed, divider;
int cycles, clockDrift; int cycles, clockDrift;
int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch; int changeOrd, changePos, totalSeconds, totalTicks, totalTicksR, totalCmds, lastCmds, cmdsPerSecond, globalPitch;
@ -568,6 +569,7 @@ class DivEngine {
metronome(false), metronome(false),
exporting(false), exporting(false),
halted(false), halted(false),
forceMono(false),
ticks(0), ticks(0),
curRow(0), curRow(0),
curOrder(0), curOrder(0),

View file

@ -1192,5 +1192,12 @@ void DivEngine::nextBuf(float** in, float** out, int inChans, int outChans, unsi
memcpy(oscBuf[0],out[0],size*sizeof(float)); memcpy(oscBuf[0],out[0],size*sizeof(float));
memcpy(oscBuf[1],out[1],size*sizeof(float)); memcpy(oscBuf[1],out[1],size*sizeof(float));
oscSize=size; oscSize=size;
if (forceMono) {
for (size_t i=0; i<size; i++) {
out[0][i]=(out[0][i]+out[1][i])*0.5;
out[1][i]=out[0][i];
}
}
isBusy.unlock(); isBusy.unlock();
} }

View file

@ -2968,6 +2968,11 @@ void FurnaceGUI::drawSettings() {
ImGui::SameLine(); ImGui::SameLine();
ImGui::Combo("##Quality",&settings.audioQuality,audioQualities,2); ImGui::Combo("##Quality",&settings.audioQuality,audioQualities,2);
bool forceMonoB=settings.forceMono;
if (ImGui::Checkbox("Force mono audio",&forceMonoB)) {
settings.forceMono=forceMonoB;
}
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Emulation")) { if (ImGui::BeginTabItem("Emulation")) {
@ -3193,6 +3198,7 @@ void FurnaceGUI::syncSettings() {
settings.stepOnDelete=e->getConfInt("stepOnDelete",0); settings.stepOnDelete=e->getConfInt("stepOnDelete",0);
settings.scrollStep=e->getConfInt("scrollStep",0); settings.scrollStep=e->getConfInt("scrollStep",0);
settings.sysSeparators=e->getConfInt("sysSeparators",1); settings.sysSeparators=e->getConfInt("sysSeparators",1);
settings.forceMono=e->getConfInt("forceMono",0);
} }
#define PUT_UI_COLOR(source) e->setConf(#source,(int)ImGui::GetColorU32(uiColors[source])); #define PUT_UI_COLOR(source) e->setConf(#source,(int)ImGui::GetColorU32(uiColors[source]));
@ -3227,6 +3233,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("stepOnDelete",settings.stepOnDelete); e->setConf("stepOnDelete",settings.stepOnDelete);
e->setConf("scrollStep",settings.scrollStep); e->setConf("scrollStep",settings.scrollStep);
e->setConf("sysSeparators",settings.sysSeparators); e->setConf("sysSeparators",settings.sysSeparators);
e->setConf("forceMono",settings.forceMono);
PUT_UI_COLOR(GUI_COLOR_BACKGROUND); PUT_UI_COLOR(GUI_COLOR_BACKGROUND);
PUT_UI_COLOR(GUI_COLOR_FRAME_BACKGROUND); PUT_UI_COLOR(GUI_COLOR_FRAME_BACKGROUND);

View file

@ -217,6 +217,7 @@ class FurnaceGUI {
int stepOnDelete; int stepOnDelete;
int scrollStep; int scrollStep;
int sysSeparators; int sysSeparators;
int forceMono;
unsigned int maxUndoSteps; unsigned int maxUndoSteps;
String mainFontPath; String mainFontPath;
String patFontPath; String patFontPath;
@ -249,6 +250,7 @@ class FurnaceGUI {
stepOnDelete(0), stepOnDelete(0),
scrollStep(0), scrollStep(0),
sysSeparators(1), sysSeparators(1),
forceMono(0),
maxUndoSteps(100), maxUndoSteps(100),
mainFontPath(""), mainFontPath(""),
patFontPath("") {} patFontPath("") {}