Skip to content
Open
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
25 changes: 0 additions & 25 deletions include/lmms_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,31 +323,6 @@ inline float safeDbfsToAmp(float dbfs)
}


// TODO C++20: use std::formatted_size
// @brief Calculate number of digits which LcdSpinBox would show for a given number
inline int numDigitsAsInt(float f)
{
// use rounding:
// LcdSpinBox sometimes uses std::round(), sometimes cast rounding
// we use rounding to be on the "safe side"
int asInt = static_cast<int>(std::round(f));
int digits = 1; // always at least 1
if(asInt < 0)
{
++digits;
asInt = -asInt;
}
// "asInt" is positive from now
int power = 1;
for (int i = 1; i < 10; ++i)
{
power *= 10;
if (asInt >= power) { ++digits; } // 2 digits for >=10, 3 for >=100
else { break; }
}
return digits;
}

template <typename T>
class LinearMap
{
Expand Down
10 changes: 6 additions & 4 deletions src/gui/Lv2ViewBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#ifdef LMMS_HAVE_LV2

#include <format>
#include <QGridLayout>
#include <QPushButton>
#include <QHBoxLayout>
Expand Down Expand Up @@ -74,10 +75,11 @@ Lv2ViewProc::Lv2ViewProc(QWidget* parent, Lv2Proc* proc, int colNum) :
break;
case PortVis::Integer:
{
sample_rate_t sr = Engine::audioEngine()->outputSampleRate();
auto pMin = port.min(sr);
auto pMax = port.max(sr);
int numDigits = std::max(numDigitsAsInt(pMin), numDigitsAsInt(pMax));
const sample_rate_t sr = Engine::audioEngine()->outputSampleRate();
const auto numDigits = std::max(
std::formatted_size("{}", static_cast<long>(std::round(port.min(sr)))),
std::formatted_size("{}", static_cast<long>(std::round(port.max(sr))))
);
m_control = new LcdControl(numDigits, m_parent);
break;
}
Expand Down
1 change: 0 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set(LMMS_TESTS
src/core/ArrayVectorTest.cpp
src/core/AudioBufferTest.cpp
src/core/AutomatableModelTest.cpp
src/core/MathTest.cpp
src/core/ProjectVersionTest.cpp
src/core/RelativePathsTest.cpp
src/core/TimelineTest.cpp
Expand Down
53 changes: 0 additions & 53 deletions tests/src/core/MathTest.cpp

This file was deleted.

Loading