Skip to content

Commit

Permalink
Merge pull request #12305 from ronso0/sampler-deckvisuals-fix
Browse files Browse the repository at this point in the history
Sampler DeckVisuals fix
  • Loading branch information
daschuer authored Nov 16, 2023
2 parents 290e5c7 + 76ea815 commit 1e6bb73
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 29 deletions.
10 changes: 6 additions & 4 deletions src/coreservices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace {
const mixxx::Logger kLogger("CoreServices");
constexpr int kMicrophoneCount = 4;
constexpr int kAuxiliaryCount = 4;
constexpr int kSamplerCount = 4;

#define CLEAR_AND_CHECK_DELETED(x) clearHelper(x, #x);

Expand Down Expand Up @@ -303,10 +304,11 @@ void CoreServices::initialize(QApplication* pApp) {
}

m_pPlayerManager->addConfiguredDecks();
m_pPlayerManager->addSampler();
m_pPlayerManager->addSampler();
m_pPlayerManager->addSampler();
m_pPlayerManager->addSampler();

for (int i = 0; i < kSamplerCount; ++i) {
m_pPlayerManager->addSampler();
}

m_pPlayerManager->addPreviewDeck();

m_pEffectsManager->setup();
Expand Down
27 changes: 12 additions & 15 deletions src/mixer/playermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ T* findFirstStoppedPlayerInList(const QList<T*>& players) {
return nullptr;
}

inline QString getDefaultSamplerPath(UserSettingsPointer pConfig) {
return pConfig->getSettingsPath() + QStringLiteral("/samplers.xml");
}

} // anonymous namespace

//static
Expand All @@ -106,15 +110,15 @@ PlayerManager::PlayerManager(UserSettingsPointer pConfig,
m_pEngine(pEngine),
// NOTE(XXX) LegacySkinParser relies on these controls being Controls
// and not ControlProxies.
m_pCONumDecks(new ControlObject(
m_pCONumDecks(std::make_unique<ControlObject>(
ConfigKey(kAppGroup, QStringLiteral("num_decks")), true, true)),
m_pCONumSamplers(new ControlObject(
m_pCONumSamplers(std::make_unique<ControlObject>(
ConfigKey(kAppGroup, QStringLiteral("num_samplers")), true, true)),
m_pCONumPreviewDecks(new ControlObject(
m_pCONumPreviewDecks(std::make_unique<ControlObject>(
ConfigKey(kAppGroup, QStringLiteral("num_preview_decks")), true, true)),
m_pCONumMicrophones(new ControlObject(
m_pCONumMicrophones(std::make_unique<ControlObject>(
ConfigKey(kAppGroup, QStringLiteral("num_microphones")), true, true)),
m_pCONumAuxiliaries(new ControlObject(
m_pCONumAuxiliaries(std::make_unique<ControlObject>(
ConfigKey(kAppGroup, QStringLiteral("num_auxiliaries")), true, true)),
m_pTrackAnalysisScheduler(TrackAnalysisScheduler::NullPointer()) {
m_pCONumDecks->addAlias(ConfigKey(kLegacyGroup, QStringLiteral("num_decks")));
Expand Down Expand Up @@ -144,8 +148,7 @@ PlayerManager::~PlayerManager() {

const auto locker = lockMutex(&m_mutex);

m_pSamplerBank->saveSamplerBankToPath(
m_pConfig->getSettingsPath() + "/samplers.xml");
m_pSamplerBank->saveSamplerBankToPath(getDefaultSamplerPath(m_pConfig));
// No need to delete anything because they are all parented to us and will
// be destroyed when we are destroyed.
m_players.clear();
Expand All @@ -158,12 +161,6 @@ PlayerManager::~PlayerManager() {
delete m_pCOPNumSamplers.fetchAndStoreAcquire(nullptr);
delete m_pCOPNumPreviewDecks.fetchAndStoreAcquire(nullptr);

delete m_pCONumSamplers;
delete m_pCONumDecks;
delete m_pCONumPreviewDecks;
delete m_pCONumMicrophones;
delete m_pCONumAuxiliaries;

if (m_pTrackAnalysisScheduler) {
m_pTrackAnalysisScheduler->stop();
m_pTrackAnalysisScheduler.reset();
Expand Down Expand Up @@ -342,6 +339,7 @@ void PlayerManager::slotChangeNumSamplers(double v) {
addSamplerInner();
}
m_pCONumSamplers->setAndConfirm(m_samplers.size());
emit numberOfSamplersChanged(m_samplers.count());
}

void PlayerManager::slotChangeNumPreviewDecks(double v) {
Expand Down Expand Up @@ -452,8 +450,7 @@ void PlayerManager::addDeckInner() {
}

void PlayerManager::loadSamplers() {
m_pSamplerBank->loadSamplerBankFromPath(
m_pConfig->getSettingsPath() + "/samplers.xml");
m_pSamplerBank->loadSamplerBankFromPath(getDefaultSamplerPath(m_pConfig));
}

void PlayerManager::addSampler() {
Expand Down
11 changes: 6 additions & 5 deletions src/mixer/playermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ class PlayerManager : public QObject, public PlayerManagerInterface {

// Emitted when the number of decks changes.
void numberOfDecksChanged(int decks);
void numberOfSamplersChanged(int samplers);

void trackAnalyzerProgress(TrackId trackId, AnalyzerProgress analyzerProgress);
void trackAnalyzerIdle();
Expand Down Expand Up @@ -275,11 +276,11 @@ class PlayerManager : public QObject, public PlayerManagerInterface {
EffectsManager* m_pEffectsManager;
EngineMixer* m_pEngine;
SamplerBank* m_pSamplerBank;
ControlObject* m_pCONumDecks;
ControlObject* m_pCONumSamplers;
ControlObject* m_pCONumPreviewDecks;
ControlObject* m_pCONumMicrophones;
ControlObject* m_pCONumAuxiliaries;
std::unique_ptr<ControlObject> m_pCONumDecks;
std::unique_ptr<ControlObject> m_pCONumSamplers;
std::unique_ptr<ControlObject> m_pCONumPreviewDecks;
std::unique_ptr<ControlObject> m_pCONumMicrophones;
std::unique_ptr<ControlObject> m_pCONumAuxiliaries;
parented_ptr<ControlProxy> m_pAutoDjEnabled;

TrackAnalysisScheduler::Pointer m_pTrackAnalysisScheduler;
Expand Down
3 changes: 0 additions & 3 deletions src/mixer/samplerbank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ SamplerBank::SamplerBank(UserSettingsPointer pConfig,
this);
}

SamplerBank::~SamplerBank() {
}

void SamplerBank::slotSaveSamplerBank(double v) {
if (v <= 0.0) {
return;
Expand Down
1 change: 0 additions & 1 deletion src/mixer/samplerbank.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class SamplerBank : public QObject {
public:
SamplerBank(UserSettingsPointer pConfig,
PlayerManager* pPlayerManager);
~SamplerBank() override;

bool saveSamplerBankToPath(const QString& samplerBankPath);
bool loadSamplerBankFromPath(const QString& samplerBankPath);
Expand Down
9 changes: 9 additions & 0 deletions src/mixxxmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,15 @@ void MixxxMainWindow::initialize() {
m_pVisualsManager->addDeckIfNotExist(group);
}
});
connect(pPlayerManager.get(),
&PlayerManager::numberOfSamplersChanged,
this,
[this](int decks) {
for (int i = 0; i < decks; ++i) {
QString group = PlayerManager::groupForSampler(i);
m_pVisualsManager->addDeckIfNotExist(group);
}
});

#ifndef MIXXX_USE_QOPENGL
// Before creating the first skin we need to create a QGLWidget so that all
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/visualsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DeckVisuals::DeckVisuals(const QString& group)
engineKey(ConfigKey(group, "key")) {
m_pTimeElapsed = std::make_unique<ControlObject>(ConfigKey(m_group, "time_elapsed"));
m_pTimeRemaining = std::make_unique<ControlObject>(ConfigKey(m_group, "time_remaining"));
m_pEndOfTrack = std::make_unique<ControlObject>(ConfigKey(group, "end_of_track"));
m_pEndOfTrack = std::make_unique<ControlObject>(ConfigKey(m_group, "end_of_track"));
m_pVisualBpm = std::make_unique<ControlObject>(ConfigKey(m_group, "visual_bpm"));
m_pVisualKey = std::make_unique<ControlObject>(ConfigKey(m_group, "visual_key"));

Expand Down

0 comments on commit 1e6bb73

Please sign in to comment.