ES5506: add a volume scale parameter

This commit is contained in:
tildearrow 2023-02-12 02:11:03 -05:00
parent 30ce6e9ed7
commit e2e0afd18a
3 changed files with 21 additions and 3 deletions

View File

@ -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;

View File

@ -266,7 +266,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
std::queue<QueuedHostIntf> hostIntf8;
std::queue<unsigned char> queuedRead;
std::queue<QueuedReadState> queuedReadState;
int cycle, curPage;
int cycle, curPage, volScale;
unsigned char maskedVal;
unsigned int irqv;
bool isMasked, isReaded;

View File

@ -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;