WITH_BOOST define added
- some platforms don't support C++17 Special Mathmatical functions, most notibly macOS and llvm. This enables this to work by using boost for the bessel functionsportability/boost
parent
3f98a5a68f
commit
2e1f3e04cb
|
@ -1,5 +1,6 @@
|
|||
# ignore build artifacts
|
||||
build-*/*
|
||||
*.o
|
||||
|
||||
# user config
|
||||
*.codekit
|
||||
|
@ -7,3 +8,4 @@ build-*/*
|
|||
*.pro.user.*
|
||||
*.stash
|
||||
*.autosave
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
#include "resampler.h"
|
||||
using namespace Xybrid::NodeLib;
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <iostream>
|
||||
#include <array>
|
||||
|
||||
#ifdef WITH_BOOST
|
||||
#include <boost/math/special_functions/bessel.hpp>
|
||||
#else
|
||||
#include <cmath>
|
||||
#endif
|
||||
namespace {
|
||||
const constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974;
|
||||
|
||||
|
@ -18,17 +22,26 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// generate
|
||||
const std::array<std::array<double, LUT_TAPS>, LUT_STEPS> Xybrid::NodeLib::resamplerLUT = [] {
|
||||
#ifdef WITH_BOOST
|
||||
double denom = boost::math::cyl_bessel_i(0, KAISER_BETA);
|
||||
#else
|
||||
double denom = std::cyl_bessel_i(0, KAISER_BETA);
|
||||
|
||||
#endif
|
||||
std::array<std::array<double, LUT_TAPS>, LUT_STEPS> t;
|
||||
t[0] = {0, 0, 0, 1, 0, 0, 0, 0}; // we already know the ideal integer step
|
||||
for (size_t step = 1; step < LUT_STEPS; step++) {
|
||||
double sv = static_cast<double>(step) / LUT_STEPS;
|
||||
for (size_t tap = 0; tap < LUT_TAPS; tap++) {
|
||||
double x = static_cast<double>(tap) - sv;
|
||||
#ifdef WITH_BOOST
|
||||
t[step][tap] = sinc(x-(LUT_TAPS/2-1)) * (boost::math::cyl_bessel_i(0, KAISER_BETA * std::sqrt(1 - std::pow(((2 * (x+1)) / (LUT_TAPS)) - 1, 2))) / denom);
|
||||
#else
|
||||
t[step][tap] = sinc(x-(LUT_TAPS/2-1)) * (std::cyl_bessel_i(0, KAISER_BETA * std::sqrt(1 - std::pow(((2 * (x+1)) / (LUT_TAPS)) - 1, 2))) / denom);
|
||||
#endif
|
||||
if (t[step][tap] != t[step][tap]) t[step][tap] = 0; // NaN guard
|
||||
//std::cout << "tap " << tap << ": " << t[step][tap] << " ";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ TEMPLATE = app
|
|||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
|
@ -36,6 +37,24 @@ HEADERS += $$files(*.h, true) \
|
|||
FORMS += $$files(*.ui, true)
|
||||
RESOURCES += res/resources.qrc
|
||||
|
||||
unix:!macx {
|
||||
|
||||
}
|
||||
|
||||
macx: {
|
||||
DEFINES += WITH_BOOST
|
||||
LIBS += -L/usr/local/Cellar/boost/1.70.0/lib/ -lboost_math_tr1
|
||||
LIBS += -framework OpenGL
|
||||
QMAKE_CXXFLAGS += -I/usr/local/Cellar/boost/1.70.0/include/
|
||||
}
|
||||
|
||||
# TODO: make this work.
|
||||
CONFIG (boost) {
|
||||
DEFINES += WITH_BOOST
|
||||
LIBS += -L$${BOOSTPATH}
|
||||
QMAKE_CXXFLAGS += -I$${BOOSTINCLUDE}
|
||||
}
|
||||
|
||||
# Default rules for deployment.
|
||||
qnx: target.path = /tmp/$${TARGET}/bin
|
||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||
|
|
Loading…
Reference in New Issue