get rid of ugly gcc diagnostic pragmas
parent
a7ece838f1
commit
b92dd4f3c5
7
notes
7
notes
|
@ -35,12 +35,7 @@ TODO {
|
||||||
about-license info
|
about-license info
|
||||||
}
|
}
|
||||||
|
|
||||||
more ui options for laptop stuff {
|
> add common oscillators to a nodelib header
|
||||||
- invert scrollwheel (knobs)
|
|
||||||
maybe scroll sensitivity
|
|
||||||
}
|
|
||||||
|
|
||||||
add common oscillators to a nodelib header
|
|
||||||
|
|
||||||
revert-to-saved menu action
|
revert-to-saved menu action
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,14 @@ class QCborValue;
|
||||||
|
|
||||||
namespace Xybrid::NodeLib {
|
namespace Xybrid::NodeLib {
|
||||||
// more precision than probably fits in a double, but it certainly shouldn't hurt
|
// more precision than probably fits in a double, but it certainly shouldn't hurt
|
||||||
const constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974;
|
const inline constexpr double PI = 3.141592653589793238462643383279502884197169399375105820974;
|
||||||
const constexpr double SEMI = 1.059463094359295264561825294946341700779204317494185628559;
|
const inline constexpr double SEMI = 1.059463094359295264561825294946341700779204317494185628559;
|
||||||
/// Multiplier to compensate for the balance equation
|
/// Multiplier to compensate for the balance equation
|
||||||
// (1.0 / cos(PI*0.25))
|
/// (1.0 / cos(PI*0.25))
|
||||||
const constexpr double PAN_MULT = 1.414213562373095048801688724209698078569671875376948073176;
|
const inline constexpr double PAN_MULT = 1.414213562373095048801688724209698078569671875376948073176;
|
||||||
|
|
||||||
/// Sane mimimum transition time to avoid clip artifacts
|
/// Sane mimimum transition time to avoid clip artifacts
|
||||||
const constexpr double shortStep = 0.0025;
|
const inline constexpr double shortStep = 0.0025;
|
||||||
struct ADSR {
|
struct ADSR {
|
||||||
double a = 0.0, d = 0.0, s = 1.0, r = 0.0;
|
double a = 0.0, d = 0.0, s = 1.0, r = 0.0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "util/ext.h"
|
||||||
|
|
||||||
|
namespace Xybrid::NodeLib {
|
||||||
|
namespace Oscillator {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
namespace Osc = Oscillator;
|
||||||
|
}
|
|
@ -18,6 +18,7 @@ using namespace Xybrid::Audio;
|
||||||
using namespace Xybrid::UI;
|
using namespace Xybrid::UI;
|
||||||
|
|
||||||
#include "util/strings.h"
|
#include "util/strings.h"
|
||||||
|
#include "util/ext.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
@ -49,12 +50,8 @@ namespace {
|
||||||
return m;
|
return m;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
// silence qtcreator warnings about gcc optimize attributes
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wattributes"
|
|
||||||
|
|
||||||
// polyBLEP algorithm (pulse antialiasing), slightly modified from https://www.kvraudio.com/forum/viewtopic.php?t=375517
|
// polyBLEP algorithm (pulse antialiasing), slightly modified from https://www.kvraudio.com/forum/viewtopic.php?t=375517
|
||||||
[[gnu::optimize("O3")]] double polyblep(double t, double dt) {
|
force_opt double polyblep(double t, double dt) {
|
||||||
// 0 <= t < 1
|
// 0 <= t < 1
|
||||||
if (t < dt) {
|
if (t < dt) {
|
||||||
t /= dt;
|
t /= dt;
|
||||||
|
@ -69,7 +66,7 @@ namespace {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] double oscPulse(double phase, double delta, double duty = 0.5) {
|
force_opt double oscPulse(double phase, double delta, double duty = 0.5) {
|
||||||
//double duty = 0.5 + std::cos(time * 2.5) * (1 - 0.125*2) * 0.5;
|
//double duty = 0.5 + std::cos(time * 2.5) * (1 - 0.125*2) * 0.5;
|
||||||
double d = 1.0;
|
double d = 1.0;
|
||||||
if (std::fmod(phase, 1.0) >= duty) d = -1.0;
|
if (std::fmod(phase, 1.0) >= duty) d = -1.0;
|
||||||
|
@ -78,13 +75,13 @@ namespace {
|
||||||
return d - (duty-0.5)*2; // DC offset compensation
|
return d - (duty-0.5)*2; // DC offset compensation
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] double oscTri(double phase) {
|
force_opt double oscTri(double phase) {
|
||||||
phase = std::fmod(phase + 0.75, 1.0);
|
phase = std::fmod(phase + 0.75, 1.0);
|
||||||
phase = phase * 0.2 + (std::floor(phase*32.0) / 32.0) * 0.8;
|
phase = phase * 0.2 + (std::floor(phase*32.0) / 32.0) * 0.8;
|
||||||
return std::abs(phase*2.0 - 1.0)*2.0 - 1.0;
|
return std::abs(phase*2.0 - 1.0)*2.0 - 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] double oscSaw(double phase, double delta) {
|
force_opt double oscSaw(double phase, double delta) {
|
||||||
phase = std::fmod(phase + 0.5, 1.0);
|
phase = std::fmod(phase + 0.5, 1.0);
|
||||||
double d = phase * 0.2 + (std::floor(phase*7.0) / 7.0 + (0.5/7.0)) * 0.8;
|
double d = phase * 0.2 + (std::floor(phase*7.0) / 7.0 + (0.5/7.0)) * 0.8;
|
||||||
d = d * 2.0 - 1.0;
|
d = d * 2.0 - 1.0;
|
||||||
|
@ -92,7 +89,6 @@ namespace {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
I2x03::I2x03() {
|
I2x03::I2x03() {
|
||||||
|
|
|
@ -18,6 +18,7 @@ using namespace Xybrid::Audio;
|
||||||
using namespace Xybrid::UI;
|
using namespace Xybrid::UI;
|
||||||
|
|
||||||
#include "util/strings.h"
|
#include "util/strings.h"
|
||||||
|
#include "util/ext.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -47,12 +48,8 @@ namespace {
|
||||||
return b * p + a * (1.0 - p);
|
return b * p + a * (1.0 - p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// silence qtcreator warnings about gcc optimize attributes
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wattributes"
|
|
||||||
|
|
||||||
// polyBLEP algorithm (pulse antialiasing), slightly modified from https://www.kvraudio.com/forum/viewtopic.php?t=375517
|
// polyBLEP algorithm (pulse antialiasing), slightly modified from https://www.kvraudio.com/forum/viewtopic.php?t=375517
|
||||||
[[gnu::optimize("O3")]] double polyblep(double t, double dt) {
|
force_opt double polyblep(double t, double dt) {
|
||||||
// 0 <= t < 1
|
// 0 <= t < 1
|
||||||
if (t < dt) {
|
if (t < dt) {
|
||||||
t /= dt;
|
t /= dt;
|
||||||
|
@ -67,7 +64,7 @@ namespace {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] inline double push(double in, double mod, double factor) {
|
force_opt inline double push(double in, double mod, double factor) {
|
||||||
double s = in < 0 ? -1 : 1;
|
double s = in < 0 ? -1 : 1;
|
||||||
in *= s;
|
in *= s;
|
||||||
//if (mod < 0) mod = 1.0/-mod;
|
//if (mod < 0) mod = 1.0/-mod;
|
||||||
|
@ -76,7 +73,7 @@ namespace {
|
||||||
return std::pow(in, mod)*s;
|
return std::pow(in, mod)*s;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] double oscSaw(double phase, double delta, double mod) {
|
force_opt double oscSaw(double phase, double delta, double mod) {
|
||||||
phase = std::fmod(phase + 0.5, 1.0);
|
phase = std::fmod(phase + 0.5, 1.0);
|
||||||
double d = phase;// * 0.2 + (std::floor(phase*7.0) / 7.0 + (0.5/7.0)) * 0.8;
|
double d = phase;// * 0.2 + (std::floor(phase*7.0) / 7.0 + (0.5/7.0)) * 0.8;
|
||||||
d = d * 2.0 - 1.0;
|
d = d * 2.0 - 1.0;
|
||||||
|
@ -85,9 +82,9 @@ namespace {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] double oscSine(double phase, double, double mod) { return push(std::sin(phase*PI*2), -mod, 5); }
|
force_opt double oscSine(double phase, double, double mod) { return push(std::sin(phase*PI*2), -mod, 5); }
|
||||||
|
|
||||||
[[gnu::optimize("O3")]] double oscPulse(double phase, double delta, double mod) {
|
force_opt double oscPulse(double phase, double delta, double mod) {
|
||||||
double duty = (mod+1.0)/2.0;
|
double duty = (mod+1.0)/2.0;
|
||||||
double d = 1.0;
|
double d = 1.0;
|
||||||
if (std::fmod(phase, 1.0) >= duty) d = -1.0;
|
if (std::fmod(phase, 1.0) >= duty) d = -1.0;
|
||||||
|
@ -96,9 +93,6 @@ namespace {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
// for clang on freebsd (and possibly other non-apple llvm sources) it seems we need to specify more.
|
// for clang on freebsd (and possibly other non-apple llvm sources) it seems we need to specify more.
|
||||||
// wave function list(s)
|
// wave function list(s)
|
||||||
const constexpr std::array<double(*)(double,double,double),3> waveFunc = {
|
const constexpr std::array<double(*)(double,double,double),3> waveFunc = {
|
||||||
|
|
|
@ -3,6 +3,26 @@
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
// gcc only, no clang to complain here pls
|
||||||
|
#if defined(__GNUC__) && !defined(__clang__)
|
||||||
|
#define force_opt __attribute__((optimize("3")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// things that work for gcc and clang
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define force_inline [[gnu::always_inline]]
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// and empty defs for these if not available for current compiler
|
||||||
|
#ifndef force_inline
|
||||||
|
#define force_inline
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef force_opt
|
||||||
|
#define force_opt
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
template<typename TO, typename FROM> inline constexpr TO hard_cast(FROM f) {
|
template<typename TO, typename FROM> inline constexpr TO hard_cast(FROM f) {
|
||||||
static_assert(std::is_pointer_v<TO> && std::is_pointer_v<FROM>);
|
static_assert(std::is_pointer_v<TO> && std::is_pointer_v<FROM>);
|
||||||
return reinterpret_cast<TO>( reinterpret_cast<void*>(f) );
|
return reinterpret_cast<TO>( reinterpret_cast<void*>(f) );
|
||||||
|
|
Loading…
Reference in New Issue