Skip to content

Commit

Permalink
Replace atomic CO with stem selection to change the load behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Nov 17, 2024
1 parent f439645 commit 74382c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
54 changes: 32 additions & 22 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,13 @@ LoadToGroupController::LoadToGroupController(LibraryControl* pParent, const QStr
&LoadToGroupController::slotLoadToGroupAndPlay);

#ifdef __STEM__
m_loadSelectedTrackStems =
std::make_unique<ControlPushButton>(ConfigKey(group, "load_selected_track_stems"));
connect(m_loadSelectedTrackStems.get(),
&ControlObject::valueChanged,
this,
[this](double value) {
if (value >= 0 && value <= 2 << mixxx::kMaxSupportedStems) {
emit loadToGroup(m_group,
mixxx::StemChannelSelection::fromInt(
static_cast<int>(value)),
false);
}
});
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
m_loadSelectedLibraryStems[stemIdx] =
std::make_unique<PollingControlProxy>(ConfigKey(
QStringLiteral("[LibraryStem%1]").arg(stemIdx + 1),
"selected"));
}
#endif

connect(this,
&LoadToGroupController::loadToGroup,
pParent,
Expand All @@ -62,25 +54,35 @@ LoadToGroupController::LoadToGroupController(LibraryControl* pParent, const QStr

LoadToGroupController::~LoadToGroupController() = default;

#ifdef __STEM__
mixxx::StemChannelSelection LoadToGroupController::getLibraryStemSelection() const {
auto stemSelection = mixxx::StemChannelSelection();
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
if (!m_loadSelectedLibraryStems[stemIdx]->toBool()) {
continue;
}
stemSelection |= mixxx::StemChannel(1 << stemIdx);
}
return stemSelection;
}
#endif

void LoadToGroupController::slotLoadToGroup(double v) {
if (v > 0) {
emit loadToGroup(m_group,
#ifdef __STEM__
mixxx::StemChannelSelection(),
emit loadToGroup(m_group, getLibraryStemSelection(), false);
#else
emit loadToGroup(m_group, false);
#endif
false);
}
}

void LoadToGroupController::slotLoadToGroupAndPlay(double v) {
if (v > 0) {
#ifdef __STEM__
emit loadToGroup(m_group,
mixxx::StemChannelSelection(),
true);
emit loadToGroup(m_group, getLibraryStemSelection(), true);
#else
emit loadToGroup(m_group,
true);
emit loadToGroup(m_group, true);
#endif
}
}
Expand All @@ -98,6 +100,14 @@ LibraryControl::LibraryControl(Library* pLibrary)
m_numPreviewDecks(kAppGroup, QStringLiteral("num_preview_decks"), this) {
qRegisterMetaType<FocusWidget>("FocusWidget");

#ifdef __STEM__
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
m_loadSelectedStems[stemIdx] = std::make_unique<ControlPushButton>(
ConfigKey(QStringLiteral("[LibraryStem%1]").arg(stemIdx + 1),
"selected"));
}
#endif

slotNumDecksChanged(m_numDecks.get());
slotNumSamplersChanged(m_numSamplers.get());
slotNumPreviewDecksChanged(m_numPreviewDecks.get());
Expand Down
10 changes: 9 additions & 1 deletion src/library/librarycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <memory>

#include "control/controlproxy.h"
#include "control/pollingcontrolproxy.h"
#include "library/library_decl.h"
#ifdef __STEM__
#include "engine/engine.h"
Expand Down Expand Up @@ -45,7 +46,9 @@ class LoadToGroupController : public QObject {
std::unique_ptr<ControlObject> m_pLoadAndPlayControl;

#ifdef __STEM__
std::unique_ptr<ControlPushButton> m_loadSelectedTrackStems;
mixxx::StemChannelSelection getLibraryStemSelection() const;

std::unique_ptr<PollingControlProxy> m_loadSelectedLibraryStems[mixxx::kMaxSupportedStems];
#endif
};

Expand Down Expand Up @@ -221,4 +224,9 @@ class LibraryControl : public QObject {
ControlProxy m_numSamplers;
ControlProxy m_numPreviewDecks;
std::map<QString, std::unique_ptr<LoadToGroupController>> m_loadToGroupControllers;

#ifdef __STEM__
// Stem selection
std::unique_ptr<ControlPushButton> m_loadSelectedStems[mixxx::kMaxSupportedStems];
#endif
};

0 comments on commit 74382c9

Please sign in to comment.