From 651fa1845c84ed2eb8dd0855922347edf62c59f0 Mon Sep 17 00:00:00 2001 From: khodowany Date: Fri, 18 Sep 2026 17:51:21 -0500 Subject: [PATCH] Build Fix --- src/sequence.cpp | 2 +- tests/sequence.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/sequence.cpp b/src/sequence.cpp index d8f8bd9..e77682a 100644 --- a/src/sequence.cpp +++ b/src/sequence.cpp @@ -159,7 +159,7 @@ auto sonus::detail::sequence_player::render(std::float32_t *output, std::uint64_ } for (auto channel = std::uint32_t{}; channel < channels; ++channel) { auto &destination = output[frame * channels + channel]; - destination = std::clamp(destination + mixed * sequence.gain * gain, -1.0F, 1.0F); + destination = std::clamp(destination + mixed * sequence.gain * gain, -1.0F, 1.0F); } } if (current->frame == current->end_frame) { diff --git a/tests/sequence.cpp b/tests/sequence.cpp index 8a9f30a..55d9ccf 100644 --- a/tests/sequence.cpp +++ b/tests/sequence.cpp @@ -54,6 +54,24 @@ BOOST_AUTO_TEST_CASE(sequence_cancel_replace_and_independent_unisons) { BOOST_CHECK(!engine->play_sequence(value)); } +BOOST_AUTO_TEST_CASE(sequence_clips_overlapping_samples) { + auto engine = sonus::engine::create({.sample_rate = 48000U, .channels = 2U, .master_volume = 1.0F, .no_device = true}); + BOOST_REQUIRE(engine); + auto value = sonus::sample_sequence{.samples = {{.sample_rate = 48000U, .frames = {1.0F, -1.0F}, .loop_start = 0U, .loop_end = 2U}}, + .events = {{.sample = 0U, .duration_frames = 2U}, {.sample = 0U, .duration_frames = 2U}}, + .release_envelope = {1.0F, 0.0F}, + .duration_frames = 4U, + .max_voices = 2U, + .gain = 1.0F}; + auto session = engine->play_sequence(std::move(value)); + BOOST_REQUIRE(session); + auto output = std::array{}; + BOOST_REQUIRE(engine->render(output.data(), output.size() / 2U)); + auto expected = std::array{1.0F, 1.0F, -1.0F, -1.0F, 1.0F, 1.0F, 0.0F, 0.0F}; + BOOST_TEST(output == expected, boost::test_tools::per_element()); + BOOST_CHECK(session->status() == sonus::playback_status::COMPLETED); +} + BOOST_AUTO_TEST_CASE(sequence_concurrent_control) { auto engine = sonus::engine::create({.channels = 1U, .no_device = true}); BOOST_REQUIRE(engine);