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

Synchronize AutoDJ next deck with top track in queue #12909

Merged
merged 6 commits into from
Aug 20, 2024

Conversation

Bacadam
Copy link
Contributor

@Bacadam Bacadam commented Mar 3, 2024

This fixes bug #8956, adding a signal in playlisttablemodel which is emitted when a change in track order involves the first track. The signal is connected to a slot in autodjprocessor which skips the track in next deck, replacing it with the new top track in queue.

@JoergAtGithub
Copy link
Member

Welcome at Mixxx!
As a first-time contributor we need you to sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.

@ronso0
Copy link
Member

ronso0 commented Mar 3, 2024

I agree this is a bugfix, so this should go to the 2.4 branch.
@Bacadam please chnage the base branch here, and if there are unrelated commits shown also rebase your branch onto 2.4 and force-push.

Thank you!

Copy link
Member

@ronso0 ronso0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fix, works as desired.

@@ -275,6 +279,11 @@ void PlaylistTableModel::moveTrack(const QModelIndex& sourceIndex,
}

m_pTrackCollectionManager->internalCollection()->getPlaylistDAO().moveTrack(m_iPlaylistId, oldPosition, newPosition);

if (oldPosition==1 || newPosition==1) {
qDebug() << "First track changed";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO we don't need this debug message here, the one in AutoDJProcessor is sufficient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format is complaining here.
You can avoid these complains by installing
pre-commit
https://github.com/mixxxdj/mixxx/wiki/Using-Git#set-up-automatic-code-checking

@ronso0 ronso0 linked an issue Mar 3, 2024 that may be closed by this pull request
@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 4, 2024

Welcome at Mixxx! As a first-time contributor we need you to sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.

Thanks! I've signed it under the name Bacadam.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an issue:

  • Load the second track from the Auto-DJ playlist to the paused deck.
  • Now the we have an "inconsistent state"
  • Fix it by moving the track up.
  • The track disappears from the playlist and the original first track is loaded
    This should not happen.

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 4, 2024

Thank you for this fix, works as desired.

Thanks, I'll do the requested changes and the rebase tomorrow.

I have an issue:

* Load the second track from the Auto-DJ playlist to the paused deck.

* Now the we have an "inconsistent state"

* Fix it by moving the track up.

* The track disappears from the playlist and the original first track is loaded
  This should not happen.

Hum okay I will reproduce it and see what I can do.

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 6, 2024

Sorry, I force pushed before having change the base branch here and so Github bot added some irrelevant tags.

@JoergAtGithub
Copy link
Member

The pre-commit check is failing. The best way to fix pre-commit issues is to install pre-commit locally on your system, as described here: https://github.com/mixxxdj/mixxx/wiki/Using-Git#set-up-automatic-code-checking
Than it will fix these issues automatically before every commit.
Alternatively, you can download the pre-commit.patch file from the artifacts of this PR
grafik
unzip it, and apply it using:
git apply pre-commit.patch

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 12, 2024

Okay I've installed pre-commit and I think I solved all clang-format issues with last commit

@ronso0
Copy link
Member

ronso0 commented Mar 12, 2024

I think you can squash all three commits. (and force-push)

Did you manage to fix the issue @daschuer discovered?

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 12, 2024

The behavior @daschuer discovered is due to the calls to removeLoadedTrackFromTopOfQueue in skipNext.
I tried to copy all the skipNext code in the playlistFirstTrackChanged() slot, without the removeLoadedTrackFromTopOfQueue lines and it worked.

The question now is what are the checks in skipNext that are useful in our case and that must be done in the slot as well?

@ronso0
Copy link
Member

ronso0 commented Mar 12, 2024

I suggest to first squash the current state, push, then append an experimental commit so we can discuss the code in place.

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 14, 2024

I copied the skipNext code and kept what I think is useful. I tested it and it works.

Comment on lines 1677 to 1682
// if (!pLeftDeck || !pRightDeck) {
// // User has changed the orientation, disable Auto DJ
// toggleAutoDJ(false);
// emit autoDJError(ADJ_NOT_TWO_DECKS);
// return ADJ_NOT_TWO_DECKS;
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just don't know what to do with these commented lines as I don't know what deck orientation is, and how user can change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orientation is the side of the crossfader a deck is assigned to (left - center - right).

Not sure whether we need to do these checks here, I'd say no.

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 14, 2024

I found another thing that we can consider as a bug now that this synchronization is implemented.
When you right-click on tracks or playlists and select Add to AutoDJ (top) or Add to AutoDJ (replace), the track are added in second position, and so the next deck is not modified.

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 14, 2024

I found another thing that we can consider as a bug now that this synchronization is implemented. When you right-click on tracks or playlists and select Add to AutoDJ (top) or Add to AutoDJ (replace), the track are added in second position, and so the next deck is not modified.

The code responsible for that is in playlistdao.cpp, and I proposed a working solution.
The problem is I need to call my playlistFirstTrackChanged()slot from playlistdao.cppand I don't know what's the right way.
For my precedent commit to work, I changed playlistFirstTrackChanged() to public slot but that may not be a really good practice?

@daschuer
Copy link
Member

When you right-click on tracks or playlists and select Add to AutoDJ (top) or Add to AutoDJ (replace), the track are added in second position, and so the next deck is not modified.

I think that is the desired behavior. The use case is that the users may have already cued the track in the second deck, and just wants to collect some other tracks while browsing the library.

If hey want to play the track after the next they can load the track directly into the deck. So we have both cases covered.

@Bacadam
Copy link
Contributor Author

Bacadam commented Mar 26, 2024

Are we sure about that? If the users have selected the next track and browse more tracks, they probably want to add them to the end of the queue? Why would they especially want to add a track in third position?

If they use AutoDJ, they probably don't load directly in decks?

I might have a "music player" approach on that, this is how most music players work. But I can't tell for DJ softwares.

Anyway, what you prefer, I can revert my last commit if you want.

@Bacadam
Copy link
Contributor Author

Bacadam commented Apr 12, 2024

Okay I reverted my work on Add to AutoDJ buttons, so this PR is in a clean state.

@ronso0 ronso0 added this to the 2.4.2 milestone Apr 13, 2024
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you

@daschuer
Copy link
Member

@ronso0: Ready for merge?

@daschuer daschuer requested a review from ronso0 June 9, 2024 15:26
@@ -1665,6 +1669,20 @@ void AutoDJProcessor::playerRateChanged(DeckAttributes* pAttributes) {
calculateTransition(fromDeck, getOtherDeck(fromDeck), false);
}

void AutoDJProcessor::playlistFirstTrackChanged() {
qDebug() << this << "playlistFirstTrackChanged";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please wrap this in if constexpr (sDebug) { like the other debug logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for your feedback.

@Bacadam Bacadam requested a review from ronso0 August 1, 2024 13:04
@daschuer
Copy link
Member

@ronso0 Is this now merge-able?

@ronso0
Copy link
Member

ronso0 commented Aug 20, 2024

Yes, sorry for the delay, this looks good.
Thank you!

@ronso0 ronso0 merged commit 886efbe into mixxxdj:2.4 Aug 20, 2024
14 checks passed
@ronso0 ronso0 added the changelog This PR should be included in the changelog label Aug 20, 2024
@ronso0
Copy link
Member

ronso0 commented Aug 20, 2024

@daschuer do yo already have a changelog update ready, or shall I do one for this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autodj changelog This PR should be included in the changelog library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto DJ: Synchronizing queue's top item and next deck
4 participants