Use a custom lround and silence tidy
This commit is contained in:
parent
1498daa8a6
commit
87c6174cad
2 changed files with 16 additions and 1 deletions
|
|
@ -254,6 +254,20 @@ constexpr Type sqrtTwo() { return static_cast<Type>(1.41421356237309504880168872
|
||||||
template <class Type>
|
template <class Type>
|
||||||
constexpr Type sqrtTwoInv() { return static_cast<Type>(0.707106781186547524400844362104849039284835937688474036588); };
|
constexpr Type sqrtTwoInv() { return static_cast<Type>(0.707106781186547524400844362104849039284835937688474036588); };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief lround for positive values
|
||||||
|
* This optimizes a bit better by ignoring the negative code path
|
||||||
|
*
|
||||||
|
* @tparam T
|
||||||
|
* @param value
|
||||||
|
* @return constexpr long int
|
||||||
|
*/
|
||||||
|
template<class T, absl::enable_if_t<std::is_floating_point<T>::value, int> = 0 >
|
||||||
|
constexpr long int lroundPositive(T value)
|
||||||
|
{
|
||||||
|
return static_cast<int>(0.5f + value); // NOLINT
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief A fraction which is parameterized by integer type
|
@brief A fraction which is parameterized by integer type
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "Panning.h"
|
#include "Panning.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace sfz
|
namespace sfz
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +25,7 @@ static const auto panData = []()
|
||||||
float panLookup(float pan)
|
float panLookup(float pan)
|
||||||
{
|
{
|
||||||
// reduce range, round to nearest
|
// reduce range, round to nearest
|
||||||
int index = static_cast<int>(0.5f + pan * (panSize - 1));
|
int index = lroundPositive(pan * (panSize - 1));
|
||||||
return panData[index];
|
return panData[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue