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

fix loop_remove #12521

Merged
merged 3 commits into from Jan 11, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions res/skins/LateNight/decks/deck_settings.xml
Expand Up @@ -31,10 +31,10 @@
<Layout>horizontal</Layout>
<Children>

<Template src="skins:LateNight/controls/button_2state.xml">
<Template src="skins:LateNight/controls/button_1state.xml">
<SetVariable name="TooltipId">slip_mode</SetVariable>
<SetVariable name="ObjectName">SlipmodeButton<Variable name="DeckGroup"/></SetVariable>
<SetVariable name="ConfigKey"><Variable name="Group"/>,slip_enabled</SetVariable>
<SetVariable name="ConfigKey"><Variable name="Group"/>,loop_remove</SetVariable>
<SetVariable name="Size">21f,18f</SetVariable>
</Template>

Expand Down
15 changes: 15 additions & 0 deletions src/engine/controls/loopingcontrol.cpp
Expand Up @@ -779,6 +779,21 @@ void LoopingControl::slotLoopRemove() {
m_loopInfo.setValue(loopInfo);
m_pCOLoopStartPosition->set(loopInfo.startPosition.toEngineSamplePosMaybeInvalid());
m_pCOLoopEndPosition->set(loopInfo.endPosition.toEngineSamplePosMaybeInvalid());
// The loop cue is stored by BaseTrackPlayerImpl::unloadTrack()
// if the loop is valid, else it is removed.
// We remove it here right away so the loop is not restored
// when the track is loaded to another player in the meantime.
auto pLoadedTrack = getEngineBuffer()->getLoadedTrack();
if (!pLoadedTrack) {
return;
}
const QList<CuePointer> cuePoints = pLoadedTrack->getCuePoints();
for (const auto& pCue : cuePoints) {
if (pCue->getType() == mixxx::CueType::Loop && pCue->getHotCue() == Cue::kNoHotCue) {
daschuer marked this conversation as resolved.
Show resolved Hide resolved
pLoadedTrack->removeCue(pCue);
return;
}
}
}

void LoopingControl::slotLoopIn(double pressed) {
Expand Down
24 changes: 13 additions & 11 deletions src/mixer/basetrackplayer.cpp
Expand Up @@ -355,26 +355,26 @@ TrackPointer BaseTrackPlayerImpl::unloadTrack() {
// nothing to do
return TrackPointer();
}

PlayerInfo::instance().setTrackInfo(getGroup(), TrackPointer());

// Save the loops that are currently set in a loop cue. If no loop cue is
// currently on the track, then create a new one.
// Save the loop that is currently to the loop cue. If no loop cue is
// currently on the track, create a new one.
// If the loop is invalid and a loop cue exists, remove it.
const auto loopStart =
mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
m_pLoopInPoint->get());
const auto loopEnd =
mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
m_pLoopOutPoint->get());
if (loopStart.isValid() && loopEnd.isValid() && loopStart <= loopEnd) {
CuePointer pLoopCue;
const QList<CuePointer> cuePoints = m_pLoadedTrack->getCuePoints();
for (const auto& pCue : cuePoints) {
if (pCue->getType() == mixxx::CueType::Loop && pCue->getHotCue() == Cue::kNoHotCue) {
pLoopCue = pCue;
break;
}
CuePointer pLoopCue;
const QList<CuePointer> cuePoints = m_pLoadedTrack->getCuePoints();
for (const auto& pCue : cuePoints) {
if (pCue->getType() == mixxx::CueType::Loop && pCue->getHotCue() == Cue::kNoHotCue) {
pLoopCue = pCue;
break;
}
}
if (loopStart.isValid() && loopEnd.isValid() && loopStart <= loopEnd) {
if (pLoopCue) {
pLoopCue->setStartAndEndPosition(loopStart, loopEnd);
} else {
Expand All @@ -384,6 +384,8 @@ TrackPointer BaseTrackPlayerImpl::unloadTrack() {
loopStart,
loopEnd);
}
} else if (pLoopCue) {
m_pLoadedTrack->removeCue(pLoopCue);
}

disconnectLoadedTrack();
Expand Down