LMMS
Loading...
Searching...
No Matches
lmms_math.h File Reference
#include <QtGlobal>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <numbers>
#include <concepts>
#include "lmms_constants.h"

Go to the source code of this file.

Classes

class  lmms::LinearMap< T >

Namespaces

namespace  lmms

Functions

bool lmms::approximatelyEqual (float x, float y) noexcept
auto lmms::fraction (std::floating_point auto x) noexcept
 Returns the fractional part of a float, a value between -1.0f and 1.0f.
auto lmms::absFraction (std::floating_point auto x) noexcept
 Returns the wrapped fractional part of a float, a value between 0.0f and 1.0f.
int lmms::fastRand () noexcept
 Returns a pseudorandom integer within [0, 32768).
template<std::floating_point T>
lmms::fastRand (T upper) noexcept
 Returns a pseudorandom number within [0, upper) (exclusive upper bound).
template<std::integral T>
lmms::fastRand (T upper) noexcept
 Returns a pseudorandom integer within [0, upper) (exclusive upper bound). upper may be negative, in which case the output range is (upper, 0].
template<typename T>
auto lmms::fastRand (T from, T to) noexcept
 Returns a pseudorandom integer within [from, to) (exclusive upper bound).
template<std::floating_point T>
lmms::fastRandInc (T upper) noexcept
 Returns a pseudorandom number within [0, upper] (inclusive upper bound).
template<std::unsigned_integral T>
lmms::fastRandInc (T upper) noexcept
 Returns a pseudorandom integer within [0, upper] (inclusive upper bound).
template<std::signed_integral T>
lmms::fastRandInc (T upper) noexcept
 Returns a pseudorandom integer within [0, upper] (inclusive upper bound). upper may be negative, in which case the output range is [upper, 0].
template<typename T>
auto lmms::fastRandInc (T from, T to) noexcept
 Returns a pseudorandom integer within [from, to] (inclusive upper bound). This function does not require the parameters to be in the proper order. fastRand(a, b) behaves identically to fastRand(b, a).
bool lmms::oneIn (unsigned chance) noexcept
 Returns true one in chance times at random.
template<class T>
static void lmms::roundAt (T &value, const T &where, const T &stepSize)
 Round value to where depending on step size.
double lmms::fastPow (double a, double b)
 Source: http://martin.ankerl.com/2007/10/04/optimized-pow-approximation-for-java-and-c-c/.
template<typename T>
constexprlmms::sign (T val) noexcept
 returns +1 if val >= 0, else -1
float lmms::sqrt_neg (float val)
 if val >= 0.0f, returns sqrt(val), else: -sqrt(-val)
float lmms::signedPowf (float v, float e)
 Exponential function that deals with negative bases.
float lmms::logToLinearScale (float min, float max, float value)
 Scales @value from linear to logarithmic. Value should be within [0,1].
float lmms::linearToLogScale (float min, float max, float value)
 Scales value from logarithmic to linear. Value should be in min-max range.
template<typename T>
auto lmms::fastPow10f (T x)
template<typename T>
auto lmms::fastLog10f (T x)
float lmms::ampToDbfs (float amp)
 Converts linear amplitude (>0-1.0) to dBFS scale.
float lmms::dbfsToAmp (float dbfs)
 Converts dBFS-scale to linear amplitude with 0dBFS = 1.0.
float lmms::safeAmpToDbfs (float amp)
 Converts linear amplitude (0-1.0) to dBFS scale. Handles zeroes as -inf.
float lmms::safeDbfsToAmp (float dbfs)
 Converts dBFS-scale to linear amplitude with 0dBFS = 1.0. Handles infinity as zero.
int lmms::numDigitsAsInt (float f)