macOS/clang++ Porting work
- std=c++2a instead of c++20. QT Creator mkspec for mac requires this - added missing headers in some places. likely other headers are missing - expanded WITH_BOOST segments to include memory_resource stuff - moved SVFilter template process() into header.master
parent
b92dd4f3c5
commit
7aa71c5cc2
|
@ -3,11 +3,26 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
#include <boost/container/pmr/memory_resource.hpp>
|
||||||
|
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
||||||
|
using boost::container::pmr::polymorphic_allocator;
|
||||||
|
template <class Key,
|
||||||
|
class T,
|
||||||
|
class Hash = std::hash<Key>,
|
||||||
|
class Pred = std::equal_to<Key>>
|
||||||
|
using unordered_map = std::unordered_map<Key, T, Hash, Pred, polymorphic_allocator<std::pair<const Key,T>>>;
|
||||||
|
template <class Key, class T,
|
||||||
|
class Hash = std::hash<Key>,
|
||||||
|
class Pred = std::equal_to<Key>>
|
||||||
|
using unordered_multimap = std::unordered_multimap<Key, T, Hash, Pred, polymorphic_allocator<std::pair<const Key,T>>>;
|
||||||
|
#else
|
||||||
|
using std::pmr::unordered_map;
|
||||||
|
using std::pmr::unordered_multimap;
|
||||||
|
#endif
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "nodelib/basics.h"
|
#include "nodelib/basics.h"
|
||||||
|
|
||||||
#include "data/node.h"
|
#include "data/node.h"
|
||||||
|
|
||||||
#include "util/mem.h"
|
#include "util/mem.h"
|
||||||
|
|
||||||
namespace Xybrid::Data {
|
namespace Xybrid::Data {
|
||||||
|
@ -91,8 +106,8 @@ namespace Xybrid::NodeLib {
|
||||||
double volume = 1.0;
|
double volume = 1.0;
|
||||||
double pan = 0.0;
|
double pan = 0.0;
|
||||||
|
|
||||||
std::pmr::unordered_map<uint16_t, Note> activeNotes = {16, Util::ralloc};
|
unordered_map<uint16_t, Note> activeNotes = {16, Util::ralloc};
|
||||||
std::pmr::unordered_multimap<uint16_t, Tween> activeTweens = {16, Util::ralloc};
|
unordered_multimap<uint16_t, Tween> activeTweens = {16, Util::ralloc};
|
||||||
|
|
||||||
std::function<bool(Note*, const ParamReader&)> paramFilter;
|
std::function<bool(Note*, const ParamReader&)> paramFilter;
|
||||||
std::unordered_map<uint8_t, std::function<bool(const ParamReader&)>> globalParam;
|
std::unordered_map<uint8_t, std::function<bool(const ParamReader&)>> globalParam;
|
||||||
|
|
|
@ -10,7 +10,7 @@ using namespace Xybrid::Audio;
|
||||||
|
|
||||||
template class Xybrid::NodeLib::GenericSVFilter<AudioFrame>;
|
template class Xybrid::NodeLib::GenericSVFilter<AudioFrame>;
|
||||||
template class Xybrid::NodeLib::GenericSVFilter<double>;
|
template class Xybrid::NodeLib::GenericSVFilter<double>;
|
||||||
|
/*
|
||||||
template<typename DT>
|
template<typename DT>
|
||||||
void GenericSVFilter<DT>::process(DT in, double cutoff, double resonance, int ovs) {
|
void GenericSVFilter<DT>::process(DT in, double cutoff, double resonance, int ovs) {
|
||||||
if (ovs <= 0) return;
|
if (ovs <= 0) return;
|
||||||
|
@ -28,3 +28,4 @@ void GenericSVFilter<DT>::process(DT in, double cutoff, double resonance, int ov
|
||||||
}
|
}
|
||||||
notch = high+low;
|
notch = high+low;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "data/audioframe.h"
|
#include "data/audioframe.h"
|
||||||
|
#include "nodelib/basics.h"
|
||||||
|
#include "audio/audioengine.h"
|
||||||
|
using namespace Xybrid::Audio;
|
||||||
|
|
||||||
namespace Xybrid::NodeLib {
|
namespace Xybrid::NodeLib {
|
||||||
/// 12db Chamberlin State Variable Filter
|
/// 12db Chamberlin State Variable Filter
|
||||||
|
@ -23,7 +25,22 @@ namespace Xybrid::NodeLib {
|
||||||
inline GenericSVFilter<DT>(const GenericSVFilter<DT>& o) { std::memcpy(static_cast<void*>(this), static_cast<const void*>(&o), sizeof(o)); }
|
inline GenericSVFilter<DT>(const GenericSVFilter<DT>& o) { std::memcpy(static_cast<void*>(this), static_cast<const void*>(&o), sizeof(o)); }
|
||||||
inline GenericSVFilter<DT>& operator=(const GenericSVFilter<DT>& o) { std::memcpy(static_cast<void*>(this), static_cast<const void*>(&o), sizeof(o)); return *this; }
|
inline GenericSVFilter<DT>& operator=(const GenericSVFilter<DT>& o) { std::memcpy(static_cast<void*>(this), static_cast<const void*>(&o), sizeof(o)); return *this; }
|
||||||
|
|
||||||
void process(DT in, double cutoff, double resonance, int oversamp = DEFAULT_OVERSAMP);
|
void process(DT in, double cutoff, double resonance, int oversamp = DEFAULT_OVERSAMP) {
|
||||||
|
if (oversamp <= 0) return;
|
||||||
|
cutoff = std::max(cutoff, 1.0);
|
||||||
|
resonance = std::max(resonance, 0.01);
|
||||||
|
|
||||||
|
double f = 2.0 * std::sin(PI * cutoff / (audioEngine->curSampleRate() * oversamp));
|
||||||
|
double q = std::sqrt(1.0 - std::atan(std::sqrt(resonance)) * 2.0 / PI);
|
||||||
|
double damp = std::sqrt(q);
|
||||||
|
|
||||||
|
for (int i = 0; i < oversamp; i++) {
|
||||||
|
low += band*f;
|
||||||
|
high = in*damp - low - band*q;
|
||||||
|
band += high*f;
|
||||||
|
}
|
||||||
|
notch = high+low;
|
||||||
|
}
|
||||||
inline void reset() { low = 0.0; high = 0.0; band = 0.0; notch = 0.0; }
|
inline void reset() { low = 0.0; high = 0.0; band = 0.0; notch = 0.0; }
|
||||||
inline void normalize(double m) {
|
inline void normalize(double m) {
|
||||||
if constexpr (std::is_arithmetic_v<DT>) {
|
if constexpr (std::is_arithmetic_v<DT>) {
|
||||||
|
@ -48,7 +65,7 @@ namespace Xybrid::NodeLib {
|
||||||
extern template void Xybrid::NodeLib::GenericSVFilter<double>::process(double, double, double, int);
|
extern template void Xybrid::NodeLib::GenericSVFilter<double>::process(double, double, double, int);
|
||||||
|
|
||||||
/// 12db Chamberlin State Variable Filter
|
/// 12db Chamberlin State Variable Filter
|
||||||
typedef GenericSVFilter<Data::AudioFrame> SVFilter;
|
typedef GenericSVFilter<Xybrid::Data::AudioFrame> SVFilter;
|
||||||
/// 12db Chamberlin State Variable Filter (mono version)
|
/// 12db Chamberlin State Variable Filter (mono version)
|
||||||
typedef GenericSVFilter<double> SVFilterM;
|
typedef GenericSVFilter<double> SVFilterM;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
#include "data/node.h"
|
#include "data/node.h"
|
||||||
#include "data/audioframe.h"
|
#include "data/audioframe.h"
|
||||||
|
|
||||||
#include "nodelib/svfilter.h"
|
#include "nodelib/svfilter.h"
|
||||||
#include "nodelib/param.h"
|
#include "nodelib/param.h"
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "data/node.h"
|
#include "data/node.h"
|
||||||
#include "data/audioframe.h"
|
#include "data/audioframe.h"
|
||||||
|
#include <array>
|
||||||
namespace Xybrid::Gadgets {
|
namespace Xybrid::Gadgets {
|
||||||
class QuickLevel : public Data::Node {
|
class QuickLevel : public Data::Node {
|
||||||
QContiguousCache<Data::AudioFrame> buf;
|
QContiguousCache<Data::AudioFrame> buf;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
using namespace Xybrid::Util;
|
using namespace Xybrid::Util;
|
||||||
|
|
||||||
std::pmr::synchronized_pool_resource Xybrid::Util::rpool; // instantiate
|
synchronized_pool_resource Xybrid::Util::rpool; // instantiate
|
||||||
decltype(Xybrid::Util::ralloc) Xybrid::Util::ralloc(&rpool);
|
decltype(Xybrid::Util::ralloc) Xybrid::Util::ralloc(&rpool);
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -15,7 +15,7 @@ void Xybrid::Util::reserveInitialPool() {
|
||||||
|
|
||||||
const constexpr size_t rsize = 1024*1024*128;
|
const constexpr size_t rsize = 1024*1024*128;
|
||||||
size_t bsize = rpool.options().largest_required_pool_block;
|
size_t bsize = rpool.options().largest_required_pool_block;
|
||||||
std::vector<void*> allocs;
|
vector<void*> allocs;
|
||||||
for (size_t ts = 0; ts < rsize; ts += bsize) {
|
for (size_t ts = 0; ts < rsize; ts += bsize) {
|
||||||
allocs.push_back(rpool.allocate(bsize));
|
allocs.push_back(rpool.allocate(bsize));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,32 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
#include <boost/container/pmr/memory_resource.hpp>
|
||||||
|
#include <boost/container/pmr/polymorphic_allocator.hpp>
|
||||||
|
#include <boost/container/pmr/synchronized_pool_resource.hpp>
|
||||||
|
#include <boost/container/vector.hpp>
|
||||||
|
using boost::container::pmr::synchronized_pool_resource;
|
||||||
|
using boost::container::pmr::polymorphic_allocator;
|
||||||
|
using boost::container::vector;
|
||||||
|
#else
|
||||||
#include <memory_resource>
|
#include <memory_resource>
|
||||||
|
using std::pmr::synchronized_pool_resource;
|
||||||
|
using std::pmr::polymorphic_allocator;
|
||||||
|
#endif
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
template <class Key,
|
||||||
|
class Hash = std::hash<Key>,
|
||||||
|
class Pred = std::equal_to<Key>>
|
||||||
|
using unordered_set = std::unordered_set<Key, Hash, Pred, polymorphic_allocator<Key>>;
|
||||||
|
#else
|
||||||
|
using std::pmr::unordered_set;
|
||||||
|
using std::vector;
|
||||||
|
#endif
|
||||||
namespace Xybrid::Util {
|
namespace Xybrid::Util {
|
||||||
extern std::pmr::synchronized_pool_resource rpool;
|
extern synchronized_pool_resource rpool;
|
||||||
extern std::pmr::polymorphic_allocator<std::max_align_t> ralloc;
|
extern polymorphic_allocator<std::max_align_t> ralloc;
|
||||||
|
|
||||||
void reserveInitialPool();
|
void reserveInitialPool();
|
||||||
|
|
||||||
|
@ -18,7 +38,7 @@ namespace Xybrid::Util {
|
||||||
std::list<slot[PSIZE]> pages;
|
std::list<slot[PSIZE]> pages;
|
||||||
|
|
||||||
std::deque<T*> avail;
|
std::deque<T*> avail;
|
||||||
std::pmr::unordered_set<T*> used = {rpool};
|
unordered_set<T*> used = {rpool};
|
||||||
|
|
||||||
void newPage() {
|
void newPage() {
|
||||||
auto p = pages.emplace_back();
|
auto p = pages.emplace_back();
|
||||||
|
|
|
@ -26,7 +26,7 @@ DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00
|
||||||
|
|
||||||
DISTFILES += ../.astylerc
|
DISTFILES += ../.astylerc
|
||||||
|
|
||||||
CONFIG += c++20
|
CONFIG += c++2a
|
||||||
|
|
||||||
# use all optimizations that won't generally interfere with debugging
|
# use all optimizations that won't generally interfere with debugging
|
||||||
QMAKE_CXXFLAGS_DEBUG += -Og
|
QMAKE_CXXFLAGS_DEBUG += -Og
|
||||||
|
@ -49,12 +49,12 @@ freebsd-clang {
|
||||||
|
|
||||||
macx: {
|
macx: {
|
||||||
DEFINES += WITH_BOOST
|
DEFINES += WITH_BOOST
|
||||||
LIBS += -L/usr/local/Cellar/boost/1.70.0/lib/ -lboost_math_tr1
|
LIBS += -L/Users/rachel/.nix-profile/lib -lboost_container -lboost_math_tr1
|
||||||
LIBS += -framework OpenGL
|
LIBS += -framework OpenGL
|
||||||
LIBS += -framework Foundation
|
LIBS += -framework Foundation
|
||||||
SOURCES +=
|
SOURCES +=
|
||||||
HEADERS +=
|
HEADERS +=
|
||||||
QMAKE_CXXFLAGS += -g -I/usr/local/Cellar/boost/1.70.0/include/
|
QMAKE_CXXFLAGS += -g -I/nix/store/gp7ascpyzsprb2i79kl5a22rmyawwscb-boost-1.77.0-dev/include
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue