Update math functions to C++ standard library (#7685)

* use c++ std::* math functions
This updates usages of sin, cos, tan, pow, exp, log, log10, sqrt, fmod, fabs, and fabsf,
excluding any usages that look like they might be part of a submodule or 3rd-party code.
There's probably some std math functions not listed here that haven't been updated yet.

* fix std::sqrt typo

lmao one always sneaks by

* Apply code review suggestions
- std::pow(2, x) -> std::exp2(x)
- std::pow(10, x) -> lmms::fastPow10f(x)
- std::pow(x, 2) -> x * x, std::pow(x, 3) -> x * x * x, etc.
- Resolve TODOs, fix typos, and so forth

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>

* Fix double -> float truncation, DrumSynth fix

I mistakenly introduced a bug in my recent PR regarding template
constants, in which a -1 that was supposed to appear outside of an abs()
instead was moved inside it, screwing up the generated waveform. I fixed
that and also simplified the function by factoring out the phase domain
wrapping using the new `ediv()` function from this PR. It should behave
how it's supposed to now... assuming all my parentheses are in the right
place lol

* Annotate magic numbers with TODOs for C++20

* On second thought, why wait?

What else is lmms::numbers for?

* begone inline

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>

* begone other inline

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>

* Re-inline function in lmms_math.h

For functions, constexpr implies inline so this just re-adds inline to
the one that isn't constexpr yet

* Formatting fixes, readability improvements

Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>

* Fix previously missed pow() calls, cleanup

Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>

* Just delete ediv() entirely lmao

No ediv(), no std::fmod(), no std::remainder(), just std::floor().
It should all work for negative phase inputs as well. If I end up
needing ediv() in the future, I can add it then.

* Simplify DrumSynth triangle waveform

This reuses more work and is also a lot more easy to visualize.

It's probably a meaningless micro-optimization, but it might be worth changing it back to a switch-case and just calculating ph_tau and saw01 at the beginning of the function in all code paths, even if it goes unused for the first two cases. Guess I'll see if anybody has strong opinions about it.

* Move multiplication inside abs()

* Clean up a few more pow(x, 2) -> x * x

* Remove numbers::inv_pi, numbers::inv_tau

* delete spooky leading 0

Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>

---------

Co-authored-by: Rossmaxx <74815851+Rossmaxx@users.noreply.github.com>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This commit is contained in:
Fawn
2025-02-08 21:50:02 -07:00
committed by GitHub
parent cb7c6d16cb
commit 4a089a19dc
48 changed files with 256 additions and 295 deletions

View File

@@ -647,8 +647,7 @@ float AutomationClip::valueAt( timeMap::const_iterator v, int offset ) const
float m1 = OUTTAN(v) * numValues * m_tension;
float m2 = INTAN(v + 1) * numValues * m_tension;
auto t2 = pow(t, 2);
auto t3 = pow(t, 3);
auto t2 = t * t, t3 = t2 * t;
return (2 * t3 - 3 * t2 + 1) * OUTVAL(v)
+ (t3 - 2 * t2 + t) * m1
+ (-2 * t3 + 3 * t2) * INVAL(v + 1)

View File

@@ -42,7 +42,6 @@ namespace lmms {
using namespace std;
// const int Fs = 44100;
const float TwoPi = 6.2831853f;
const int MAX = 0;
const int ENV = 1;
const int PNT = 2;
@@ -172,37 +171,19 @@ void DrumSynth::GetEnv(int env, const char* sec, const char* key, QString ini)
float DrumSynth::waveform(float ph, int form)
{
float w;
switch (form)
{
case 0:
w = static_cast<float>(sin(fmod(ph, TwoPi)));
break; // sine
case 1:
w = static_cast<float>(fabs(2.0f * static_cast<float>(sin(fmod(0.5f * ph, TwoPi))) - 1.f));
break; // sine^2
case 2:
while (ph < TwoPi)
{
ph += TwoPi;
}
w = 0.6366197f * static_cast<float>(fmod(ph, TwoPi) - 1.f); // tri
if (w > 1.f)
{
w = 2.f - w;
}
break;
case 3:
w = ph - TwoPi * static_cast<float>(static_cast<int>(ph / TwoPi)); // saw
w = (0.3183098f * w) - 1.f;
break;
default:
w = (sin(fmod(ph, TwoPi)) > 0.0) ? 1.f : -1.f;
break; // square
}
return w;
// sine
if (form == 0) { return std::sin(ph); }
// sine^2
if (form == 1) { return std::abs(2.f * std::sin(0.5f * ph)) - 1.f; }
// sawtooth with range [0, 1], used to generate triangle, sawtooth, and square
auto ph_tau = ph / numbers::tau_v<float>;
auto saw01 = ph_tau - std::floor(ph_tau);
// triangle
if (form == 2) { return 1.f - 4.f * std::abs(saw01 - 0.5f); }
// sawtooth
if (form == 3) { return 2.f * saw01 - 1.f; }
// square
return (saw01 < 0.5f) ? 1.f : -1.f;
}
int DrumSynth::GetPrivateProfileString(
@@ -434,7 +415,7 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
{
a = 1.f;
b = -NT / 50.f;
c = static_cast<float>(fabs(static_cast<float>(NT))) / 100.f;
c = std::abs(static_cast<float>(NT)) / 100.f;
g = NL;
}
@@ -448,19 +429,19 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
sliLev[0] = GetPrivateProfileInt(sec, "Level", 128, dsfile);
TL = static_cast<float>(sliLev[0] * sliLev[0]) * mem_t;
GetEnv(1, sec, "Envelope", dsfile);
F1 = MasterTune * TwoPi * GetPrivateProfileFloat(sec, "F1", 200.0, dsfile) / Fs;
if (fabs(F1) < 0.001f)
F1 = MasterTune * numbers::tau_v<float> * GetPrivateProfileFloat(sec, "F1", 200.0, dsfile) / Fs;
if (std::abs(F1) < 0.001f)
{
F1 = 0.001f; // to prevent overtone ratio div0
}
F2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec, "F2", 120.0, dsfile) / Fs;
F2 = MasterTune * numbers::tau_v<float> * GetPrivateProfileFloat(sec, "F2", 120.0, dsfile) / Fs;
TDroopRate = GetPrivateProfileFloat(sec, "Droop", 0.f, dsfile);
if (TDroopRate > 0.f)
{
TDroopRate = fastPow10f((TDroopRate - 20.0f) / 30.0f);
TDroopRate = TDroopRate * -4.f / envData[1][MAX];
TDroop = 1;
F2 = F1 + ((F2 - F1) / (1.f - static_cast<float>(exp(TDroopRate * envData[1][MAX]))));
F2 = F1 + ((F2 - F1) / (1.f - std::exp(TDroopRate * envData[1][MAX])));
ddF = F1 - F2;
}
else
@@ -479,8 +460,8 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
GetEnv(3, sec, "Envelope1", dsfile);
GetEnv(4, sec, "Envelope2", dsfile);
OMode = GetPrivateProfileInt(sec, "Method", 2, dsfile);
OF1 = MasterTune * TwoPi * GetPrivateProfileFloat(sec, "F1", 200.0, dsfile) / Fs;
OF2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec, "F2", 120.0, dsfile) / Fs;
OF1 = MasterTune * numbers::tau_v<float> * GetPrivateProfileFloat(sec, "F1", 200.0, dsfile) / Fs;
OF2 = MasterTune * numbers::tau_v<float> * GetPrivateProfileFloat(sec, "F2", 120.0, dsfile) / Fs;
OW1 = GetPrivateProfileInt(sec, "Wave1", 0, dsfile);
OW2 = GetPrivateProfileInt(sec, "Wave2", 0, dsfile);
OBal2 = static_cast<float>(GetPrivateProfileInt(sec, "Param", 50, dsfile));
@@ -508,8 +489,8 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
OcQ = OcA * OcA;
OcF = (1.8f - 0.7f * OcQ) * 0.92f; // multiply by env 2
OcA *= 1.0f + 4.0f * OBal1; // level is a compromise!
Ocf1 = TwoPi / OF1;
Ocf2 = TwoPi / OF2;
Ocf1 = numbers::tau_v<float> / OF1;
Ocf2 = numbers::tau_v<float> / OF2;
for (i = 0; i < 6; i++)
{
Oc[i][0] = Oc[i][1] = Ocf1 + (Ocf2 - Ocf1) * 0.2f * static_cast<float>(i);
@@ -521,12 +502,12 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
BON = chkOn[3];
sliLev[3] = GetPrivateProfileInt(sec, "Level", 128, dsfile);
BL = static_cast<float>(sliLev[3] * sliLev[3]) * mem_b;
BF = MasterTune * TwoPi * GetPrivateProfileFloat(sec, "F", 1000.0, dsfile) / Fs;
BPhi = TwoPi / 8.f;
BF = MasterTune * numbers::tau_v<float> * GetPrivateProfileFloat(sec, "F", 1000.0, dsfile) / Fs;
BPhi = numbers::tau_v<float> / 8.f;
GetEnv(5, sec, "Envelope", dsfile);
BFStep = GetPrivateProfileInt(sec, "dF", 50, dsfile);
BQ = static_cast<float>(BFStep);
BQ = BQ * BQ / (10000.f - 6600.f * (static_cast<float>(sqrt(BF)) - 0.19f));
BQ = BQ * BQ / (10000.f - 6600.f * (std::sqrt(BF) - 0.19f));
BFStep = 1 + static_cast<int>((40.f - (BFStep / 2.5f)) / (BQ + 1.f + (1.f * BF)));
strcpy(sec, "NoiseBand2");
@@ -534,12 +515,12 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
BON2 = chkOn[4];
sliLev[4] = GetPrivateProfileInt(sec, "Level", 128, dsfile);
BL2 = static_cast<float>(sliLev[4] * sliLev[4]) * mem_b;
BF2 = MasterTune * TwoPi * GetPrivateProfileFloat(sec, "F", 1000.0, dsfile) / Fs;
BPhi2 = TwoPi / 8.f;
BF2 = MasterTune * numbers::tau_v<float> * GetPrivateProfileFloat(sec, "F", 1000.0, dsfile) / Fs;
BPhi2 = numbers::tau_v<float> / 8.f;
GetEnv(6, sec, "Envelope", dsfile);
BFStep2 = GetPrivateProfileInt(sec, "dF", 50, dsfile);
BQ2 = static_cast<float>(BFStep2);
BQ2 = BQ2 * BQ2 / (10000.f - 6600.f * (static_cast<float>(sqrt(BF2)) - 0.19f));
BQ2 = BQ2 * BQ2 / (10000.f - 6600.f * (std::sqrt(BF2) - 0.19f));
BFStep2 = 1 + static_cast<int>((40 - (BFStep2 / 2.5)) / (BQ2 + 1 + (1 * BF2)));
// read distortion parameters
@@ -659,7 +640,7 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
{
for (t = tpos; t <= tplus; t++)
{
phi[t - tpos] = F2 + (ddF * static_cast<float>(exp(t * TDroopRate)));
phi[t - tpos] = F2 + (ddF * std::exp(t * TDroopRate));
}
}
else
@@ -681,7 +662,7 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
UpdateEnv(1, t);
}
Tphi = Tphi + phi[totmp];
DF[totmp] += TL * envData[1][ENV] * static_cast<float>(sin(fmod(Tphi, TwoPi))); // overflow?
DF[totmp] += TL * envData[1][ENV] * std::sin(std::fmod(Tphi, numbers::tau_v<float>)); // overflow?
}
if (t >= envData[1][MAX])
{
@@ -714,7 +695,7 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
}
BPhi = BPhi + BF + BQ * BdF;
botmp = t - tpos;
DF[botmp] = DF[botmp] + static_cast<float>(cos(fmod(BPhi, TwoPi))) * envData[5][ENV] * BL;
DF[botmp] = DF[botmp] + std::cos(std::fmod(BPhi, numbers::tau_v<float>)) * envData[5][ENV] * BL;
}
if (t >= envData[5][MAX])
{
@@ -740,7 +721,7 @@ int DrumSynth::GetDSFileSamples(QString dsfile, int16_t*& wave, int channels, sa
}
BPhi2 = BPhi2 + BF2 + BQ2 * BdF2;
botmp = t - tpos;
DF[botmp] = DF[botmp] + static_cast<float>(cos(fmod(BPhi2, TwoPi))) * envData[6][ENV] * BL2;
DF[botmp] = DF[botmp] + std::cos(std::fmod(BPhi2, numbers::tau_v<float>)) * envData[6][ENV] * BL2;
}
if (t >= envData[6][MAX])
{

View File

@@ -436,8 +436,8 @@ float LadspaManager::getDefaultSetting( const ladspa_key_t & _plugin,
if( LADSPA_IS_HINT_LOGARITHMIC
( hintDescriptor ) )
{
return( exp( log( portRangeHint->LowerBound ) * 0.75 +
log( portRangeHint->UpperBound ) * 0.25 ) );
return std::exp(std::log(portRangeHint->LowerBound)
* 0.75 + std::log(portRangeHint->UpperBound) * 0.25);
}
else
{
@@ -448,8 +448,7 @@ float LadspaManager::getDefaultSetting( const ladspa_key_t & _plugin,
if( LADSPA_IS_HINT_LOGARITHMIC
( hintDescriptor ) )
{
return( sqrt( portRangeHint->LowerBound
* portRangeHint->UpperBound ) );
return std::sqrt(portRangeHint->LowerBound * portRangeHint->UpperBound);
}
else
{
@@ -460,8 +459,8 @@ float LadspaManager::getDefaultSetting( const ladspa_key_t & _plugin,
if( LADSPA_IS_HINT_LOGARITHMIC
( hintDescriptor ) )
{
return( exp( log( portRangeHint->LowerBound ) * 0.25 +
log( portRangeHint->UpperBound ) * 0.75 ) );
return std::exp(std::log(portRangeHint->LowerBound)
* 0.25 + std::log(portRangeHint->UpperBound) * 0.75);
}
else
{

View File

@@ -102,10 +102,10 @@ float Microtuner::keyToFreq(int key, int userBaseNote) const
// Compute frequency of the middle note and return the final frequency
const double octaveRatio = intervals[octaveDegree].getRatio();
const float middleFreq = (keymap->getBaseFreq() / pow(octaveRatio, (baseScaleOctave + baseKeymapOctave)))
/ intervals[baseScaleDegree].getRatio();
const float middleFreq = (keymap->getBaseFreq() / std::pow(octaveRatio, baseScaleOctave + baseKeymapOctave))
/ intervals[baseScaleDegree].getRatio();
return middleFreq * intervals[scaleDegree].getRatio() * pow(octaveRatio, keymapOctave + scaleOctave);
return middleFreq * intervals[scaleDegree].getRatio() * std::pow(octaveRatio, keymapOctave + scaleOctave);
}
int Microtuner::octaveSize() const

View File

@@ -71,7 +71,7 @@ bool isSilent( const SampleFrame* src, int frames )
for( int i = 0; i < frames; ++i )
{
if( fabsf( src[i][0] ) >= silenceThreshold || fabsf( src[i][1] ) >= silenceThreshold )
if (std::abs(src[i][0]) >= silenceThreshold || std::abs(src[i][1]) >= silenceThreshold)
{
return false;
}

View File

@@ -532,8 +532,8 @@ void NotePlayHandle::updateFrequency()
if (m_instrumentTrack->isKeyMapped(transposedKey))
{
const auto frequency = m_instrumentTrack->m_microtuner.keyToFreq(transposedKey, baseNote);
m_frequency = frequency * powf(2.f, (detune + instrumentPitch / 100) / 12.f);
m_unpitchedFrequency = frequency * powf(2.f, detune / 12.f);
m_frequency = frequency * std::exp2((detune + instrumentPitch / 100) / 12.f);
m_unpitchedFrequency = frequency * std::exp2(detune / 12.f);
}
else
{
@@ -544,8 +544,8 @@ void NotePlayHandle::updateFrequency()
{
// default key mapping and 12-TET frequency computation with default 440 Hz base note frequency
const float pitch = (key() - baseNote + masterPitch + detune) / 12.0f;
m_frequency = DefaultBaseFreq * powf(2.0f, pitch + instrumentPitch / (100 * 12.0f));
m_unpitchedFrequency = DefaultBaseFreq * powf(2.0f, pitch);
m_frequency = DefaultBaseFreq * std::exp2(pitch + instrumentPitch / (100 * 12.0f));
m_unpitchedFrequency = DefaultBaseFreq * std::exp2(pitch);
}
for (auto it : m_subNotes)

View File

@@ -142,8 +142,8 @@ void Oscillator::generateTriangleWaveTable(int bands, sample_t* table, int first
{
for (int n = firstBand | 1; n <= bands; n += 2)
{
table[i] += (n & 2 ? -1.0f : 1.0f) / powf(n, 2.0f) *
std::sin(numbers::tau_v<float> * n * i / (float)OscillatorConstants::WAVETABLE_LENGTH) / (numbers::pi_sqr_v<float> / 8);
table[i] += (n & 2 ? -1.0f : 1.0f) / (n * n) *
std::sin(numbers::tau_v<float> * n * i / (float)OscillatorConstants::WAVETABLE_LENGTH) / (numbers::pi_sqr_v<float> / 8.0f);
}
}
}

View File

@@ -36,7 +36,7 @@ Interval::Interval(float cents) :
m_denominator(0),
m_cents(cents)
{
m_ratio = powf(2.f, m_cents / 1200.f);
m_ratio = std::exp2(m_cents / 1200.f);
}
Interval::Interval(uint32_t numerator, uint32_t denominator) :
@@ -68,7 +68,7 @@ void Interval::loadSettings(const QDomElement &element)
m_denominator = element.attribute("den", "0").toULong();
m_cents = element.attribute("cents", "0").toDouble();
if (m_denominator) {m_ratio = static_cast<float>(m_numerator) / m_denominator;}
else {m_ratio = powf(2.f, m_cents / 1200.f);}
else { m_ratio = std::exp2(m_cents / 1200.f); }
}

View File

@@ -152,7 +152,7 @@ AudioSoundIo::AudioSoundIo( bool & outSuccessful, AudioEngine * _audioEngine ) :
break;
}
if (closestSupportedSampleRate == -1 ||
abs(range->max - currentSampleRate) < abs(closestSupportedSampleRate - currentSampleRate))
std::abs(range->max - currentSampleRate) < std::abs(closestSupportedSampleRate - currentSampleRate))
{
closestSupportedSampleRate = range->max;
}

View File

@@ -591,7 +591,7 @@ void Lv2Proc::createPort(std::size_t portNum)
// make multiples of 0.01 (or 0.1 for larger values)
float minStep = (stepSize >= 1.0f) ? 0.1f : 0.01f;
stepSize -= fmodf(stepSize, minStep);
stepSize -= std::fmod(stepSize, minStep);
stepSize = std::max(stepSize, minStep);
ctrl->m_connectedModel.reset(

View File

@@ -253,7 +253,7 @@ QFont GuiApplication::getWin32SystemFont()
{
// height is in pixels, convert to points
HDC hDC = GetDC( nullptr );
pointSize = MulDiv( abs( pointSize ), 72, GetDeviceCaps( hDC, LOGPIXELSY ) );
pointSize = MulDiv(std::abs(pointSize), 72, GetDeviceCaps(hDC, LOGPIXELSY));
ReleaseDC( nullptr, hDC );
}

View File

@@ -1414,7 +1414,7 @@ TimePos ClipView::draggedClipPos( QMouseEvent * me )
endQ = endQ - m_clip->length();
// Select the position closest to actual position
if ( abs(newPos - startQ) < abs(newPos - endQ) ) newPos = startQ;
if (std::abs(newPos - startQ) < std::abs(newPos - endQ)) { newPos = startQ; }
else newPos = endQ;
}
else
@@ -1457,7 +1457,7 @@ TimePos ClipView::quantizeSplitPos( TimePos midiPos, bool shiftMode )
const TimePos rightOff = m_clip->length() - midiPos;
const TimePos rightPos = m_clip->length() - rightOff.quantize( snapSize );
//...whichever gives a position closer to the cursor
if ( abs(leftPos - midiPos) < abs(rightPos - midiPos) ) { return leftPos; }
if (std::abs(leftPos - midiPos) < std::abs(rightPos - midiPos)) { return leftPos; }
else { return rightPos; }
}
else

View File

@@ -1630,7 +1630,7 @@ void AutomationEditor::wheelEvent(QWheelEvent * we )
}
// FIXME: Reconsider if determining orientation is necessary in Qt6.
else if(abs(we->angleDelta().x()) > abs(we->angleDelta().y())) // scrolling is horizontal
else if (std::abs(we->angleDelta().x()) > std::abs(we->angleDelta().y())) // scrolling is horizontal
{
adjustLeftRightScoll(we->angleDelta().x());
}

View File

@@ -2813,7 +2813,7 @@ void PianoRoll::dragNotes(int x, int y, bool alt, bool shift, bool ctrl)
TimePos mousePosQ = mousePos.quantize(static_cast<float>(quantization()) / DefaultTicksPerBar);
TimePos mousePosEndQ = mousePosEnd.quantize(static_cast<float>(quantization()) / DefaultTicksPerBar);
bool snapEnd = abs(mousePosEndQ - mousePosEnd) < abs(mousePosQ - mousePos);
bool snapEnd = std::abs(mousePosEndQ - mousePosEnd) < std::abs(mousePosQ - mousePos);
// Set the offset
noteOffset = snapEnd
@@ -3878,7 +3878,7 @@ void PianoRoll::wheelEvent(QWheelEvent * we )
}
// FIXME: Reconsider if determining orientation is necessary in Qt6.
else if(abs(we->angleDelta().x()) > abs(we->angleDelta().y())) // scrolling is horizontal
else if (std::abs(we->angleDelta().x()) > std::abs(we->angleDelta().y())) // scrolling is horizontal
{
adjustLeftRightScoll(we->angleDelta().x());
}

View File

@@ -777,12 +777,12 @@ IntModel* PianoView::getNearestMarker(int key, QString* title)
const int first = m_piano->instrumentTrack()->firstKey();
const int last = m_piano->instrumentTrack()->lastKey();
if (abs(key - base) < abs(key - first) && abs(key - base) < abs(key - last))
if (std::abs(key - base) < std::abs(key - first) && std::abs(key - base) < std::abs(key - last))
{
if (title) {*title = tr("Base note");}
return m_piano->instrumentTrack()->baseNoteModel();
}
else if (abs(key - first) < abs(key - last))
else if (std::abs(key - first) < std::abs(key - last))
{
if (title) {*title = tr("First note");}
return m_piano->instrumentTrack()->firstKeyModel();

View File

@@ -735,7 +735,7 @@ void graphModel::clearInvisible()
void graphModel::drawSampleAt( int x, float val )
{
//snap to the grid
val -= ( m_step != 0.0 ) ? fmod( val, m_step ) * m_step : 0;
val -= (m_step != 0.0) ? std::fmod(val, m_step) * m_step : 0;
// boundary crop
x = qMax( 0, qMin( length()-1, x ) );

View File

@@ -313,8 +313,8 @@ void Knob::setTextColor( const QColor & c )
QLineF Knob::calculateLine( const QPointF & _mid, float _radius, float _innerRadius ) const
{
const float rarc = m_angle * numbers::pi_v<float> / 180.0;
const float ca = cos( rarc );
const float sa = -sin( rarc );
const float ca = std::cos(rarc);
const float sa = -std::sin(rarc);
return QLineF( _mid.x() - sa*_innerRadius, _mid.y() - ca*_innerRadius,
_mid.x() - sa*_radius, _mid.y() - ca*_radius );

View File

@@ -43,6 +43,7 @@
#include "GuiApplication.h"
#include "FontHelper.h"
#include "MainWindow.h"
#include "lmms_math.h"
namespace lmms::gui
{
@@ -109,7 +110,7 @@ void LcdFloatSpinBox::layoutSetup(const QString &style)
void LcdFloatSpinBox::update()
{
const int digitValue = std::pow(10.f, m_fractionDisplay.numDigits());
const int digitValue = fastPow10f(m_fractionDisplay.numDigits());
float value = model()->value();
int fraction = std::abs(std::round((value - static_cast<int>(value)) * digitValue));
if (fraction == digitValue)