Merge branch 'portability/macos' of https://git.foxiepa.ws/foxiepaws/xybrid

macOS compatibility fixes
portability/macos
zetaPRIME 2019-07-21 19:21:10 -04:00
commit 43f6374fc2
8 changed files with 47 additions and 9 deletions

2
.gitignore vendored
View File

@ -1,5 +1,6 @@
# ignore build artifacts
build-*/*
*.o
# user config
*.codekit
@ -7,3 +8,4 @@ build-*/*
*.pro.user.*
*.stash
*.autosave

View File

@ -6,7 +6,7 @@
#include <deque>
#include <unordered_map>
#include <atomic>
#include <array>
#include <QIODevice>
#include <QAudioOutput>
#include <QSemaphore>

View File

@ -7,7 +7,7 @@
#include <list>
#include <vector>
#include <string>
#include <array>
#include <QString>
namespace Xybrid::Data {

View File

@ -13,13 +13,15 @@
int main(int argc, char *argv[]) {
qRegisterMetaType<Xybrid::Data::Port>();
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");

View File

@ -320,8 +320,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

View File

@ -3,7 +3,7 @@
#include <memory>
#include <functional>
#include <unordered_map>
#include <array>
#include "nodelib/basics.h"
#include "data/node.h"

View File

@ -1,8 +1,17 @@
#include "resampler.h"
using namespace Xybrid::NodeLib;
#include <cmath>
#include <iostream>
#include <array>
#ifdef WITH_BOOST
#include <boost/math/special_functions/bessel.hpp>
#define cyl_bessel_i boost::math::cyl_bessel_i
#else
#include <cmath>
#define cyl_bessel_i std::cyl_bessel_i
#endif
namespace {
const constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974;
@ -17,9 +26,12 @@ namespace {
}
}
// generate
const std::array<std::array<double, LUT_TAPS>, LUT_STEPS> Xybrid::NodeLib::resamplerLUT = [] {
double denom = std::cyl_bessel_i(0, KAISER_BETA);
double denom = cyl_bessel_i(0, KAISER_BETA);
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
@ -27,7 +39,7 @@ const std::array<std::array<double, LUT_TAPS>, LUT_STEPS> Xybrid::NodeLib::resam
double sv = static_cast<double>(step) / LUT_STEPS;
for (size_t tap = 0; tap < LUT_TAPS; tap++) {
double x = static_cast<double>(tap) - sv;
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);
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] << " ";
}

View File

@ -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