kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 429aef491a9d9641ddd83f452ea39ab3cbe9360f
parent 4bafdafcb4295144208b96e8c5a4d4db4e521f3d
Author: [email protected] <[email protected]>
Date:   Tue, 27 Dec 2022 16:10:07 +0000

Fix sine and others not accepting scalar refs

Diffstat:
Minclude/kfr/dsp/oscillators.hpp | 28++++++++++++++--------------
Minclude/kfr/dsp/waveshaper.hpp | 4++--
Minclude/kfr/dsp/weighting.hpp | 6+++---
Mtests/dsp_test.cpp | 7+++++++
4 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/include/kfr/dsp/oscillators.hpp b/include/kfr/dsp/oscillators.hpp @@ -144,7 +144,7 @@ KFR_FUNCTION T1 rawsine(const T1& x) { return intrinsics::rawsine(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::rawsine, E1> rawsine(E1&& x) { return { std::forward<E1>(x) }; @@ -154,7 +154,7 @@ KFR_FUNCTION T1 sine(const T1& x) { return intrinsics::sine(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::sine, E1> sine(E1&& x) { return { std::forward<E1>(x) }; @@ -164,7 +164,7 @@ KFR_FUNCTION T1 sinenorm(const T1& x) { return intrinsics::sinenorm(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::sinenorm, E1> sinenorm(E1&& x) { return { fn::sinenorm(), std::forward<E1>(x) }; @@ -174,7 +174,7 @@ KFR_FUNCTION T1 rawsquare(const T1& x) { return intrinsics::rawsquare(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::rawsquare, E1> rawsquare(E1&& x) { return { fn::rawsquare(), std::forward<E1>(x) }; @@ -184,7 +184,7 @@ KFR_FUNCTION T1 square(const T1& x) { return intrinsics::square(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::square, E1> square(E1&& x) { return { fn::square(), std::forward<E1>(x) }; @@ -194,7 +194,7 @@ KFR_FUNCTION T1 squarenorm(const T1& x) { return intrinsics::squarenorm(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::squarenorm, E1> squarenorm(E1&& x) { return { fn::squarenorm(), std::forward<E1>(x) }; @@ -204,7 +204,7 @@ KFR_FUNCTION T1 rawtriangle(const T1& x) { return intrinsics::rawtriangle(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::rawtriangle, E1> rawtriangle(E1&& x) { return { fn::rawtriangle(), std::forward<E1>(x) }; @@ -214,7 +214,7 @@ KFR_FUNCTION T1 triangle(const T1& x) { return intrinsics::triangle(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::triangle, E1> triangle(E1&& x) { return { fn::triangle(), std::forward<E1>(x) }; @@ -224,7 +224,7 @@ KFR_FUNCTION T1 trianglenorm(const T1& x) { return intrinsics::trianglenorm(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::trianglenorm, E1> trianglenorm(E1&& x) { return { fn::trianglenorm(), std::forward<E1>(x) }; @@ -234,7 +234,7 @@ KFR_FUNCTION T1 rawsawtooth(const T1& x) { return intrinsics::rawsawtooth(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::rawsawtooth, E1> rawsawtooth(E1&& x) { return { fn::rawsawtooth(), std::forward<E1>(x) }; @@ -244,7 +244,7 @@ KFR_FUNCTION T1 sawtooth(const T1& x) { return intrinsics::sawtooth(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::sawtooth, E1> sawtooth(E1&& x) { return { fn::sawtooth(), std::forward<E1>(x) }; @@ -254,7 +254,7 @@ KFR_FUNCTION T1 sawtoothnorm(const T1& x) { return intrinsics::sawtoothnorm(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::sawtoothnorm, E1> sawtoothnorm(E1&& x) { return { fn::sawtoothnorm(), std::forward<E1>(x) }; @@ -264,7 +264,7 @@ KFR_FUNCTION T1 isawtooth(const T1& x) { return intrinsics::isawtooth(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::isawtooth, E1> isawtooth(E1&& x) { return { fn::isawtooth(), std::forward<E1>(x) }; @@ -274,7 +274,7 @@ KFR_FUNCTION T1 isawtoothnorm(const T1& x) { return intrinsics::isawtoothnorm(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::isawtoothnorm, E1> isawtoothnorm(E1&& x) { return { fn::isawtoothnorm(), std::forward<E1>(x) }; diff --git a/include/kfr/dsp/waveshaper.hpp b/include/kfr/dsp/waveshaper.hpp @@ -63,13 +63,13 @@ KFR_FUNCTION flt_type<T1> saturate_II(const T1& x) } KFR_FN(saturate_II) -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::saturate_II, E1> saturate_I(E1&& x) { return { fn::saturate_I(), std::forward<E1>(x) }; } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_FUNCTION expression_function<fn::saturate_II, E1> saturate_II(E1&& x) { return { fn::saturate_II(), std::forward<E1>(x) }; diff --git a/include/kfr/dsp/weighting.hpp b/include/kfr/dsp/weighting.hpp @@ -103,7 +103,7 @@ KFR_INTRINSIC T1 aweighting(const T1& x) return intrinsics::aweighting(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_INTRINSIC expression_function<fn::aweighting, E1> aweighting(E1&& x) { return { fn::aweighting(), std::forward<E1>(x) }; @@ -115,7 +115,7 @@ KFR_INTRINSIC T1 bweighting(const T1& x) return intrinsics::bweighting(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_INTRINSIC expression_function<fn::bweighting, E1> bweighting(E1&& x) { return { fn::bweighting(), std::forward<E1>(x) }; @@ -127,7 +127,7 @@ KFR_INTRINSIC T1 cweighting(const T1& x) return intrinsics::cweighting(x); } -template <typename E1, KFR_ENABLE_IF(is_input_expression<E1>)> +template <typename E1, KFR_ACCEPT_EXPRESSIONS(E1)> KFR_INTRINSIC expression_function<fn::cweighting, E1> cweighting(E1&& x) { return { fn::cweighting(), std::forward<E1>(x) }; diff --git a/tests/dsp_test.cpp b/tests/dsp_test.cpp @@ -66,6 +66,13 @@ TEST(mixdown_stereo) CHECK_EXPRESSION(side, 21, [](size_t i) { return i - (i * 2.0 + 100.0); }); } +TEST(sine_type) +{ + double ph = 0.0; + using T = decltype(sine(ph)); + static_assert(std::is_same_v<T, double>); +} + TEST(phasor) { constexpr fbase sr = 44100.0;