26 std::lock_guard lock{mutex_};
27 buffer_.resize( frame_count, 0.0f );
28 if ( frame_count > 0 )
30 current_ = current_ % buffer_.size();
37 std::lock_guard lock{mutex_};
38 return buffer_.size();
43 std::lock_guard lock{mutex_};
44 if ( buffer_.empty() )
49 const auto y = buffer_[ current_ ];
50 buffer_[ current_ ] = x;
51 current_ = ( ++current_ ) % buffer_.size();
57 std::lock_guard lock{mutex_};
66 float gain() const noexcept
73 std::lock_guard lock{other.mutex_};
74 buffer_ = other.buffer_;
75 current_ = other.current_;
86 std::lock( mutex_, other.mutex_ );
87 std::lock_guard lock{mutex_, std::adopt_lock};
88 std::lock_guard lock_other{other.mutex_, std::adopt_lock};
90 buffer_ = other.buffer_;
91 current_ = other.current_;
97 void reset_unlocked() noexcept
99 for (
auto& entry : buffer_ )
105 mutable std::mutex mutex_;
106 std::vector< float > buffer_{};
111 template <
class Delay >
125 std::lock_guard lock{mutex_};
126 return std::accumulate( begin( delays_ ), end( delays_ ),
float( 0 ),
127 [&x](
float z,
auto& delay ) {
135 std::lock_guard lock{mutex_};
136 for (
auto& delay : delays_ )
144 std::lock_guard lock{mutex_};
145 for (
auto& delay : delays_ )
153 std::lock_guard lock{mutex_};
154 for (
auto& delay : delays_ )
156 delay.set_gain(
gain );
162 std::lock_guard lock{mutex_};
163 const auto non_empty = !delays_.empty();
166 non_empty ? delays_.front().gain() : 1.0f} );
171 std::vector< Delay > delays_{};
174 template <
class Delay >
182 const auto y = Delay::operator()( x );
183 return {( 1.0f - ratio_ ) * y, ratio_ * y};
size_type frame_count() const noexcept
Definition: delay.hpp:35
delay_t(size_type frame_count=0, float gain=1.0f)
Definition: delay.hpp:19
float operator()(float x) noexcept
Definition: delay.hpp:41
Definition: delay.hpp:175
void set_frame_count(std::vector< float >::size_type frame_count) noexcept
Definition: delay.hpp:133
typename Delay::size_type size_type
Definition: delay.hpp:115
void set_gain(float gain) noexcept
Definition: delay.hpp:61
float operator()(float x) noexcept
Definition: delay.hpp:123
void set_gain(float gain) noexcept
Definition: delay.hpp:151
std::vector< float >::size_type size_type
Definition: delay.hpp:17
void reset() noexcept
Definition: delay.hpp:142
void set_frame_count(size_type frame_count)
Definition: delay.hpp:24
float gain() const noexcept
Definition: delay.hpp:66
void set_delay_count(std::vector< delay_t >::size_type count)
Definition: delay.hpp:160
std::pair< float, float > operator()(float x) noexcept
Definition: delay.hpp:180
void set_stereo_ratio(float ratio) noexcept
Definition: delay.hpp:186
Definition: delay.hpp:112
void reset() noexcept
Definition: delay.hpp:55
repeated_delay_t(size_type delay_count=0, size_type frame_count=0, float gain=1.0f)
Definition: delay.hpp:117
delay_t & operator=(const delay_t &other)
Definition: delay.hpp:79
delay_t(const delay_t &other)
Definition: delay.hpp:71