-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Auto dj cross fader center #13628
base: main
Are you sure you want to change the base?
Auto dj cross fader center #13628
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,15 +120,17 @@ AutoDJProcessor::AutoDJProcessor( | |
m_eState(ADJ_DISABLED), | ||
m_transitionProgress(0.0), | ||
m_transitionTime(kTransitionPreferenceDefault) { | ||
m_pAutoDJTableModel = new PlaylistTableModel(this, pTrackCollectionManager, | ||
"mixxx.db.model.autodj"); | ||
m_pAutoDJTableModel = new PlaylistTableModel( | ||
this, pTrackCollectionManager, "mixxx.db.model.autodj"); | ||
m_pAutoDJTableModel->selectPlaylist(iAutoDJPlaylistId); | ||
m_pAutoDJTableModel->select(); | ||
|
||
m_pShufflePlaylist = new ControlPushButton( | ||
ConfigKey("[AutoDJ]", "shuffle_playlist")); | ||
connect(m_pShufflePlaylist, &ControlPushButton::valueChanged, | ||
this, &AutoDJProcessor::controlShuffle); | ||
connect(m_pShufflePlaylist, | ||
&ControlPushButton::valueChanged, | ||
this, | ||
&AutoDJProcessor::controlShuffle); | ||
|
||
m_pSkipNext = new ControlPushButton( | ||
ConfigKey("[AutoDJ]", "skip_next")); | ||
|
@@ -566,6 +568,8 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) { | |
setCrossfader(1.0); | ||
} | ||
} | ||
m_crossfaderStartCenter = m_pConfig->getValue<bool>(ConfigKey(kConfigKey, | ||
QStringLiteral("center_xfader_when_starting_xfade"))); | ||
emitAutoDJStateChanged(m_eState); | ||
} else { // Disable Auto DJ | ||
m_pEnabledAutoDJ->setAndConfirm(0.0); | ||
|
@@ -832,6 +836,7 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes, | |
double crossfaderTarget; | ||
if (m_eState == ADJ_LEFT_FADING) { | ||
crossfaderTarget = 1.0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please revert this extra line |
||
|
||
} else if (m_eState == ADJ_RIGHT_FADING) { | ||
crossfaderTarget = -1.0; | ||
} else { | ||
|
@@ -859,17 +864,31 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes, | |
double transitionProgress = (thisPlayPosition - thisDeck->fadeBeginPos) / | ||
(thisDeck->fadeEndPos - thisDeck->fadeBeginPos); | ||
double transitionStep = transitionProgress - m_transitionProgress; | ||
|
||
if ((transitionProgress == 0.0) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if the == 0.0 state is always reached, because of rounding issues.i think it is more reliable to move this in an else branch of the condition below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed, this condition is never true and can be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After some testing (and an assert), I couldn't find this state being reached either. So I agree it can be removed. |
||
(m_crossfaderStartCenter)) { | ||
setCrossfader(0.0); // So we start at the mid point before we make any fader moves. | ||
} | ||
if (transitionStep > 0.0) { | ||
// We have made progress. | ||
// Backward seeks pause the transitions; forward seeks speed up | ||
// the transitions. If there has been a seek beyond endPos, end | ||
// the transition immediately. | ||
double remainingCrossfader = crossfaderTarget - currentCrossfader; | ||
double adjustment = remainingCrossfader / | ||
(1.0 - m_transitionProgress) * transitionStep; | ||
// we move the crossfader linearly with | ||
// movements in this track's play position. | ||
setCrossfader(currentCrossfader + adjustment); | ||
if ((m_crossfaderStartCenter) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Auto DJ should allow to adjust the Crossfader during a transition. So the code must be able to continue fading from any position. In this case I can imagine a emergency condition where the user realizes that he wants fade in and moves the xfader rapidly to the beginning. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This only happens once and the crossfader is now at the new position, so the user can adjust. |
||
(transitionProgress <= | ||
((thisDeck->fadeEndPos - | ||
thisDeck->fadeBeginPos) / | ||
2))) { | ||
// We want the cross fader to remain in the middle. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will constantly fight with the user. I think it is better to just not touch the crossfadere here. It will feel naturally if we fall back to the default mode when xfader is no longer in the expected center position. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should now be:
to make it clearer what is going on. In my testing, neither constantly fights the user. If the user moves the fader it goes there and completes the transition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can confirm that this readjust the user tweaks in some conditions. It happens because you compare here fractions of the full track length with fractions of the transition. I think the best solution is to move this code to Line 823 as
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please show the conditions. I can't find any in my testing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had a play around with this. And I think you are correct. It seems you only need to set the position of the crossfader to the middle once. And the best position would be just before the other desk starts playing. So I would propose this at around line 820:
The reason is that I noticed that occasionally the audio seems to just miss the very start of a track (I noticed it on a cold vocal start). This may have been a glitch in my system, so I cannot attest to this, but it seems the best thing to do in any event. |
||
setCrossfader(0.0); | ||
} else { | ||
double remainingCrossfader = crossfaderTarget - currentCrossfader; | ||
double adjustment = remainingCrossfader / | ||
(1.0 - m_transitionProgress) * transitionStep; | ||
// we move the crossfader linearly with | ||
// movements in this track's play position. | ||
setCrossfader(currentCrossfader + adjustment); | ||
} | ||
} | ||
m_transitionProgress = transitionProgress; | ||
// if we are at 1.0 here, we need an additional callback until the last | ||
|
@@ -1343,6 +1362,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck, | |
} | ||
|
||
switch (m_transitionMode) { | ||
// case TransitionMode::RadioFullIntroOutro: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I said elsewhere that is a comment form an earlier experiment, that I neglected to delete. |
||
case TransitionMode::FullIntroOutro: { | ||
// Use the outro or intro length for the transition time, whichever is | ||
// shorter. Let the full outro and intro play; do not cut off any part | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_crossfaderStartCenter should be also initialized in the constructor.
Currently we need to restart auto DJ to switch the modes. When it becomes a transition mode, it can be already changes on the fly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell AutoDj is instantiated just once at the program start, so I've made the change even if I think is a tad redundant for completeness. "Currently we need to restart auto DJ to switch the modes.", is true, like a lot of changes made in options.