mirror of
https://github.com/tildearrow/furnace.git
synced 2024-12-31 20:11:29 +00:00
dynamic audio settings changing
This commit is contained in:
parent
d6d6bf80ec
commit
6ca3c4ec4d
4 changed files with 64 additions and 17 deletions
|
@ -1,3 +1,4 @@
|
|||
#include "blip_buf.h"
|
||||
#include "engine.h"
|
||||
#include "platform/genesis.h"
|
||||
#include "platform/genesisext.h"
|
||||
|
@ -22,21 +23,39 @@ void DivDispatchContainer::setRates(double gotRate) {
|
|||
blip_set_rates(bb[1],dispatch->rate,gotRate);
|
||||
}
|
||||
|
||||
void DivDispatchContainer::setQuality(bool lowQual) {
|
||||
lowQuality=lowQual;
|
||||
}
|
||||
|
||||
void DivDispatchContainer::acquire(size_t offset, size_t count) {
|
||||
dispatch->acquire(bbIn[0],bbIn[1],offset,count);
|
||||
}
|
||||
|
||||
void DivDispatchContainer::fillBuf(size_t runtotal, size_t size) {
|
||||
for (size_t i=0; i<runtotal; i++) {
|
||||
temp[0]=bbIn[0][i];
|
||||
blip_add_delta(bb[0],i,temp[0]-prevSample[0]);
|
||||
prevSample[0]=temp[0];
|
||||
}
|
||||
if (lowQuality) {
|
||||
for (size_t i=0; i<runtotal; i++) {
|
||||
temp[0]=bbIn[0][i];
|
||||
blip_add_delta_fast(bb[0],i,temp[0]-prevSample[0]);
|
||||
prevSample[0]=temp[0];
|
||||
}
|
||||
|
||||
if (dispatch->isStereo()) for (size_t i=0; i<runtotal; i++) {
|
||||
temp[1]=bbIn[1][i];
|
||||
blip_add_delta(bb[1],i,temp[1]-prevSample[1]);
|
||||
prevSample[1]=temp[1];
|
||||
if (dispatch->isStereo()) for (size_t i=0; i<runtotal; i++) {
|
||||
temp[1]=bbIn[1][i];
|
||||
blip_add_delta_fast(bb[1],i,temp[1]-prevSample[1]);
|
||||
prevSample[1]=temp[1];
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<runtotal; i++) {
|
||||
temp[0]=bbIn[0][i];
|
||||
blip_add_delta(bb[0],i,temp[0]-prevSample[0]);
|
||||
prevSample[0]=temp[0];
|
||||
}
|
||||
|
||||
if (dispatch->isStereo()) for (size_t i=0; i<runtotal; i++) {
|
||||
temp[1]=bbIn[1][i];
|
||||
blip_add_delta(bb[1],i,temp[1]-prevSample[1]);
|
||||
prevSample[1]=temp[1];
|
||||
}
|
||||
}
|
||||
|
||||
blip_end_frame(bb[0],runtotal);
|
||||
|
|
|
@ -3166,11 +3166,25 @@ void DivEngine::setConsoleMode(bool enable) {
|
|||
consoleMode=enable;
|
||||
}
|
||||
|
||||
void DivEngine::switchMaster() {
|
||||
deinitAudioBackend();
|
||||
if (initAudioBackend()) {
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
disCont[i].setRates(got.rate);
|
||||
disCont[i].setQuality(lowQuality);
|
||||
}
|
||||
if (!output->setRun(true)) {
|
||||
logE("error while activating audio!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DivEngine::initDispatch() {
|
||||
isBusy.lock();
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
disCont[i].init(song.system[i],this,getChannelCount(song.system[i]),got.rate,(!song.pal) || (song.customTempo!=0 && song.hz<53));
|
||||
disCont[i].setRates(got.rate);
|
||||
disCont[i].setQuality(lowQuality);
|
||||
}
|
||||
recalcChans();
|
||||
isBusy.unlock();
|
||||
|
@ -3226,6 +3240,15 @@ void DivEngine::quitDispatch() {
|
|||
}
|
||||
|
||||
bool DivEngine::initAudioBackend() {
|
||||
// load values
|
||||
if (getConfString("audioEngine","SDL")=="JACK") {
|
||||
audioEngine=DIV_AUDIO_JACK;
|
||||
} else {
|
||||
audioEngine=DIV_AUDIO_SDL;
|
||||
}
|
||||
|
||||
lowQuality=getConfInt("audioQuality",0);
|
||||
|
||||
switch (audioEngine) {
|
||||
case DIV_AUDIO_JACK:
|
||||
#ifndef HAVE_JACK
|
||||
|
@ -3257,6 +3280,8 @@ bool DivEngine::initAudioBackend() {
|
|||
logI("initializing audio.\n");
|
||||
if (!output->init(want,got)) {
|
||||
logE("error while initializing audio!\n");
|
||||
delete output;
|
||||
output=NULL;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -3301,13 +3326,6 @@ bool DivEngine::init() {
|
|||
|
||||
loadConf();
|
||||
|
||||
// load values
|
||||
if (getConfString("audioEngine","SDL")=="JACK") {
|
||||
audioEngine=DIV_AUDIO_JACK;
|
||||
} else {
|
||||
audioEngine=DIV_AUDIO_SDL;
|
||||
}
|
||||
|
||||
// init the rest of engine
|
||||
if (!initAudioBackend()) return false;
|
||||
|
||||
|
|
|
@ -86,8 +86,10 @@ struct DivDispatchContainer {
|
|||
int temp[2], prevSample[2];
|
||||
short* bbIn[2];
|
||||
short* bbOut[2];
|
||||
bool lowQuality;
|
||||
|
||||
void setRates(double gotRate);
|
||||
void setQuality(bool lowQual);
|
||||
void acquire(size_t offset, size_t count);
|
||||
void fillBuf(size_t runtotal, size_t size);
|
||||
void clear();
|
||||
|
@ -100,7 +102,8 @@ struct DivDispatchContainer {
|
|||
temp{0,0},
|
||||
prevSample{0,0},
|
||||
bbIn{NULL,NULL},
|
||||
bbOut{NULL,NULL} {}
|
||||
bbOut{NULL,NULL},
|
||||
lowQuality(false) {}
|
||||
};
|
||||
|
||||
class DivEngine {
|
||||
|
@ -109,6 +112,7 @@ class DivEngine {
|
|||
TAAudioDesc want, got;
|
||||
int chans;
|
||||
bool active;
|
||||
bool lowQuality;
|
||||
bool playing;
|
||||
bool freelance;
|
||||
bool speedAB;
|
||||
|
@ -424,6 +428,9 @@ class DivEngine {
|
|||
|
||||
// get last error
|
||||
String getLastError();
|
||||
|
||||
// switch master
|
||||
void switchMaster();
|
||||
|
||||
// init dispatch
|
||||
void initDispatch();
|
||||
|
@ -443,6 +450,7 @@ class DivEngine {
|
|||
output(NULL),
|
||||
chans(0),
|
||||
active(false),
|
||||
lowQuality(false),
|
||||
playing(false),
|
||||
freelance(false),
|
||||
speedAB(false),
|
||||
|
|
|
@ -1923,6 +1923,8 @@ void FurnaceGUI::commitSettings() {
|
|||
|
||||
e->saveConf();
|
||||
|
||||
e->switchMaster();
|
||||
|
||||
ImGui::GetIO().Fonts->Clear();
|
||||
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(defFont_main_compressed_data,defFont_main_compressed_size,e->getConfInt("mainFontSize",18)*dpiScale))==NULL) {
|
||||
logE("could not load UI font!\n");
|
||||
|
|
Loading…
Reference in a new issue