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

Auto dj cross fader center #13628

Merged
merged 2 commits into from
Oct 9, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -169,6 +171,7 @@ AutoDJProcessor::AutoDJProcessor(

m_pCOCrossfader = new ControlProxy("[Master]", "crossfader");
m_pCOCrossfaderReverse = new ControlProxy("[Mixer Profile]", "xFaderReverse");
m_crossfaderStartCenter = false;

QString str_autoDjTransition = m_pConfig->getValueString(
ConfigKey(kConfigKey, kTransitionPreferenceName));
Expand Down Expand Up @@ -808,12 +811,14 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,
otherDeck->setPlayPosition(otherDeck->startPos);
}

if (!otherDeckPlaying) {
otherDeck->play();
if (m_crossfaderStartCenter) {
setCrossfader(0.0);
} else if (thisDeck->fadeBeginPos >= thisDeck->fadeEndPos) {
setCrossfader(thisDeck->isLeft() ? 1.0 : -1.0);
}

if (thisDeck->fadeBeginPos >= thisDeck->fadeEndPos) {
setCrossfader(thisDeck->isLeft() ? 1.0 : -1.0);
if (!otherDeckPlaying) {
otherDeck->play();
}

// Now that we have started the other deck playing, remove the track
Expand All @@ -832,6 +837,7 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,
double crossfaderTarget;
if (m_eState == ADJ_LEFT_FADING) {
crossfaderTarget = 1.0;
Copy link
Member

Choose a reason for hiding this comment

The 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 {
Expand Down Expand Up @@ -1342,6 +1348,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
<< "outroLength" << outroLength;
}

m_crossfaderStartCenter = false;
switch (m_transitionMode) {
case TransitionMode::FullIntroOutro: {
// Use the outro or intro length for the transition time, whichever is
Expand Down Expand Up @@ -1441,6 +1448,10 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, toDeckStartSeconds);
}
} break;
case TransitionMode::FixedStartCenterSkipSilence:
m_crossfaderStartCenter = true;
// fall through intended!
[[fallthrough]];
case TransitionMode::FixedSkipSilence: {
double toDeckStartSecond;
pToDeck->fadeBeginPos = getLastSoundSecond(pToDeck);
Expand Down
4 changes: 3 additions & 1 deletion src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class AutoDJProcessor : public QObject {
FullIntroOutro,
FadeAtOutroStart,
FixedFullTrack,
FixedSkipSilence
FixedSkipSilence,
FixedStartCenterSkipSilence
};

AutoDJProcessor(QObject* pParent,
Expand Down Expand Up @@ -285,6 +286,7 @@ class AutoDJProcessor : public QObject {
double m_transitionProgress;
double m_transitionTime; // the desired value set by the user
TransitionMode m_transitionMode;
bool m_crossfaderStartCenter;

QList<DeckAttributes*> m_decks;

Expand Down
8 changes: 7 additions & 1 deletion src/library/autodj/dlgautodj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent,
"Skip Silence:\n"
"Play the whole track except for silence at the beginning and end.\n"
"Begin crossfading from the selected number of seconds before the\n"
"last sound.");
"last sound.\n"
"\n"
"Skip Silence:\n"
"The same as Skip Silence, but starting transitions with a centered\n"
"crossfader, so that the intro starts at full volume.\n");

pushButtonFadeNow->setToolTip(fadeBtnTooltip);
pushButtonSkipNext->setToolTip(skipBtnTooltip);
Expand Down Expand Up @@ -179,6 +183,8 @@ DlgAutoDJ::DlgAutoDJ(WLibrary* parent,
static_cast<int>(AutoDJProcessor::TransitionMode::FixedFullTrack));
fadeModeCombobox->addItem(tr("Skip Silence"),
static_cast<int>(AutoDJProcessor::TransitionMode::FixedSkipSilence));
fadeModeCombobox->addItem(tr("Skip Silence Start Full Volume"),
static_cast<int>(AutoDJProcessor::TransitionMode::FixedStartCenterSkipSilence));
fadeModeCombobox->setCurrentIndex(
fadeModeCombobox->findData(static_cast<int>(m_pAutoDJProcessor->getTransitionMode())));
connect(fadeModeCombobox,
Expand Down
Loading