Rename envelope -> envelope_base

This commit is contained in:
Nikita Lisitsa 2026-07-18 21:37:58 +03:00
parent c177911737
commit 2d66f12707
3 changed files with 10 additions and 8 deletions

View file

@ -8,10 +8,10 @@ namespace psemek::audio
{
template <typename EnvelopeFn>
struct envelope_impl
struct envelope_base_impl
: stream
{
envelope_impl(stream_ptr stream, EnvelopeFn envelope_fn, std::optional<duration> truncate)
envelope_base_impl(stream_ptr stream, EnvelopeFn envelope_fn, std::optional<duration> truncate)
: stream_(std::move(stream))
, envelope_fn_(std::move(envelope_fn))
, remaining_(truncate ? std::optional{truncate->samples()} : std::nullopt)
@ -59,9 +59,11 @@ namespace psemek::audio
}
// Guaranteed to call envelope_fn exactly once per audio frame
template <typename EnvelopeFn>
stream_ptr envelope(stream_ptr stream, EnvelopeFn envelope_fn, std::optional<duration> truncate = {})
stream_ptr envelope_base(stream_ptr stream, EnvelopeFn envelope_fn, std::optional<duration> truncate = {})
{
return std::make_shared<envelope_impl<EnvelopeFn>>(std::move(stream), std::move(envelope_fn), truncate);
return std::make_shared<envelope_base_impl<EnvelopeFn>>(std::move(stream), std::move(envelope_fn), truncate);
}
}

View file

@ -1,5 +1,5 @@
#include <psemek/audio/effect/fade_out.hpp>
#include <psemek/audio/effect/envelope.hpp>
#include <psemek/audio/effect/envelope_base.hpp>
#include <psemek/math/interval.hpp>
namespace psemek::audio
@ -7,7 +7,7 @@ namespace psemek::audio
stream_ptr fade_in(stream_ptr stream, duration length, duration start)
{
return envelope(std::move(stream), [start, length](duration time){
return envelope_base(std::move(stream), [start, length](duration time){
return math::clamp(static_cast<float>(time.frames() - start.frames()) / length.frames(), {0.f, 1.f});
});
}

View file

@ -1,5 +1,5 @@
#include <psemek/audio/effect/fade_out.hpp>
#include <psemek/audio/effect/envelope.hpp>
#include <psemek/audio/effect/envelope_base.hpp>
#include <psemek/math/interval.hpp>
namespace psemek::audio
@ -7,7 +7,7 @@ namespace psemek::audio
stream_ptr fade_out(stream_ptr stream, duration length, duration start)
{
return envelope(std::move(stream), [start, length](duration time){
return envelope_base(std::move(stream), [start, length](duration time){
return math::clamp(static_cast<float>(length.frames() + start.frames() - time.frames()) / length.frames(), {0.f, 1.f});
}, start + length);
}