+1
-1
@@ -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) {
|
for (auto channel = std::uint32_t{}; channel < channels; ++channel) {
|
||||||
auto &destination = output[frame * channels + channel];
|
auto &destination = output[frame * channels + channel];
|
||||||
destination = std::clamp(destination + mixed * sequence.gain * gain, -1.0F, 1.0F);
|
destination = std::clamp<std::float32_t>(destination + mixed * sequence.gain * gain, -1.0F, 1.0F);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (current->frame == current->end_frame) {
|
if (current->frame == current->end_frame) {
|
||||||
|
|||||||
@@ -54,6 +54,24 @@ BOOST_AUTO_TEST_CASE(sequence_cancel_replace_and_independent_unisons) {
|
|||||||
BOOST_CHECK(!engine->play_sequence(value));
|
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<std::float32_t, 8>{};
|
||||||
|
BOOST_REQUIRE(engine->render(output.data(), output.size() / 2U));
|
||||||
|
auto expected = std::array<std::float32_t, 8>{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) {
|
BOOST_AUTO_TEST_CASE(sequence_concurrent_control) {
|
||||||
auto engine = sonus::engine::create({.channels = 1U, .no_device = true});
|
auto engine = sonus::engine::create({.channels = 1U, .no_device = true});
|
||||||
BOOST_REQUIRE(engine);
|
BOOST_REQUIRE(engine);
|
||||||
|
|||||||
Reference in New Issue
Block a user