Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NaNs for some dbFS value displays (-∞ dbFS) #7142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/gui/widgets/Fader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,17 @@ void Fader::updateTextFloat()
{
if (ConfigManager::inst()->value("app", "displaydbfs").toInt() && m_conversionFactor == 100.0)
{
s_textFloat->setText(QString("Volume: %1 dBFS").
arg(ampToDbfs(model()->value()), 3, 'f', 2));
QString label(tr("Volume: %1 dBFS"));

auto const modelValue = model()->value();
if (modelValue <= 0.)
{
s_textFloat->setText(label.arg("-∞"));
}
else
{
s_textFloat->setText(label.arg(ampToDbfs(modelValue), 3, 'f', 2));
}
}
else
{
Expand Down
16 changes: 11 additions & 5 deletions src/gui/widgets/FloatModelEditorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,15 @@ void FloatModelEditorBase::enterValue()
if (isVolumeKnob() &&
ConfigManager::inst()->value("app", "displaydbfs").toInt())
{
auto const initalValue = model()->getRoundedValue() / 100.0;
auto const initialDbValue = initalValue > 0. ? ampToDbfs(initalValue) : -96;

new_val = QInputDialog::getDouble(
this, tr("Set value"),
tr("Please enter a new value between "
"-96.0 dBFS and 6.0 dBFS:"),
ampToDbfs(model()->getRoundedValue() / 100.0),
-96.0, 6.0, model()->getDigitCount(), &ok);
initialDbValue, -96.0, 6.0, model()->getDigitCount(), &ok);

if (new_val <= -96.0)
{
new_val = 0.0f;
Expand Down Expand Up @@ -439,9 +442,12 @@ QString FloatModelEditorBase::displayValue() const
if (isVolumeKnob() &&
ConfigManager::inst()->value("app", "displaydbfs").toInt())
{
return m_description.trimmed() + QString(" %1 dBFS").
arg(ampToDbfs(model()->getRoundedValue() / volumeRatio()),
3, 'f', 2);
auto const valueToVolumeRatio = model()->getRoundedValue() / volumeRatio();
return m_description.trimmed() + (
valueToVolumeRatio == 0.
? QString(" -∞ dBFS")
: QString(" %1 dBFS").arg(ampToDbfs(valueToVolumeRatio), 3, 'f', 2)
);
}

return m_description.trimmed() + QString(" %1").
Expand Down
Loading