1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/sprout/compost/utility/rosenberg.hpp
2014-01-08 16:48:12 +09:00

35 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*=============================================================================
Copyright (c) 2011-2014 Bolero MURAKAMI
https://github.com/bolero-MURAKAMI/Sprout
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
#ifndef SPROUT_COMPOST_UTILITY_ROSENBERG_HPP
#define SPROUT_COMPOST_UTILITY_ROSENBERG_HPP
#include <sprout/config.hpp>
#include <sprout/detail/pow.hpp>
#include <sprout/type_traits/float_promote.hpp>
namespace sprout {
namespace compost {
//
// rosenberg_value
// Rosenberg 波は声門開大期と閉小期が周期の40%16%となる非対称形の波形でありτ1 が開大期τ2が閉小期を示す
//
template<typename T>
inline SPROUT_CONSTEXPR typename sprout::float_promote<T>::type
rosenberg_value(T x, T tau1, T tau2) {
typedef typename sprout::float_promote<T>::type type;
return x >= 0 && x <= tau1
? 3 * sprout::detail::pow2<type>(x / tau1) - 2 * sprout::detail::pow3<type>(x / tau1)
: x > tau1 && x <= tau1 + tau2
? 1 - sprout::detail::pow2<type>((x - tau1) / tau2)
: 0
;
}
} // namespace compost
} // namespace sprout
#endif // #ifndef SPROUT_COMPOST_UTILITY_ROSENBERG_HPP