fixed and enhanced audio frequency display in debugger

This commit is contained in:
Thomas Jentzsch 2021-12-21 11:25:17 +01:00
parent bfc59ddcc3
commit bdabbf9aa0
4 changed files with 54 additions and 19 deletions

View File

@ -1007,20 +1007,33 @@ string TIADebug::colorSwatch(uInt8 c) const
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// FIXME - how does this work; is this even needed ??
// convert to stringstream, get rid of snprintf
string TIADebug::audFreq(uInt8 div)
string TIADebug::audFreq0()
{
string ret;
std::array<char, 10> buf;
return audFreq(audC0(), audF0());
}
double hz = 31400.0;
if(div) hz /= div;
std::snprintf(buf.data(), 9, "%5.1f", hz);
ret += buf.data();
ret += "Hz";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::audFreq1()
{
return audFreq(audC1(), audF1());
}
return ret;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::audFreq(uInt8 dist, uInt8 div)
{
uInt16 dist_div[16] = {
1, 15, 465, 465, 2, 2, 31, 31,
511, 31, 31, 1, 6, 6, 93, 93
};
const double hz =
(myConsole.timing() == ConsoleTiming::ntsc ? 31440.0 : 31200.0)
/ dist_div[dist] / (div + 1);
ostringstream buf;
buf.setf(std::ios_base::fixed, std::ios_base::floatfield);
buf << std::setw(7) << std::setprecision(1) << hz << "Hz";
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1302,7 +1315,7 @@ string TIADebug::toString()
<< "AUDF0: "
<< hexWithLabel("", int(audF0()),
state.aud[0] != oldState.aud[0]) << "/"
<< std::setw(11) << std::right << stringOnly(audFreq(audF0()),
<< std::setw(11) << std::right << stringOnly(audFreq0(),
state.aud[0] != oldState.aud[0]) << " "
<< "AUDC0: "
<< hexWithLabel("", int(audC0()),
@ -1314,7 +1327,7 @@ string TIADebug::toString()
<< "AUDF1: "
<< hexWithLabel("", int(audF1()),
state.aud[1] != oldState.aud[1]) << "/"
<< std::setw(11) << std::right << stringOnly(audFreq(audF1()),
<< std::setw(11) << std::right << stringOnly(audFreq1(),
state.aud[1] != oldState.aud[1]) << " "
<< "AUDC1: "
<< hexWithLabel("", int(audC1()),

View File

@ -106,6 +106,8 @@ class TIADebug : public DebuggerSystem
uInt8 audF1(int newVal = -1);
uInt8 audV0(int newVal = -1);
uInt8 audV1(int newVal = -1);
string audFreq0();
string audFreq1();
void setGRP0Old(uInt8 b);
void setGRP1Old(uInt8 b);
@ -185,7 +187,7 @@ class TIADebug : public DebuggerSystem
/** Display a color patch for color at given index in the palette */
string colorSwatch(uInt8 c) const;
string audFreq(uInt8 div);
string audFreq(uInt8 dist, uInt8 div);
string stringOnly(string value, bool changed = false);
string decWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 3);
string hexWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 2);

View File

@ -49,6 +49,12 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
myAudF->setTarget(this);
myAudF->setID(kAUDFID);
addFocusWidget(myAudF);
myAud0F = new StaticTextWidget(boss, lfont,
myAudF->getRight() + fontWidth, ypos + (lineHeight + 5)/ 2 + 2, " ");
new StaticTextWidget(boss, lfont,
myAud0F->getRight(), ypos + (lineHeight + 5)/ 2 + 2, "/");
myAud1F = new StaticTextWidget(boss, lfont,
myAud0F->getRight() + fontWidth, ypos + (lineHeight + 5)/ 2 + 2, " ");
for(int col = 0; col < 2; ++col)
{
@ -57,7 +63,6 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
Common::Base::toString(col, Common::Base::Fmt::_16_1),
TextAlign::Left);
}
// AudC registers
xpos = 10; ypos += lineHeight + 5;
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
@ -80,7 +85,8 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
myAudV->setID(kAUDVID);
addFocusWidget(myAudV);
myAudEffV = new StaticTextWidget(boss, lfont, myAudV->getRight() + fontWidth, myAudV->getTop() + 2,
myAudEffV = new StaticTextWidget(boss, lfont,
myAudV->getRight() + fontWidth * 2, myAudV->getTop() + 2,
"100% (eff. volume)");
setHelpAnchor("AudioTab", true);
@ -128,9 +134,18 @@ void AudioWidget::loadConfig()
}
myAudV->setList(alist, vlist, changed);
handleFrequencies();
handleVolume();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::handleFrequencies()
{
myAud0F->setLabel(instance().debugger().tiaDebug().audFreq0());
myAud1F->setLabel(instance().debugger().tiaDebug().audFreq1());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::handleVolume()
{
@ -185,6 +200,7 @@ void AudioWidget::changeFrequencyRegs()
default:
break;
}
handleFrequencies();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -206,6 +222,7 @@ void AudioWidget::changeControlRegs()
default:
break;
}
handleFrequencies();
handleVolume();
}

View File

@ -40,9 +40,11 @@ class AudioWidget : public Widget, public CommandSender
kAUDVID
};
DataGridWidget* myAudF{nullptr};
DataGridWidget* myAudC{nullptr};
DataGridWidget* myAudV{nullptr};
DataGridWidget* myAudF{nullptr};
StaticTextWidget* myAud0F{nullptr};
StaticTextWidget* myAud1F{nullptr};
DataGridWidget* myAudC{nullptr};
DataGridWidget* myAudV{nullptr};
StaticTextWidget* myAudEffV{nullptr};
// Audio channels
@ -59,6 +61,7 @@ class AudioWidget : public Widget, public CommandSender
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
void loadConfig() override;
void handleFrequencies();
void handleVolume();
uInt32 getEffectiveVolume();