Skip to content

Commit

Permalink
Merge pull request #13628 from davidlmorris/AutoDj-CrossFader-Center
Browse files Browse the repository at this point in the history
Auto dj cross fader center
  • Loading branch information
daschuer authored Oct 9, 2024
2 parents 38e82db + 55a893a commit 833d91d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
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 @@ -812,12 +815,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 @@ -836,6 +841,7 @@ void AutoDJProcessor::playerPositionChanged(DeckAttributes* pAttributes,
double crossfaderTarget;
if (m_eState == ADJ_LEFT_FADING) {
crossfaderTarget = 1.0;

} else if (m_eState == ADJ_RIGHT_FADING) {
crossfaderTarget = -1.0;
} else {
Expand Down Expand Up @@ -1346,6 +1352,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 @@ -1445,6 +1452,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 @@ -286,6 +287,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

0 comments on commit 833d91d

Please sign in to comment.