mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
add compost auto_pan, vocal_cancelled
This commit is contained in:
parent
e588c4925a
commit
b7cf29d767
3 changed files with 213 additions and 0 deletions
|
@ -13,8 +13,10 @@
|
|||
#include <sprout/compost/effects/tremolo.hpp>
|
||||
#include <sprout/compost/effects/vibrato.hpp>
|
||||
#include <sprout/compost/effects/chorus.hpp>
|
||||
#include <sprout/compost/effects/auto_pan.hpp>
|
||||
#include <sprout/compost/effects/pseudo_stereo.hpp>
|
||||
#include <sprout/compost/effects/noise_gated.hpp>
|
||||
#include <sprout/compost/effects/vocal_cancelled.hpp>
|
||||
#include <sprout/compost/effects/superposed.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_COMPOST_EFFECTS_HPP
|
||||
|
|
158
sprout/compost/effects/auto_pan.hpp
Normal file
158
sprout/compost/effects/auto_pan.hpp
Normal file
|
@ -0,0 +1,158 @@
|
|||
#ifndef SPROUT_COMPOST_EFFECTS_AUTO_PAN_HPP
|
||||
#define SPROUT_COMPOST_EFFECTS_AUTO_PAN_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/math/constants.hpp>
|
||||
#include <sprout/math/sin.hpp>
|
||||
#include <sprout/range/adaptor/transformed.hpp>
|
||||
#include <sprout/range/adaptor/outdirected.hpp>
|
||||
#include <sprout/range/adaptor/indexed.hpp>
|
||||
#include <sprout/compost/formats/stereo.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace compost {
|
||||
//
|
||||
// auto_pan_outdirected_value
|
||||
//
|
||||
template<typename Value, typename IntType, bool IsLeft>
|
||||
struct auto_pan_outdirected_value {
|
||||
public:
|
||||
typedef Value value_type;
|
||||
typedef IntType int_type;
|
||||
private:
|
||||
value_type depth_;
|
||||
value_type rate_;
|
||||
int_type samples_per_sec_;
|
||||
private:
|
||||
template<bool Left, typename Outdirected>
|
||||
SPROUT_CONSTEXPR typename std::enable_if<
|
||||
Left,
|
||||
typename std::iterator_traits<Outdirected>::value_type
|
||||
>::type
|
||||
calc(Outdirected const& x) const {
|
||||
return (1 + depth_ * sprout::sin(2 * sprout::math::pi<Value>() * rate_ * x.index() / samples_per_sec_)) * *x;
|
||||
}
|
||||
template<bool Left, typename Outdirected>
|
||||
SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!Left,
|
||||
typename std::iterator_traits<Outdirected>::value_type
|
||||
>::type
|
||||
calc(Outdirected const& x) const {
|
||||
return (1 + depth_ * sprout::sin(2 * sprout::math::pi<Value>() * rate_ * x.index() / samples_per_sec_ + sprout::math::pi<Value>())) * *x;
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR auto_pan_outdirected_value(
|
||||
value_type const& depth, value_type const& rate,
|
||||
int_type samples_per_sec = 44100
|
||||
)
|
||||
: depth_(depth), rate_(rate), samples_per_sec_(samples_per_sec)
|
||||
{}
|
||||
template<typename Outdirected>
|
||||
SPROUT_CONSTEXPR typename std::iterator_traits<Outdirected>::value_type
|
||||
operator()(Outdirected const& x) const {
|
||||
return calc<IsLeft>(x);
|
||||
}
|
||||
};
|
||||
|
||||
namespace effects {
|
||||
//
|
||||
// auto_pan_holder
|
||||
//
|
||||
template<typename T, typename IntType = int>
|
||||
class auto_pan_holder {
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef IntType int_type;
|
||||
private:
|
||||
value_type depth_;
|
||||
value_type rate_;
|
||||
int_type samples_per_sec_;
|
||||
public:
|
||||
auto_pan_holder() = default;
|
||||
auto_pan_holder(auto_pan_holder const&) = default;
|
||||
SPROUT_CONSTEXPR auto_pan_holder(
|
||||
value_type const& depth, value_type const& rate,
|
||||
int_type samples_per_sec = 44100
|
||||
)
|
||||
: depth_(depth), rate_(rate), samples_per_sec_(samples_per_sec)
|
||||
{}
|
||||
SPROUT_CONSTEXPR value_type const& depth() const {
|
||||
return depth_;
|
||||
}
|
||||
SPROUT_CONSTEXPR value_type const& rate() const {
|
||||
return rate_;
|
||||
}
|
||||
SPROUT_CONSTEXPR int_type const& samples_per_sec() const {
|
||||
return samples_per_sec_;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// auto_pan_forwarder
|
||||
//
|
||||
class auto_pan_forwarder {
|
||||
public:
|
||||
template<typename T, typename IntType>
|
||||
SPROUT_CONSTEXPR sprout::compost::effects::auto_pan_holder<T, IntType>
|
||||
operator()(T const& depth, T const& rate, IntType samples_per_sec) {
|
||||
return sprout::compost::effects::auto_pan_holder<T, IntType>(depth, rate, samples_per_sec);
|
||||
}
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR sprout::compost::effects::auto_pan_holder<T>
|
||||
operator()(T const& depth, T const& rate) {
|
||||
return sprout::compost::effects::auto_pan_holder<T>(depth, rate);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// auto_pan
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::compost::effects::auto_pan_forwarder auto_pan{};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename Range, typename T, typename IntType>
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
operator|(Range&& lhs, sprout::compost::effects::auto_pan_holder<T, IntType> const& rhs)
|
||||
-> decltype(
|
||||
sprout::forward<Range>(lhs)
|
||||
| sprout::adaptors::indexed | sprout::adaptors::outdirected
|
||||
| sprout::adaptors::transformed(
|
||||
sprout::compost::auto_pan_outdirected_value<T, IntType, true>(rhs.depth(), rhs.rate(), rhs.samples_per_sec())
|
||||
)
|
||||
| sprout::compost::formats::stereo(
|
||||
sprout::forward<Range>(lhs)
|
||||
| sprout::adaptors::indexed | sprout::adaptors::outdirected
|
||||
| sprout::adaptors::transformed(
|
||||
sprout::compost::auto_pan_outdirected_value<T, IntType, false>(rhs.depth(), rhs.rate(), rhs.samples_per_sec())
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
return sprout::forward<Range>(lhs)
|
||||
| sprout::adaptors::indexed | sprout::adaptors::outdirected
|
||||
| sprout::adaptors::transformed(
|
||||
sprout::compost::auto_pan_outdirected_value<T, IntType, true>(rhs.depth(), rhs.rate(), rhs.samples_per_sec())
|
||||
)
|
||||
| sprout::compost::formats::stereo(
|
||||
sprout::forward<Range>(lhs)
|
||||
| sprout::adaptors::indexed | sprout::adaptors::outdirected
|
||||
| sprout::adaptors::transformed(
|
||||
sprout::compost::auto_pan_outdirected_value<T, IntType, false>(rhs.depth(), rhs.rate(), rhs.samples_per_sec())
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
} // namespace effects
|
||||
|
||||
using sprout::compost::effects::auto_pan;
|
||||
} // namespace compost
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_COMPOST_EFFECTS_AUTO_PAN_HPP
|
53
sprout/compost/effects/vocal_cancelled.hpp
Normal file
53
sprout/compost/effects/vocal_cancelled.hpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#ifndef SPROUT_COMPOST_EFFECTS_VOCAL_CANCELLED_HPP
|
||||
#define SPROUT_COMPOST_EFFECTS_VOCAL_CANCELLED_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/functional/minus.hpp>
|
||||
#include <sprout/range/adaptor/transformed.hpp>
|
||||
#include <sprout/compost/formats/left_channel.hpp>
|
||||
#include <sprout/compost/formats/right_channel.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace compost {
|
||||
namespace effects {
|
||||
//
|
||||
// vocal_cancelled_forwarder
|
||||
//
|
||||
class vocal_cancelled_forwarder {};
|
||||
|
||||
//
|
||||
// vocal_cancelled
|
||||
//
|
||||
namespace {
|
||||
SPROUT_STATIC_CONSTEXPR sprout::compost::effects::vocal_cancelled_forwarder vocal_cancelled{};
|
||||
} // anonymous-namespace
|
||||
|
||||
//
|
||||
// operator|
|
||||
//
|
||||
template<typename Range>
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
operator|(Range&& lhs, sprout::compost::effects::vocal_cancelled_forwarder const& rhs)
|
||||
-> decltype(
|
||||
sprout::lvalue_forward<Range>(lhs) | sprout::compost::formats::left_channel
|
||||
| sprout::adaptors::transformed(
|
||||
sprout::lvalue_forward<Range>(lhs) | sprout::compost::formats::right_channel,
|
||||
sprout::minus<>()
|
||||
)
|
||||
)
|
||||
{
|
||||
return sprout::lvalue_forward<Range>(lhs) | sprout::compost::formats::left_channel
|
||||
| sprout::adaptors::transformed(
|
||||
sprout::lvalue_forward<Range>(lhs) | sprout::compost::formats::right_channel,
|
||||
sprout::minus<>()
|
||||
)
|
||||
;
|
||||
}
|
||||
} // namespace effects
|
||||
|
||||
using sprout::compost::effects::vocal_cancelled;
|
||||
} // namespace compost
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_COMPOST_EFFECTS_VOCAL_CANCELLED_HPP
|
Loading…
Reference in a new issue