#include #include #include namespace psemek::audio { stream_ptr fade_out(stream_ptr stream, duration length, duration start) { return envelope_base(std::move(stream), [start, length](duration time){ return math::clamp(static_cast(length.frames() + start.frames() - time.frames()) / length.frames(), {0.f, 1.f}); }, start + length); } }