46template<
typename T>
constexpr T
pi();
55 return 3.1415926535897932384626433832795f;
63 return 3.1415926535897932384626433832795;
71 return 3.1415926535897932384626433832795l;
87template<
typename T>
inline T
square(T x) {
return x*x; }
98 T f = 20;
if (power) f = 10;
100 return std::pow(base, L / f);
113 T f = 20;
if (power) f = 10;
114 return f * std::log10(x);
124 return angle * pi_div_180<T>();
134 return angle / pi_div_180<T>();
143 x = std::fmod(x, full);
144 if (x < 0) x += full;
154 if (x < 0) x += full;
161inline float wrap(
float x,
float full)
163 return fwrap(x, full);
169inline double wrap(
double x,
double full)
171 return fwrap(x, full);
177inline long double wrap(
long double x,
long double full)
179 return fwrap(x, full);
183inline T wrap_two_pi(T x)
187 return wrap(x, two * pi<T>());
199 while (power_of_2 < number) power_of_2 *= 2;
209inline typename std::iterator_traits<I>::value_type
212 using T =
typename std::iterator_traits<I>::value_type;
213 return std::accumulate(begin, end, T()
214 , [] (T current, T next) {
return std::max(current, std::abs(next)); });
223inline typename std::iterator_traits<I>::value_type
rms(I begin, I end)
225 using T =
typename std::iterator_traits<I>::value_type;
230 return std::sqrt(std::inner_product(begin, end, begin, T())
231 /
static_cast<T
>(std::distance(begin, end)));
240 while (first != last)
if (*first++ != 0)
return false;
251 using argument_type = T;
252 using result_type = T;
262 return std::cos(in * 2 * pi<T>() / _period) * half + half;
276template<
typename T,
typename U = T>
280 using argument_type = U;
281 using result_type = T;
289 , argument_type length = argument_type(1))
291 this->
set(first, last, length);
298 void set(result_type first, result_type last
299 , argument_type length = argument_type(1))
302 _increment = (last - first) / length;
308 return _first + result_type(x) * _increment;
312 result_type _first, _increment;
317linear_interpolator<T>
324template<
typename T,
typename U>
325linear_interpolator<T, U>
333struct identity {
const T& operator()(
const T& in) {
return in; } };
Function object for linear interpolation.
result_type operator()(argument_type x)
Function call operator.
void set(result_type first, result_type last, argument_type length=argument_type(1))
Set range and optional length.
linear_interpolator(result_type first, result_type last, argument_type length=argument_type(1))
Constructor with range and optional length.
linear_interpolator()
Default constructor.
Raised cosine (function object).
T operator()(T in) const
Function call operator.
raised_cosine(T period=0)
Constructor.
constexpr float pi< float >()
.
constexpr double pi< double >()
.
T rad2deg(T angle)
Convert an angle in radians to an angle in degrees.
T dB2linear(T L, bool power=false)
Convert a level in decibel to a linear gain factor.
T linear2dB(T x, bool power=false)
Convert a linear gain factor to a level in dB.
bool has_only_zeros(I first, I last)
Check if there are only zeros in a range.
T wrap(T x, T full)
Wrap x into the interval [0, full).
constexpr long double pi< long double >()
.
std::iterator_traits< I >::value_type rms(I begin, I end)
Root Mean Square (RMS) value of a series of numbers.
T fwrap(T x, T full)
Wrap x into the interval [0, full).
T square(T x)
Product of a number with itself.
T next_power_of_2(T number)
Find a power of 2 which is >= a given number.
std::iterator_traits< I >::value_type max_amplitude(I begin, I end)
Return the absolute maximum of a series of numbers.
T deg2rad(T angle)
Convert an angle in degrees to an angle in radians.
linear_interpolator< T > make_linear_interpolator(T first, T last)
Helper function for automatic template type deduction.
Audio Processing Framework.
Identity function object. Function call returns a const reference to input.