Skip to content

Commit

Permalink
Merge pull request #14244 from daschuer/gh14240
Browse files Browse the repository at this point in the history
Use [Channel1_Stem1] pattern for Stem COs. Improve speed a bit.
  • Loading branch information
Swiftb0y authored Jan 30, 2025
2 parents 7052e1c + ef1efcd commit adda147
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 43 deletions.
2 changes: 1 addition & 1 deletion res/qml/EqColumn.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Column {
}

function stemGroup(group, index) {
return `${group.substr(0, group.length-1)}Stem${index + 1}]`
return `${group.substr(0, group.length-1)}_Stem${index + 1}]`
}

Row {
Expand Down
2 changes: 1 addition & 1 deletion res/skins/LateNight/stem_channel.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Template>
<SetVariable name="StemGroup">[Channel<Variable name="ChanNum"/>Stem<Variable name="StemNum"/>]</SetVariable>
<SetVariable name="StemGroup">[Channel<Variable name="ChanNum"/>_Stem<Variable name="StemNum"/>]</SetVariable>

<WidgetGroup>
<ObjectName>StemChannel_ControlContainer</ObjectName>
Expand Down
25 changes: 12 additions & 13 deletions src/engine/channels/enginedeck.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "engine/channels/enginedeck.h"

#include <QStringView>

#include "control/controlpushbutton.h"
#include "effects/effectsmanager.h"
#include "engine/controls/bpmcontrol.h"
Expand All @@ -13,17 +15,6 @@
#include "util/assert.h"
#include "util/sample.h"

#ifdef __STEM__
namespace {
QString getGroupForStem(const QString& deckGroup, int stemIdx) {
DEBUG_ASSERT(deckGroup.endsWith("]"));
return QStringLiteral("%1Stem%2]")
.arg(deckGroup.left(deckGroup.size() - 1),
QString::number(stemIdx));
}
} // anonymous namespace
#endif

EngineDeck::EngineDeck(
const ChannelHandleAndGroup& handleGroup,
UserSettingsPointer pConfig,
Expand Down Expand Up @@ -77,14 +68,14 @@ EngineDeck::EngineDeck(
m_stemMute.reserve(mixxx::kMaxSupportedStems);
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
m_stemGain.emplace_back(std::make_unique<ControlPotmeter>(
ConfigKey(getGroupForStem(getGroup(), stemIdx + 1), QStringLiteral("volume"))));
ConfigKey(getGroupForStem(getGroup(), stemIdx), 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);
auto pMuteButton = std::make_unique<ControlPushButton>(
ConfigKey(getGroupForStem(getGroup(), stemIdx + 1), QStringLiteral("mute")));
ConfigKey(getGroupForStem(getGroup(), stemIdx), QStringLiteral("mute")));
pMuteButton->setButtonMode(mixxx::control::ButtonMode::PowerWindow);
m_stemMute.push_back(std::move(pMuteButton));
}
Expand Down Expand Up @@ -363,3 +354,11 @@ void EngineDeck::slotPassthroughChangeRequest(double v) {
emit noPassthroughInputConfigured();
}
}

#ifdef __STEM__
// static
QString EngineDeck::getGroupForStem(QStringView deckGroup, int stemIdx) {
DEBUG_ASSERT(deckGroup.endsWith(QChar(']')) && stemIdx < 4);
return deckGroup.chopped(1) + QStringLiteral("_Stem") + QChar('1' + stemIdx) + QChar(']');
}
#endif
1 change: 1 addition & 0 deletions src/engine/channels/enginedeck.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class EngineDeck : public EngineChannel, public AudioDestination {
// of stem track
void cloneStemState(const EngineDeck* deckToClone);
void addStemHandle(const ChannelHandleAndGroup& stemHandleGroup);
static QString getGroupForStem(QStringView deckGroup, int stemIdx);
#endif

signals:
Expand Down
6 changes: 2 additions & 4 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,8 @@ BaseTrackPlayerImpl::BaseTrackPlayerImpl(
#ifdef __STEM__
m_pStemColors.reserve(mixxx::kMaxSupportedStems);
QString group = getGroup();
for (int stemIdx = 1; stemIdx <= mixxx::kMaxSupportedStems; stemIdx++) {
QString stemGroup = QStringLiteral("%1Stem%2]")
.arg(group.left(group.size() - 1),
QString::number(stemIdx));
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
QString stemGroup = EngineDeck::getGroupForStem(group, stemIdx);
m_pStemColors.emplace_back(std::make_unique<ControlObject>(
ConfigKey(stemGroup, QStringLiteral("color"))));
m_pStemColors.back()->set(kNoTrackColor);
Expand Down
20 changes: 10 additions & 10 deletions src/mixer/playermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,28 +145,28 @@ class PlayerManager : public QObject, public PlayerManagerInterface {
// Returns the group for the ith sampler where i is zero indexed
static QString groupForSampler(int i) {
DEBUG_ASSERT(i >= 0);
return QStringLiteral("[Sampler") + QString::number(i + 1) + ']';
return QStringLiteral("[Sampler") + QString::number(i + 1) + QChar(']');
}

// Returns the group for the ith deck where i is zero indexed
static QString groupForDeck(int i) {
DEBUG_ASSERT(i >= 0);
return QStringLiteral("[Channel") + QString::number(i + 1) + ']';
return QStringLiteral("[Channel") + QString::number(i + 1) + QChar(']');
}

#ifdef __STEM__
// Returns the group for the ith deck and jth stem where i and j is zero indexed
static QString groupForDeckStem(int i, int j) {
DEBUG_ASSERT(i >= 0);
return QStringLiteral("[Channel") + QString::number(i + 1) +
QStringLiteral("Stem") + QString::number(j + 1) + ']';
// Returns the group for the deck and stem where deckIndex and stemInde are zero based
static QString groupForDeckStem(int deckIdx, int stemIdx) {
DEBUG_ASSERT(deckIdx >= 0 && stemIdx >= 0 && stemIdx < 4);
return QStringLiteral("[Channel") + QString::number(deckIdx + 1) +
QStringLiteral("_Stem") + QChar('1' + stemIdx) + QChar(']');
}
#endif

// Returns the group for the ith PreviewDeck where i is zero indexed
static QString groupForPreviewDeck(int i) {
DEBUG_ASSERT(i >= 0);
return QStringLiteral("[PreviewDeck") + QString::number(i + 1) + ']';
return QStringLiteral("[PreviewDeck") + QString::number(i + 1) + QChar(']');
}

// Returns the group for the ith Microphone where i is zero indexed
Expand All @@ -176,7 +176,7 @@ class PlayerManager : public QObject, public PlayerManagerInterface {
// the group [Microphone]. For backwards compatibility we keep it that
// way.
if (i > 0) {
return QStringLiteral("[Microphone") + QString::number(i + 1) + ']';
return QStringLiteral("[Microphone") + QString::number(i + 1) + QChar(']');
} else {
return QStringLiteral("[Microphone]");
}
Expand All @@ -185,7 +185,7 @@ class PlayerManager : public QObject, public PlayerManagerInterface {
// Returns the group for the ith Auxiliary where i is zero indexed
static QString groupForAuxiliary(int i) {
DEBUG_ASSERT(i >= 0);
return QStringLiteral("[Auxiliary") + QString::number(i + 1) + ']';
return QStringLiteral("[Auxiliary") + QString::number(i + 1) + QChar(']');
}

static QAtomicPointer<ControlProxy> m_pCOPNumDecks;
Expand Down
12 changes: 5 additions & 7 deletions src/test/stemcontrolobjecttest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@

class StemControlTest : public BaseSignalPathTest {
protected:
QString getGroupForStem(const QString& deckGroup, int stemIdx) {
DEBUG_ASSERT(deckGroup.endsWith("]"));
return QStringLiteral("%1Stem%2]")
.arg(deckGroup.left(deckGroup.size() - 1),
QString::number(stemIdx));
QString getGroupForStem(QStringView deckGroup, int stemNr) {
DEBUG_ASSERT(deckGroup.endsWith(QChar(']')) && stemNr <= 4);
return deckGroup.chopped(1) + QStringLiteral("_Stem") + QChar('0' + stemNr) + QChar(']');
}
QString getFxGroupForStem(const QString& deckGroup, int stemIdx) {
QString getFxGroupForStem(const QString& deckGroup, int stemNr) {
return QStringLiteral("[QuickEffectRack1_%1]")
.arg(getGroupForStem(deckGroup, stemIdx));
.arg(getGroupForStem(deckGroup, stemNr));
}

void SetUp() override {
Expand Down
13 changes: 6 additions & 7 deletions src/waveform/renderers/allshader/waveformrendererstem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QImage>
#include <QOpenGLTexture>

#include "engine/channels/enginedeck.h"
#include "engine/engine.h"
#include "track/track.h"
#include "util/math.h"
Expand All @@ -28,16 +29,14 @@ void WaveformRendererStem::initializeGL() {
m_shader.init();
m_textureShader.init();
auto group = m_pEQEnabled->getKey().group;
for (int stemIdx = 1; stemIdx <= mixxx::kMaxSupportedStems; stemIdx++) {
DEBUG_ASSERT(group.endsWith("]"));
QString stemGroup = QStringLiteral("%1Stem%2]")
.arg(group.left(group.size() - 1),
QString::number(stemIdx));
for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) {
QString stemGroup = EngineDeck::getGroupForStem(group, stemIdx);
m_pStemGain.emplace_back(
std::make_unique<ControlProxy>(stemGroup,
QStringLiteral("volume")));
m_pStemMute.emplace_back(std::make_unique<ControlProxy>(
stemGroup, QStringLiteral("mute")));
m_pStemMute.emplace_back(
std::make_unique<ControlProxy>(stemGroup,
QStringLiteral("mute")));
}
}

Expand Down

0 comments on commit adda147

Please sign in to comment.