mirror of
https://github.com/tildearrow/furnace.git
synced 2025-01-05 23:21:22 +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 "engine.h"
|
||||||
#include "platform/genesis.h"
|
#include "platform/genesis.h"
|
||||||
#include "platform/genesisext.h"
|
#include "platform/genesisext.h"
|
||||||
|
@ -22,21 +23,39 @@ void DivDispatchContainer::setRates(double gotRate) {
|
||||||
blip_set_rates(bb[1],dispatch->rate,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) {
|
void DivDispatchContainer::acquire(size_t offset, size_t count) {
|
||||||
dispatch->acquire(bbIn[0],bbIn[1],offset,count);
|
dispatch->acquire(bbIn[0],bbIn[1],offset,count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivDispatchContainer::fillBuf(size_t runtotal, size_t size) {
|
void DivDispatchContainer::fillBuf(size_t runtotal, size_t size) {
|
||||||
for (size_t i=0; i<runtotal; i++) {
|
if (lowQuality) {
|
||||||
temp[0]=bbIn[0][i];
|
for (size_t i=0; i<runtotal; i++) {
|
||||||
blip_add_delta(bb[0],i,temp[0]-prevSample[0]);
|
temp[0]=bbIn[0][i];
|
||||||
prevSample[0]=temp[0];
|
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++) {
|
if (dispatch->isStereo()) for (size_t i=0; i<runtotal; i++) {
|
||||||
temp[1]=bbIn[1][i];
|
temp[1]=bbIn[1][i];
|
||||||
blip_add_delta(bb[1],i,temp[1]-prevSample[1]);
|
blip_add_delta_fast(bb[1],i,temp[1]-prevSample[1]);
|
||||||
prevSample[1]=temp[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);
|
blip_end_frame(bb[0],runtotal);
|
||||||
|
|
|
@ -3166,11 +3166,25 @@ void DivEngine::setConsoleMode(bool enable) {
|
||||||
consoleMode=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() {
|
void DivEngine::initDispatch() {
|
||||||
isBusy.lock();
|
isBusy.lock();
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
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].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].setRates(got.rate);
|
||||||
|
disCont[i].setQuality(lowQuality);
|
||||||
}
|
}
|
||||||
recalcChans();
|
recalcChans();
|
||||||
isBusy.unlock();
|
isBusy.unlock();
|
||||||
|
@ -3226,6 +3240,15 @@ void DivEngine::quitDispatch() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivEngine::initAudioBackend() {
|
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) {
|
switch (audioEngine) {
|
||||||
case DIV_AUDIO_JACK:
|
case DIV_AUDIO_JACK:
|
||||||
#ifndef HAVE_JACK
|
#ifndef HAVE_JACK
|
||||||
|
@ -3257,6 +3280,8 @@ bool DivEngine::initAudioBackend() {
|
||||||
logI("initializing audio.\n");
|
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;
|
||||||
|
output=NULL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -3301,13 +3326,6 @@ bool DivEngine::init() {
|
||||||
|
|
||||||
loadConf();
|
loadConf();
|
||||||
|
|
||||||
// load values
|
|
||||||
if (getConfString("audioEngine","SDL")=="JACK") {
|
|
||||||
audioEngine=DIV_AUDIO_JACK;
|
|
||||||
} else {
|
|
||||||
audioEngine=DIV_AUDIO_SDL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// init the rest of engine
|
// init the rest of engine
|
||||||
if (!initAudioBackend()) return false;
|
if (!initAudioBackend()) return false;
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,10 @@ struct DivDispatchContainer {
|
||||||
int temp[2], prevSample[2];
|
int temp[2], prevSample[2];
|
||||||
short* bbIn[2];
|
short* bbIn[2];
|
||||||
short* bbOut[2];
|
short* bbOut[2];
|
||||||
|
bool lowQuality;
|
||||||
|
|
||||||
void setRates(double gotRate);
|
void setRates(double gotRate);
|
||||||
|
void setQuality(bool lowQual);
|
||||||
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();
|
||||||
|
@ -100,7 +102,8 @@ struct DivDispatchContainer {
|
||||||
temp{0,0},
|
temp{0,0},
|
||||||
prevSample{0,0},
|
prevSample{0,0},
|
||||||
bbIn{NULL,NULL},
|
bbIn{NULL,NULL},
|
||||||
bbOut{NULL,NULL} {}
|
bbOut{NULL,NULL},
|
||||||
|
lowQuality(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DivEngine {
|
class DivEngine {
|
||||||
|
@ -109,6 +112,7 @@ class DivEngine {
|
||||||
TAAudioDesc want, got;
|
TAAudioDesc want, got;
|
||||||
int chans;
|
int chans;
|
||||||
bool active;
|
bool active;
|
||||||
|
bool lowQuality;
|
||||||
bool playing;
|
bool playing;
|
||||||
bool freelance;
|
bool freelance;
|
||||||
bool speedAB;
|
bool speedAB;
|
||||||
|
@ -425,6 +429,9 @@ class DivEngine {
|
||||||
// get last error
|
// get last error
|
||||||
String getLastError();
|
String getLastError();
|
||||||
|
|
||||||
|
// switch master
|
||||||
|
void switchMaster();
|
||||||
|
|
||||||
// init dispatch
|
// init dispatch
|
||||||
void initDispatch();
|
void initDispatch();
|
||||||
|
|
||||||
|
@ -443,6 +450,7 @@ class DivEngine {
|
||||||
output(NULL),
|
output(NULL),
|
||||||
chans(0),
|
chans(0),
|
||||||
active(false),
|
active(false),
|
||||||
|
lowQuality(false),
|
||||||
playing(false),
|
playing(false),
|
||||||
freelance(false),
|
freelance(false),
|
||||||
speedAB(false),
|
speedAB(false),
|
||||||
|
|
|
@ -1923,6 +1923,8 @@ void FurnaceGUI::commitSettings() {
|
||||||
|
|
||||||
e->saveConf();
|
e->saveConf();
|
||||||
|
|
||||||
|
e->switchMaster();
|
||||||
|
|
||||||
ImGui::GetIO().Fonts->Clear();
|
ImGui::GetIO().Fonts->Clear();
|
||||||
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(defFont_main_compressed_data,defFont_main_compressed_size,e->getConfInt("mainFontSize",18)*dpiScale))==NULL) {
|
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");
|
logE("could not load UI font!\n");
|
||||||
|
|
Loading…
Reference in a new issue