Skip to content

Commit

Permalink
Add a QFlag and enum to represent stem track selection
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Sep 29, 2024
1 parent ecdbb1a commit a54051a
Show file tree
Hide file tree
Showing 41 changed files with 212 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/engine/cachingreader/cachingreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ CachingReaderChunkForOwner* CachingReader::lookupChunkAndFreshen(SINT chunkIndex

// Invoked from the UI thread!!
#ifdef __STEM__
void CachingReader::newTrack(TrackPointer pTrack, uint stemMask) {
void CachingReader::newTrack(TrackPointer pTrack, mixxx::StemChannelSelection stemMask) {
#else
void CachingReader::newTrack(TrackPointer pTrack) {
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/engine/cachingreader/cachingreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CachingReader : public QObject {
// processed in the work thread, so the reader must be woken up via wake()
// for this to take effect.
#ifdef __STEM__
void newTrack(TrackPointer pTrack, uint stemMask = 0);
void newTrack(TrackPointer pTrack, mixxx::StemChannelSelection stemMask = {});
#else
void newTrack(TrackPointer pTrack);
#endif
Expand Down
5 changes: 3 additions & 2 deletions src/engine/cachingreader/cachingreaderworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ ReaderStatusUpdate CachingReaderWorker::processReadRequest(

// WARNING: Always called from a different thread (GUI)
#ifdef __STEM__
void CachingReaderWorker::newTrack(TrackPointer pTrack, uint stemMask) {
void CachingReaderWorker::newTrack(TrackPointer pTrack, mixxx::StemChannelSelection stemMask) {
#else
void CachingReaderWorker::newTrack(TrackPointer pTrack) {
#endif
Expand Down Expand Up @@ -188,7 +188,8 @@ void CachingReaderWorker::unloadTrack() {
}

#ifdef __STEM__
void CachingReaderWorker::loadTrack(const TrackPointer& pTrack, uint stemMask) {
void CachingReaderWorker::loadTrack(
const TrackPointer& pTrack, mixxx::StemChannelSelection stemMask) {
#else
void CachingReaderWorker::loadTrack(const TrackPointer& pTrack) {
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/engine/cachingreader/cachingreaderworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CachingReaderWorker : public EngineWorker {

// Request to load a new track. wake() must be called afterwards.
#ifdef __STEM__
void newTrack(TrackPointer pTrack, uint stemMask);
void newTrack(TrackPointer pTrack, mixxx::StemChannelSelection stemMask);
#else
void newTrack(TrackPointer pTrack);
#endif
Expand All @@ -129,7 +129,7 @@ class CachingReaderWorker : public EngineWorker {
#ifdef __STEM__
struct NewTrackRequest {
TrackPointer track;
uint stemMask;
mixxx::StemChannelSelection stemMask;
};
#endif
const QString m_group;
Expand Down Expand Up @@ -162,7 +162,7 @@ class CachingReaderWorker : public EngineWorker {

/// Internal method to load a track. Emits trackLoaded when finished.
#ifdef __STEM__
void loadTrack(const TrackPointer& pTrack, uint stemMask);
void loadTrack(const TrackPointer& pTrack, mixxx::StemChannelSelection stemMask);
#else
void loadTrack(const TrackPointer& pTrack);
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/engine/channels/enginedeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ EngineDeck::EngineDeck(

m_stemGain.reserve(mixxx::kMaxSupportedStems);
m_stemMute.reserve(mixxx::kMaxSupportedStems);
for (int stemIdx = 1; stemIdx <= mixxx::kMaxSupportedStems; stemIdx++) {
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
m_stemGain.emplace_back(std::make_unique<ControlPotmeter>(
ConfigKey(getGroupForStem(getGroup(), stemIdx), QStringLiteral("volume"))));
ConfigKey(getGroupForStem(getGroup(), stemIdx + 1), QStringLiteral("volume"))));
// The default value is ignored and override with the medium value by
// ControlPotmeter. This is likely a bug but fixing might have a
// disruptive impact, so setting the default explicitly
m_stemGain.back()->set(1.0);
m_stemGain.back()->setDefaultValue(1.0);
m_stemMute.emplace_back(std::make_unique<ControlPushButton>(
ConfigKey(getGroupForStem(getGroup(), stemIdx), QStringLiteral("mute"))));
ConfigKey(getGroupForStem(getGroup(), stemIdx + 1), QStringLiteral("mute"))));
}
#endif
}
Expand Down
11 changes: 10 additions & 1 deletion src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ static constexpr audio::ChannelCount kMaxEngineChannelInputCount =
// not.
constexpr int kMaxSupportedStems = 4;
#ifdef __STEM__
constexpr uint kNoStemSelected = 0;
enum class StemChannel {
First = 0x1,
Second = 0x2,
Third = 0x4,
Fourth = 0x8,

None = 0,
All = First | Second | Third | Fourth
};
Q_DECLARE_FLAGS(StemChannelSelection, StemChannel);
#endif

// Contains the information needed to process a buffer of audio
Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ void EngineBuffer::hintReader(const double dRate) {
// WARNING: This method runs in the GUI thread
#ifdef __STEM__
void EngineBuffer::loadTrack(TrackPointer pTrack,
uint stemMask,
mixxx::StemChannelSelection stemMask,
bool play,
EngineChannel* pChannelToCloneFrom) {
#else
Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginebuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class EngineBuffer : public EngineObject {
// has completed.
#ifdef __STEM__
void loadTrack(TrackPointer pTrack,
uint stemMask,
mixxx::StemChannelSelection stemMask,
bool play,
EngineChannel* pChannelToCloneFrom);
#else
Expand Down
2 changes: 1 addition & 1 deletion src/library/analysis/analysisfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void AnalysisFeature::bindLibraryWidget(WLibrary* libraryWidget,
[=, this](TrackPointer track, const QString& group) {
emit loadTrackToPlayer(track, group,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
false);
});
Expand Down
7 changes: 5 additions & 2 deletions src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ class AutoDJProcessor : public QObject {

signals:
#ifdef __STEM__
void loadTrackToPlayer(TrackPointer pTrack, const QString& group, uint stemMask, bool play);
void loadTrackToPlayer(TrackPointer pTrack,
const QString& group,
mixxx::StemChannelSelection stemMask,
bool play);
#else
void loadTrackToPlayer(TrackPointer pTrack, const QString& group, bool play);
#endif
Expand Down Expand Up @@ -236,7 +239,7 @@ class AutoDJProcessor : public QObject {
virtual void emitLoadTrackToPlayer(TrackPointer pTrack, const QString& group, bool play) {
emit loadTrackToPlayer(pTrack, group,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
play);
}
Expand Down
5 changes: 4 additions & 1 deletion src/library/autodj/dlgautodj.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ class DlgAutoDJ : public QWidget, public Ui::DlgAutoDJ, public LibraryView {
void addRandomTrackButton(bool buttonChecked);
void loadTrack(TrackPointer tio);
#ifdef __STEM__
void loadTrackToPlayer(TrackPointer tio, const QString& group, uint stemMask, bool);
void loadTrackToPlayer(TrackPointer tio,
const QString& group,
mixxx::StemChannelSelection stemMask,
bool);
#else
void loadTrackToPlayer(TrackPointer tio, const QString& group, bool);
#endif
Expand Down
8 changes: 5 additions & 3 deletions src/library/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,18 @@ void Library::slotLoadLocationToPlayer(const QString& location, const QString& g
TrackPointer pTrack = m_pTrackCollectionManager->getOrAddTrack(trackRef);
if (pTrack) {
#ifdef __STEM__
emit loadTrackToPlayer(pTrack, group, mixxx::kNoStemSelected, play);
emit loadTrackToPlayer(pTrack, group, mixxx::StemChannelSelection(), play);
#else
emit loadTrackToPlayer(pTrack, group, play);
#endif
}
}

#ifdef __STEM__
void Library::slotLoadTrackToPlayer(
TrackPointer pTrack, const QString& group, uint stemMask, bool play) {
void Library::slotLoadTrackToPlayer(TrackPointer pTrack,
const QString& group,
mixxx::StemChannelSelection stemMask,
bool play) {
emit loadTrackToPlayer(pTrack, group, stemMask, play);
}
#else
Expand Down
7 changes: 5 additions & 2 deletions src/library/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ class Library: public QObject {
void slotSwitchToView(const QString& view);
void slotLoadTrack(TrackPointer pTrack);
#ifdef __STEM__
void slotLoadTrackToPlayer(TrackPointer pTrack, const QString& group, uint stemMask, bool play);
void slotLoadTrackToPlayer(TrackPointer pTrack,
const QString& group,
mixxx::StemChannelSelection stemMask,
bool play);
#else
void slotLoadTrackToPlayer(TrackPointer pTrack, const QString& group, bool play);
#endif
Expand All @@ -134,7 +137,7 @@ class Library: public QObject {
#ifdef __STEM__
void loadTrackToPlayer(TrackPointer pTrack,
const QString& group,
uint stemMask,
mixxx::StemChannelSelection stemMask,
bool play = false);
#else
void loadTrackToPlayer(TrackPointer pTrack,
Expand Down
12 changes: 8 additions & 4 deletions src/library/librarycontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ LoadToGroupController::LoadToGroupController(LibraryControl* pParent, const QStr
this,
[this](double value) {
if (value >= 0 && value <= 2 << mixxx::kMaxSupportedStems) {
emit loadToGroup(m_group, static_cast<uint>(value), false);
emit loadToGroup(m_group,
mixxx::StemChannelSelection::fromInt(
static_cast<int>(value)),
false);
}
});
#endif
Expand All @@ -63,7 +66,7 @@ void LoadToGroupController::slotLoadToGroup(double v) {
if (v > 0) {
emit loadToGroup(m_group,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
false);
}
Expand All @@ -73,7 +76,7 @@ void LoadToGroupController::slotLoadToGroupAndPlay(double v) {
if (v > 0) {
#ifdef __STEM__
emit loadToGroup(m_group,
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
true);
#else
emit loadToGroup(m_group,
Expand Down Expand Up @@ -625,7 +628,8 @@ void LibraryControl::slotUpdateTrackMenuControl(bool visible) {
}

#ifdef __STEM__
void LibraryControl::slotLoadSelectedTrackToGroup(const QString& group, uint stemMask, bool play) {
void LibraryControl::slotLoadSelectedTrackToGroup(
const QString& group, mixxx::StemChannelSelection stemMask, bool play) {
#else
void LibraryControl::slotLoadSelectedTrackToGroup(const QString& group, bool play) {
#endif
Expand Down
9 changes: 7 additions & 2 deletions src/library/librarycontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

#include "control/controlproxy.h"
#include "library/library_decl.h"
#ifdef __STEM__
#include "engine/engine.h"
#endif

class ControlEncoder;
class ControlObject;
Expand All @@ -25,7 +28,7 @@ class LoadToGroupController : public QObject {
signals:
#ifdef __STEM__
void loadToGroup(const QString& group,
uint stemMask,
mixxx::StemChannelSelection stemMask,
bool);
#else
void loadToGroup(const QString& group,
Expand Down Expand Up @@ -66,7 +69,9 @@ class LibraryControl : public QObject {
public slots:
// Deprecated navigation slots
#ifdef __STEM__
void slotLoadSelectedTrackToGroup(const QString& group, uint stemMask, bool play);
void slotLoadSelectedTrackToGroup(const QString& group,
mixxx::StemChannelSelection stemMask,
bool play);
#else
void slotLoadSelectedTrackToGroup(const QString& group, bool play);
#endif
Expand Down
5 changes: 4 additions & 1 deletion src/library/libraryfeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#include "library/dao/trackdao.h"
#include "library/treeitemmodel.h"
#include "track/track_decl.h"
#ifdef __STEM__
#include "engine/engine.h"
#endif

class KeyboardEventFilter;
class Library;
Expand Down Expand Up @@ -138,7 +141,7 @@ class LibraryFeature : public QObject {
#ifdef __STEM__
void loadTrackToPlayer(TrackPointer pTrack,
const QString& group,
uint stemMask,
mixxx::StemChannelSelection stemMask,
bool play = false);
#else
void loadTrackToPlayer(TrackPointer pTrack,
Expand Down
8 changes: 7 additions & 1 deletion src/library/recording/dlgrecording.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "library/recording/ui_dlgrecording.h"
#include "preferences/usersettings.h"
#include "track/track_decl.h"
#ifdef __STEM__
#include "engine/engine.h"
#endif

class WLibrary;
class WTrackTableView;
Expand Down Expand Up @@ -38,7 +41,10 @@ class DlgRecording : public QWidget, public Ui::DlgRecording, public virtual Lib
signals:
void loadTrack(TrackPointer tio);
#ifdef __STEM__
void loadTrackToPlayer(TrackPointer tio, const QString& group, uint stemMask, bool);
void loadTrackToPlayer(TrackPointer tio,
const QString& group,
mixxx::StemChannelSelection stemMask,
bool);
#else
void loadTrackToPlayer(TrackPointer tio, const QString& group, bool);
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/library/tabledelegates/previewbuttondelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void PreviewButtonDelegate::buttonClicked() {
// Load to preview deck and start playing
emit loadTrackToPlayer(pTrack, kPreviewDeckGroup,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
true);
startedPlaying = true;
Expand Down
8 changes: 7 additions & 1 deletion src/library/tabledelegates/previewbuttondelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include "library/tabledelegates/tableitemdelegate.h"
#include "track/track_decl.h"
#include "util/parented_ptr.h"
#ifdef __STEM__
#include "engine/engine.h"
#endif

class ControlProxy;
class WLibraryTableView;
Expand Down Expand Up @@ -55,7 +58,10 @@ class PreviewButtonDelegate : public TableItemDelegate {

signals:
#ifdef __STEM__
void loadTrackToPlayer(const TrackPointer& pTrack, const QString& group, uint stemMask, bool);
void loadTrackToPlayer(const TrackPointer& pTrack,
const QString& group,
mixxx::StemChannelSelection stemMask,
bool);
#else
void loadTrackToPlayer(const TrackPointer& pTrack, const QString& group, bool);
#endif
Expand Down
10 changes: 5 additions & 5 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void BaseTrackPlayerImpl::slotEjectTrack(double v) {
if (lastEjected) {
slotLoadTrack(lastEjected,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
false);
}
Expand All @@ -432,7 +432,7 @@ void BaseTrackPlayerImpl::slotEjectTrack(double v) {
if (lastEjected) {
slotLoadTrack(lastEjected,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
false);
}
Expand Down Expand Up @@ -550,7 +550,7 @@ void BaseTrackPlayerImpl::disconnectLoadedTrack() {

#ifdef __STEM__
void BaseTrackPlayerImpl::slotLoadTrack(TrackPointer pNewTrack,
uint stemMask,
mixxx::StemChannelSelection stemMask,
bool bPlay) {
#else
void BaseTrackPlayerImpl::slotLoadTrack(TrackPointer pNewTrack,
Expand Down Expand Up @@ -801,7 +801,7 @@ void BaseTrackPlayerImpl::slotCloneChannel(EngineChannel* pChannel) {
bool play = ControlObject::toBool(ConfigKey(m_pChannelToCloneFrom->getGroup(), "play"));
slotLoadTrack(pTrack,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
play);
}
Expand Down Expand Up @@ -829,7 +829,7 @@ void BaseTrackPlayerImpl::loadTrackFromGroup(const QString& group) {

slotLoadTrack(pTrack,
#ifdef __STEM__
mixxx::kNoStemSelected,
mixxx::StemChannelSelection(),
#endif
false);
}
Expand Down
Loading

0 comments on commit a54051a

Please sign in to comment.