AME
ame_Util.hpp File Reference

Some utilities functions. More...

#include "ame_Math.hpp"
#include <array>
#include <atomic>
#include <cassert>
#include <concepts>
#include <cstddef>
#include <type_traits>
Include dependency graph for ame_Util.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ame::Range< T >
 範囲を表す構造体. More...
 
class  ame::LinearSmoothedValue< FloatType >
 Smooth values linearly. More...
 
class  ame::Slide< FloatType >
 Smooth values logarithmically. More...
 
class  ame::Wrap< T >
 A number to wrap between 0~length. More...
 

Functions

template<std::floating_point FloatType>
constexpr FloatType ame::addModulo2Pi (FloatType phase, FloatType increment) noexcept
 Increment the phase and returns in the range of 0~2pi. More...
 
template<std::floating_point FloatType>
constexpr FloatType ame::scale (FloatType sourceValue, FloatType sourceRangeMin, FloatType sourceRangeMax, FloatType targetRangeMin, FloatType targetRangeMax)
 Map values to an output range. More...
 
template<typename... Ts>
constexpr std::array< std::byte, sizeof...(Ts)> ame::makeBytes (Ts &&... args) noexcept
 Generate a std::array<std::byte, N> More...
 

Detailed Description

Some utilities functions.

Author
Akiyuki Okayasu (akiyu.nosp@m.ki.o.nosp@m.kayas.nosp@m.u@gm.nosp@m.ail.c.nosp@m.om)

AME is released under the MIT license.

Function Documentation

◆ addModulo2Pi()

template<std::floating_point FloatType>
constexpr FloatType ame::addModulo2Pi ( FloatType  phase,
FloatType  increment 
)
constexprnoexcept

Increment the phase and returns in the range of 0~2pi.

Template Parameters
FloatTypefloat or double
Parameters
phase
incrementAmount to add to phase
Returns
[0, 2pi]

◆ makeBytes()

template<typename... Ts>
constexpr std::array< std::byte, sizeof...(Ts)> ame::makeBytes ( Ts &&...  args)
constexprnoexcept

Generate a std::array<std::byte, N>

std::array<std::byte, 2> b = {0x00, 0xFF}; will cause an error due to implicit casting from int to std::byte. std::array<std::byte, 2> b = {std::byte{0x00}, std::byte{0xFF}}; does not cause an error, but it is tedious, so make_bytes(0x00, 0xFF) can be used to generate it.

constexpr std::array<std::byte, 2> arr = makeBytes(0x00, 0xFF);
// or
constexpr auto arr = makeBytes(0x00, 0xFF);
constexpr std::array< std::byte, sizeof...(Ts)> makeBytes(Ts &&... args) noexcept
Generate a std::array<std::byte, N>
Definition: ame_Util.hpp:380
Template Parameters
TsInteger types. It must be able to be cast to std::byte.
Parameters
argsIntegers to convert to std::byte array
Returns
constexpr std::array<std::byte, sizeof...(Ts)>

◆ scale()

template<std::floating_point FloatType>
constexpr FloatType ame::scale ( FloatType  sourceValue,
FloatType  sourceRangeMin,
FloatType  sourceRangeMax,
FloatType  targetRangeMin,
FloatType  targetRangeMax 
)
constexpr

Map values to an output range.

Template Parameters
FloatTypefloat or double
Parameters
sourceValueinput value
sourceRangeMininput range min
sourceRangeMaxinput range Max
targetRangeMinoutput range min
targetRangeMaxoutput range Max
Returns
scaled value