From 305a24196aaaeda2b78b00144057ba1f4fd5fda3 Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Wed, 9 Apr 2025 20:01:49 -0700 Subject: [PATCH] Make some constants constexpr, mark as float so MSVC doesn't print a warning about a double to float truncation --- src/StepParityCost.h | 8 ++++---- src/TechCounts.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/StepParityCost.h b/src/StepParityCost.h index 700e010c2e..4adc128015 100644 --- a/src/StepParityCost.h +++ b/src/StepParityCost.h @@ -26,15 +26,15 @@ namespace StepParity // 0.1 = 1/16th note at 150bpm. Jacks quicker than this are harder. // Above this speed, footswitches should be prioritized - const float JACK_THRESHOLD = 0.1; + constexpr float JACK_THRESHOLD = 0.1f; // 0.15 = 1/8th at 200bpm, or 3/16th at 150bpm. Below this speed, jumps should be prioritized - const float SLOW_BRACKET_THRESHOLD = 0.15; + constexpr float SLOW_BRACKET_THRESHOLD = 0.15f; // 0.2 = 1/8th at 150bpm. Footswitches slower than this are harder. // Below this speed, jacks should be prioritized - const float SLOW_FOOTSWITCH_THRESHOLD = 0.2; + constexpr float SLOW_FOOTSWITCH_THRESHOLD = 0.2f; // 0.4 = 1/4th at 150bpm. Once a footswitch gets slow enough, though, // just ignore it. - const float SLOW_FOOTSWITCH_IGNORE = 0.4; + constexpr float SLOW_FOOTSWITCH_IGNORE = 0.4f; class StepParityCost { diff --git a/src/TechCounts.cpp b/src/TechCounts.cpp index 102121a3a1..19718bb2b3 100644 --- a/src/TechCounts.cpp +++ b/src/TechCounts.cpp @@ -28,13 +28,13 @@ LuaXType( TechCountsCategory ); // 0.176 ~= 1/8th at 175bpm // Anything slower isn't counted as a jack -const float JACK_CUTOFF = 0.176; +constexpr float JACK_CUTOFF = 0.176f; // 0.3 = 1/4th at 200bpm (or 3/16th at 150bpm) // Anything slower isn't counted as a footswitch -const float FOOTSWITCH_CUTOFF = 0.3; +constexpr float FOOTSWITCH_CUTOFF = 0.3f; // 0.235 ~= 1/8th at 128bpm // Anything slower isn't counted as a doublestep -const float DOUBLESTEP_CUTOFF = 0.235; +constexpr float DOUBLESTEP_CUTOFF = 0.235f; // TechCounts methods TechCounts::TechCounts()