From e2e0afd18a0d8c6ef58239b2dfadb56312700a89 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 12 Feb 2023 02:11:03 -0500 Subject: [PATCH] ES5506: add a volume scale parameter --- src/engine/platform/es5506.cpp | 12 ++++++++++-- src/engine/platform/es5506.h | 2 +- src/gui/sysConf.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index 8e149e1a..2c395db3 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -385,13 +385,19 @@ void DivPlatformES5506::tick(bool sysTick) { if (chan[i].volChanged.changed) { // calculate volume (16 bit) if (chan[i].volChanged.lVol) { - chan[i].resLVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outLVol,0xfff)<<4; + chan[i].resLVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outLVol,0xfff); + chan[i].resLVol-=volScale; + if (chan[i].resLVol<0) chan[i].resLVol=0; + chan[i].resLVol<<=4; if (!chan[i].keyOn && chan[i].active) { pageWrite(0x00|i,0x02,chan[i].resLVol); } } if (chan[i].volChanged.rVol) { - chan[i].resRVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outRVol,0xfff)<<4; + chan[i].resRVol=VOL_SCALE_LOG(chan[i].outVol,chan[i].outRVol,0xfff); + chan[i].resRVol-=volScale; + if (chan[i].resRVol<0) chan[i].resRVol=0; + chan[i].resRVol<<=4; if (!chan[i].keyOn && chan[i].active) { pageWrite(0x00|i,0x04,chan[i].resRVol); } @@ -1152,6 +1158,7 @@ void DivPlatformES5506::setFlags(const DivConfig& flags) { CHECK_CUSTOM_CLOCK; initChanMax=MAX(4,flags.getInt("channels",0x1f)&0x1f); + volScale=4095-flags.getInt("volScale",4095); chanMax=initChanMax; pageWriteMask(0x00,0x60,0x0b,chanMax); @@ -1251,6 +1258,7 @@ int DivPlatformES5506::init(DivEngine* p, int channels, int sugRate, const DivCo parent=p; dumpWrites=false; skipRegisterWrites=false; + volScale=0; for (int i=0; i<32; i++) { isMuted[i]=false; diff --git a/src/engine/platform/es5506.h b/src/engine/platform/es5506.h index 2df07b77..56a1f629 100644 --- a/src/engine/platform/es5506.h +++ b/src/engine/platform/es5506.h @@ -266,7 +266,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf { std::queue hostIntf8; std::queue queuedRead; std::queue queuedReadState; - int cycle, curPage; + int cycle, curPage, volScale; unsigned char maskedVal; unsigned int irqv; bool isMasked, isReaded; diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index b3783ddf..f19e9481 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -883,6 +883,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo } case DIV_SYSTEM_ES5506: { int channels=flags.getInt("channels",0x1f)+1; + int volScale=flags.getInt("volScale",4095); ImGui::Text("Initial channel limit:"); if (CWSliderInt("##OTTO_InitialChannelLimit",&channels,5,32)) { if (channels<5) channels=5; @@ -890,9 +891,18 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo altered=true; } rightClickable + ImGui::Text("Volume scale:"); + + if (CWSliderInt("##VolScaleO",&volScale,0,4095)) { + if (volScale<0) volScale=0; + if (volScale>4095) volScale=4095; + altered=true; + } rightClickable + if (altered) { e->lockSave([&]() { flags.set("channels",channels-1); + flags.set("volScale",volScale); }); } break;