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

Use C++20 std::numbers, std::lerp() #7696

Merged
merged 27 commits into from
Feb 13, 2025
Merged

Conversation

rubiefawn
Copy link
Contributor

@rubiefawn rubiefawn commented Feb 9, 2025

In #7558, I added lmms::numbers; in this PR, I destroy it.

  • Use C++20 <concepts> such as floating_point rather than typename for templates
  • Replace uses of constants from lmms::numbers that are also defined in std::numbers with the std::numbers version
  • Maybe... possibly... replace uses of lmms::numbers::tau with 2 * std::numbers::pi? (I love τ dearly, but @messmerd has a point)
  • Replace lerp() from lmms_math.h and linearInterpolate() from interpolation.h with std::lerp() (this should have happened in Update math functions to C++ standard library #7685 but I didn't realize std::lerp() existed)

Rest in peace lmms::numbers::tau, my beloved
A lot of the remaining constants in lmms_constants.h are specific to
SaProcessor. If they are only used there, shouldn't they be in SaProcessor.h?
@rubiefawn
Copy link
Contributor Author

rubiefawn commented Feb 10, 2025

Almost all the remaining constants in lmms_constants.h are only used in one file each. LOWEST_LOG_FREQ, enum class FrequencyRange and its associated constants, and enum class AmplitudeRange and its associated constants are only used in the spectrum analyzer plugin. F_EPSILON is only used in lmms_math.h. In fact, MaxScaleCount and MaxKeymapCount are the only remaining constants referenced in more than one file.

Besides moving F_EPSILON into lmms_math.h and making it specific to that file, I don't currently have any suggestions or opinions about this observation.

Edit: OscillatorConstants.h exists; should this be merged with what remains of lmms_constants.h?

- And also move F_EPSILON into lmms_math.h
- And also add an overload for fast_rand() to specify a higher and lower bound
- And a bunch of other nonsense
As well as time travel to undo several foolish decisions and squash tiny
commits together
@rubiefawn rubiefawn changed the title Use C++20 std::numbers Use C++20 std::numbers, std::lerp() Feb 11, 2025
@rubiefawn rubiefawn marked this pull request as ready for review February 11, 2025 07:46
Copy link
Member

@messmerd messmerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. I just have a few suggestions

include/lmms_constants.h Outdated Show resolved Hide resolved
plugins/Compressor/CompressorControlDialog.cpp Outdated Show resolved Hide resolved
include/lmms_math.h Outdated Show resolved Hide resolved
include/lmms_math.h Outdated Show resolved Hide resolved
include/lmms_math.h Outdated Show resolved Hide resolved
include/lmms_math.h Outdated Show resolved Hide resolved
include/lmms_math.h Outdated Show resolved Hide resolved
plugins/SlicerT/SlicerT.cpp Outdated Show resolved Hide resolved
plugins/Xpressive/Xpressive.cpp Outdated Show resolved Hide resolved
rubiefawn and others added 4 commits February 11, 2025 18:50
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
Copy link
Member

@messmerd messmerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is just about ready to merge

include/lmms_math.h Outdated Show resolved Hide resolved
include/lmms_math.h Outdated Show resolved Hide resolved
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
Copy link
Member

@messmerd messmerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'll merge tomorrow if there are no objections

@messmerd messmerd merged commit e328a13 into LMMS:master Feb 13, 2025
10 checks passed
@messmerd
Copy link
Member

Thanks again!

@rubiefawn rubiefawn deleted the template-constants2 branch February 13, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants