Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle setting loop_in and loop_out at the same position #11771

Merged
merged 3 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void LoopingControl::setLoopInToCurrentPosition() {
// Reset the loop out position if it is before the loop in so that loops
// cannot be inverted.
if (loopSamples.end != kNoTrigger &&
loopSamples.end < pos) {
loopSamples.end <= pos) {
loopSamples.end = kNoTrigger;
m_pCOLoopEndPosition->set(kNoTrigger);
if (m_bLoopingEnabled) {
Expand Down Expand Up @@ -702,7 +702,7 @@ void LoopingControl::setLoopOutToCurrentPosition() {

// If the user is trying to set a loop-out before the loop in or without
// having a loop-in, then ignore it.
if (loopSamples.start == kNoTrigger || pos < loopSamples.start) {
if (loopSamples.start == kNoTrigger || pos <= loopSamples.start) {
return;
}

Expand Down
22 changes: 22 additions & 0 deletions src/test/looping_control_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ TEST_F(LoopingControlTest, LoopInSetAfterLoopOutStops) {
EXPECT_EQ(-1, m_pLoopEndPoint->get());
}

TEST_F(LoopingControlTest, LoopInSetAtLoopOutClearsLoopOut) {
m_pLoopStartPoint->slotSet(0);
m_pLoopEndPoint->slotSet(100);
m_pLoopStartPoint->slotSet(100);
EXPECT_EQ(100, m_pLoopStartPoint->get());
EXPECT_EQ(-1, m_pLoopEndPoint->get());
EXPECT_FALSE(isLoopEnabled());
}

TEST_F(LoopingControlTest, LoopOutSetAtLoopInIgnored) {
m_pLoopStartPoint->slotSet(0);
m_pLoopEndPoint->slotSet(100);
m_pLoopEndPoint->slotSet(0);
EXPECT_EQ(0, m_pLoopStartPoint->get());
EXPECT_EQ(100, m_pLoopEndPoint->get());
m_pLoopEndPoint->slotSet(-1);
EXPECT_EQ(-1, m_pLoopEndPoint->get());
m_pLoopEndPoint->slotSet(0);
EXPECT_FALSE(isLoopEnabled());
EXPECT_EQ(-1, m_pLoopEndPoint->get());
}

TEST_F(LoopingControlTest, LoopOutSetInsideLoopContinues) {
m_pLoopStartPoint->slotSet(0);
m_pLoopEndPoint->slotSet(100);
Expand Down