From 3f98a5a68f1d6ba1bd4ffaf595195ac38f70d79c Mon Sep 17 00:00:00 2001 From: "Rachel Fae Fox (foxiepaws)" Date: Thu, 18 Jul 2019 02:32:59 -0400 Subject: [PATCH 1/4] Clang (and possibly other stricter compilers require that you actually include all of what you use. unlike G++ --- xybrid/audio/audioengine.h | 2 +- xybrid/data/pattern.h | 2 +- xybrid/nodelib/instrumentcore.h | 2 +- xybrid/nodelib/resampler.cpp | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/xybrid/audio/audioengine.h b/xybrid/audio/audioengine.h index 140130f..83f5433 100644 --- a/xybrid/audio/audioengine.h +++ b/xybrid/audio/audioengine.h @@ -6,7 +6,7 @@ #include #include #include - +#include #include #include #include diff --git a/xybrid/data/pattern.h b/xybrid/data/pattern.h index 0eed5f1..2a60764 100644 --- a/xybrid/data/pattern.h +++ b/xybrid/data/pattern.h @@ -7,7 +7,7 @@ #include #include #include - +#include #include namespace Xybrid::Data { diff --git a/xybrid/nodelib/instrumentcore.h b/xybrid/nodelib/instrumentcore.h index 8036924..b537262 100644 --- a/xybrid/nodelib/instrumentcore.h +++ b/xybrid/nodelib/instrumentcore.h @@ -3,7 +3,7 @@ #include #include #include - +#include #include "nodelib/basics.h" #include "data/node.h" diff --git a/xybrid/nodelib/resampler.cpp b/xybrid/nodelib/resampler.cpp index 6d433e0..1e0ed44 100644 --- a/xybrid/nodelib/resampler.cpp +++ b/xybrid/nodelib/resampler.cpp @@ -3,6 +3,7 @@ using namespace Xybrid::NodeLib; #include #include +#include namespace { const constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974; From 2e1f3e04cbe114d773e0807fa41db9f2c934050a Mon Sep 17 00:00:00 2001 From: "Rachel Fae Fox (foxiepaws)" Date: Thu, 18 Jul 2019 05:08:22 -0400 Subject: [PATCH 2/4] 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 functions --- .gitignore | 2 ++ xybrid/nodelib/resampler.cpp | 19 ++++++++++++++++--- xybrid/xybrid.pro | 19 +++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index f0ad36b..e2579c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # ignore build artifacts build-*/* +*.o # user config *.codekit @@ -7,3 +8,4 @@ build-*/* *.pro.user.* *.stash *.autosave + diff --git a/xybrid/nodelib/resampler.cpp b/xybrid/nodelib/resampler.cpp index 1e0ed44..3097e4b 100644 --- a/xybrid/nodelib/resampler.cpp +++ b/xybrid/nodelib/resampler.cpp @@ -1,10 +1,14 @@ #include "resampler.h" using namespace Xybrid::NodeLib; -#include + #include #include - +#ifdef WITH_BOOST +#include +#else +#include +#endif namespace { const constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974; @@ -18,17 +22,26 @@ namespace { } } + + // generate const std::array, 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, 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(step) / LUT_STEPS; for (size_t tap = 0; tap < LUT_TAPS; tap++) { double x = static_cast(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] << " "; } diff --git a/xybrid/xybrid.pro b/xybrid/xybrid.pro index 3b66d63..6805bda 100644 --- a/xybrid/xybrid.pro +++ b/xybrid/xybrid.pro @@ -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 From d4595bc0226ef76174a4b3e493f83cd67c6d0494 Mon Sep 17 00:00:00 2001 From: "Rachel Fae Fox (foxiepaws)" Date: Thu, 18 Jul 2019 05:11:43 -0400 Subject: [PATCH 3/4] Modifications required to build under OSX - moved QSurfaceFormat::setDefaultFormat(fmt); higher up in main, as osx requires this. - ifdef'ed out two glEnable calls as they cause Xybrid to segfault on OSX --- xybrid/main.cpp | 8 +++++--- xybrid/mainwindow.cpp | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/xybrid/main.cpp b/xybrid/main.cpp index 261234a..c7d8dd6 100644 --- a/xybrid/main.cpp +++ b/xybrid/main.cpp @@ -13,13 +13,15 @@ int main(int argc, char *argv[]) { qRegisterMetaType(); - - QApplication a(argc, argv); - // enable antialiasing on accelerated graphicsview QSurfaceFormat fmt; fmt.setSamples(10); + QSurfaceFormat::setDefaultFormat(fmt); + QApplication a(argc, argv); + + + // make sure bundled fonts are loaded QFontDatabase::addApplicationFont(":/fonts/iosevka-term-light.ttf"); diff --git a/xybrid/mainwindow.cpp b/xybrid/mainwindow.cpp index 03bb831..fee5c51 100644 --- a/xybrid/mainwindow.cpp +++ b/xybrid/mainwindow.cpp @@ -325,8 +325,11 @@ MainWindow::MainWindow(QWidget *parent) : view->setViewport(vp); // enable hardware acceleration } view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing); + // Under OSX these cause Xybrid to crash. + #ifndef __APPLE__ glEnable(GL_MULTISAMPLE); glEnable(GL_LINE_SMOOTH); + #endif //QGL::FormatOption::Rgba From fed1365b141f735adecb6c48fbb7fe5d6061fe7f Mon Sep 17 00:00:00 2001 From: "Rachel Fae Fox (foxiepaws)" Date: Thu, 18 Jul 2019 06:19:05 -0400 Subject: [PATCH 4/4] Modified code style on the resampler to make it easier to read. --- xybrid/nodelib/resampler.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/xybrid/nodelib/resampler.cpp b/xybrid/nodelib/resampler.cpp index 3097e4b..b7772f8 100644 --- a/xybrid/nodelib/resampler.cpp +++ b/xybrid/nodelib/resampler.cpp @@ -4,11 +4,15 @@ using namespace Xybrid::NodeLib; #include #include + #ifdef WITH_BOOST #include +#define cyl_bessel_i boost::math::cyl_bessel_i #else #include +#define cyl_bessel_i std::cyl_bessel_i #endif + namespace { const constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974; @@ -26,22 +30,16 @@ namespace { // generate const std::array, 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 + + double denom = cyl_bessel_i(0, KAISER_BETA); + std::array, 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(step) / LUT_STEPS; for (size_t tap = 0; tap < LUT_TAPS; tap++) { double x = static_cast(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 + t[step][tap] = sinc(x-(LUT_TAPS/2-1)) * (cyl_bessel_i(0, KAISER_BETA * std::sqrt(1 - std::pow(((2 * (x+1)) / (LUT_TAPS)) - 1, 2))) / denom); if (t[step][tap] != t[step][tap]) t[step][tap] = 0; // NaN guard //std::cout << "tap " << tap << ": " << t[step][tap] << " "; }