Skip to content

Commit 6a611fd

Browse files
Add seq track solo
1 parent ca8ff02 commit 6a611fd

20 files changed

+176
-31
lines changed

scripts/vcpkg

src/audioCore/Utils.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,4 +1083,22 @@ namespace utils {
10831083
}
10841084

10851085
bool regardVel0NoteAsNoteOff() { return true; }
1086+
1087+
static std::atomic_int soloCount = 0;
1088+
1089+
void increaseSoloCount() {
1090+
soloCount++;
1091+
}
1092+
1093+
void decreaseSoloCount() {
1094+
soloCount--;
1095+
}
1096+
1097+
bool shouldSolo() {
1098+
return soloCount > 0;
1099+
}
1100+
1101+
void resetSoloCount() {
1102+
soloCount = 0;
1103+
}
10861104
}

src/audioCore/Utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ namespace utils {
161161
const juce::File& base = utils::getProjectDir());
162162

163163
bool regardVel0NoteAsNoteOff();
164+
165+
void increaseSoloCount();
166+
void decreaseSoloCount();
167+
bool shouldSolo();
168+
void resetSoloCount();
164169
}
165170

166171
#define UNUSED(var) (void)var

src/audioCore/action/ActionSet.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,48 @@ bool ActionSetSequencerTrackMute::undo() {
15451545
ACTION_RESULT(false);
15461546
}
15471547

1548+
ActionSetSequencerTrackSolo::ActionSetSequencerTrackSolo(
1549+
int track, bool solo)
1550+
: ACTION_DB{ track, solo } {
1551+
}
1552+
1553+
bool ActionSetSequencerTrackSolo::doAction() {
1554+
ACTION_UNSAVE_PROJECT();
1555+
1556+
ACTION_WRITE_TYPE(ActionSetSequencerTrackSolo);
1557+
ACTION_WRITE_DB();
1558+
1559+
if (auto graph = AudioCore::getInstance()->getGraph()) {
1560+
if (auto track = graph->getSourceProcessor(ACTION_DATA(track))) {
1561+
ACTION_DATA(oldSolo) = track->getSolo();
1562+
track->setSolo(ACTION_DATA(solo));
1563+
1564+
this->output("Set seq solo: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ ACTION_DATA(solo) ? "ON" : "OFF" } + "\n");;
1565+
ACTION_RESULT(true);
1566+
}
1567+
}
1568+
this->output("Can't set seq solo: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ ACTION_DATA(solo) ? "ON" : "OFF" } + "\n");
1569+
ACTION_RESULT(false);
1570+
}
1571+
1572+
bool ActionSetSequencerTrackSolo::undo() {
1573+
ACTION_UNSAVE_PROJECT();
1574+
1575+
ACTION_WRITE_TYPE_UNDO(ActionSetSequencerTrackSolo);
1576+
ACTION_WRITE_DB();
1577+
1578+
if (auto graph = AudioCore::getInstance()->getGraph()) {
1579+
if (auto track = graph->getSourceProcessor(ACTION_DATA(track))) {
1580+
track->setSolo(ACTION_DATA(oldSolo));
1581+
1582+
this->output("Undo set seq solo: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ ACTION_DATA(solo) ? "ON" : "OFF" } + "\n");;
1583+
ACTION_RESULT(true);
1584+
}
1585+
}
1586+
this->output("Can't undo set seq solo: [" + juce::String(ACTION_DATA(track)) + "] " + juce::String{ ACTION_DATA(solo) ? "ON" : "OFF" } + "\n");
1587+
ACTION_RESULT(false);
1588+
}
1589+
15481590
ActionSetSequencerTrackName::ActionSetSequencerTrackName(
15491591
int track, const juce::String& name)
15501592
: ACTION_DB{ track, name } {}

src/audioCore/action/ActionSet.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,29 @@ class ActionSetSequencerTrackMute final : public ActionUndoableBase {
369369
JUCE_LEAK_DETECTOR(ActionSetSequencerTrackMute)
370370
};
371371

372+
class ActionSetSequencerTrackSolo final : public ActionUndoableBase {
373+
public:
374+
ActionSetSequencerTrackSolo() = delete;
375+
ActionSetSequencerTrackSolo(
376+
int track, bool solo);
377+
378+
bool doAction() override;
379+
bool undo() override;
380+
const juce::String getName() override {
381+
return "Set Sequencer Track Solo";
382+
};
383+
384+
private:
385+
ACTION_DATABLOCK{
386+
const int track;
387+
const bool solo;
388+
389+
bool oldSolo = 0;
390+
} ACTION_DB;
391+
392+
JUCE_LEAK_DETECTOR(ActionSetSequencerTrackSolo)
393+
};
394+
372395
class ActionSetSequencerTrackName final : public ActionUndoableBase {
373396
public:
374397
ActionSetSequencerTrackName() = delete;

src/audioCore/graph/MainGraph.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ void MainGraph::clearGraph() {
199199
}
200200
this->audioSourceNodeList.clear();
201201

202+
/** Reset Solo Count */
203+
utils::resetSoloCount();
204+
202205
/** Callback */
203206
UICallbackAPI<int>::invoke(UICallbackType::InstrChanged, -1);
204207
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);

src/audioCore/graph/SeqSourceProcessor.cpp

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,16 +535,41 @@ SeqSourceProcessor::RecordState SeqSourceProcessor::getRecording() const {
535535
void SeqSourceProcessor::setMute(bool mute) {
536536
this->isMute = mute;
537537

538-
/** Close All Note */
539-
if (mute) {
540-
this->closeAllNote();
538+
/** Callback */
539+
UICallbackAPI<int>::invoke(UICallbackType::SeqMuteSoloChanged, this->index);
540+
}
541+
542+
bool SeqSourceProcessor::getMute() const {
543+
return this->isMute;
544+
}
545+
546+
void SeqSourceProcessor::setSolo(bool solo) {
547+
bool shouldChange = (this->isSolo == solo);
548+
549+
this->isSolo = solo;
550+
551+
/** Global Solo Count */
552+
if (shouldChange) {
553+
if (solo) {
554+
utils::increaseSoloCount();
555+
}
556+
else {
557+
utils::decreaseSoloCount();
558+
}
541559
}
542560

543561
/** Callback */
544-
UICallbackAPI<int>::invoke(UICallbackType::SeqMuteChanged, this->index);
562+
UICallbackAPI<int>::invoke(UICallbackType::SeqMuteSoloChanged, this->index);
545563
}
546564

547-
bool SeqSourceProcessor::getMute() const {
565+
bool SeqSourceProcessor::getSolo() const {
566+
return this->isSolo;
567+
}
568+
569+
bool SeqSourceProcessor::getEquivalentMute() const {
570+
if (utils::shouldSolo()) {
571+
return !this->isSolo;
572+
}
548573
return this->isMute;
549574
}
550575

@@ -711,7 +736,7 @@ void SeqSourceProcessor::processBlock(
711736
}
712737

713738
/** Process Mute */
714-
if (this->isMute) {
739+
if (this->getEquivalentMute()) {
715740
vMath::zeroAllAudioData(buffer);
716741
}
717742

@@ -774,6 +799,7 @@ bool SeqSourceProcessor::parse(
774799
this->setRecording(static_cast<RecordState>(mes->recordstate()));
775800
this->setInputMonitoring(mes->inputmonitoring());
776801
this->setMute(mes->muted());
802+
this->setSolo(mes->solo());
777803

778804
return true;
779805
}
@@ -825,6 +851,7 @@ std::unique_ptr<google::protobuf::Message> SeqSourceProcessor::serialize(
825851
mes->set_recordstate(static_cast<vsp4::SeqTrack::RecordState>(this->getRecording()));
826852
mes->set_inputmonitoring(this->getInputMonitoring());
827853
mes->set_muted(this->getMute());
854+
mes->set_solo(this->getSolo());
828855

829856
return std::unique_ptr<google::protobuf::Message>(mes.release());
830857
}

src/audioCore/graph/SeqSourceProcessor.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class SeqSourceProcessor final : public juce::AudioProcessorGraph,
8484

8585
void setMute(bool mute);
8686
bool getMute() const;
87+
void setSolo(bool solo);
88+
bool getSolo() const;
89+
bool getEquivalentMute() const;
8790

8891
void setInputMonitoring(bool inputMonitoring);
8992
bool getInputMonitoring() const;
@@ -160,6 +163,7 @@ class SeqSourceProcessor final : public juce::AudioProcessorGraph,
160163
std::atomic<RecordState> recordingFlag = RecordState::NotRecording;
161164

162165
std::atomic_bool isMute = false;
166+
std::atomic_bool isSolo = false;
163167
std::atomic_bool inputMonitoring = false;
164168

165169
juce::Array<float> outputLevels;

src/audioCore/quickAPI/QuickGet.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,24 @@ namespace quickAPI {
648648
return false;
649649
}
650650

651+
bool getSeqTrackSolo(int index) {
652+
if (auto graph = AudioCore::getInstance()->getGraph()) {
653+
if (auto track = graph->getSourceProcessor(index)) {
654+
return track->getSolo();
655+
}
656+
}
657+
return false;
658+
}
659+
660+
bool getSeqTrackEquivalentMute(int index) {
661+
if (auto graph = AudioCore::getInstance()->getGraph()) {
662+
if (auto track = graph->getSourceProcessor(index)) {
663+
return track->getEquivalentMute();
664+
}
665+
}
666+
return false;
667+
}
668+
651669
bool getSeqTrackInputMonitoring(int index) {
652670
if (auto graph = AudioCore::getInstance()->getGraph()) {
653671
if (auto track = graph->getSourceProcessor(index)) {

src/audioCore/quickAPI/QuickGet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ namespace quickAPI {
130130
const juce::Array<MIDILink> getSeqTrackMIDIOutputToMixer(int index);
131131
const juce::Array<AudioLink> getSeqTrackAudioOutputToMixer(int index);
132132
bool getSeqTrackMute(int index);
133+
bool getSeqTrackSolo(int index);
134+
bool getSeqTrackEquivalentMute(int index);
133135
bool getSeqTrackInputMonitoring(int index);
134136
RecordState getSeqTrackRecording(int index);
135137
const juce::Array<float> getSeqTrackOutputLevel(int index);

src/audioCore/recovery/ActionType.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ enum class ActionType : unsigned int {
8181
ActionSetSequencerTrackName,
8282
ActionSetSequencerTrackColor,
8383
ActionSetSequencerTrackMute,
84+
ActionSetSequencerTrackSolo,
8485
ActionSetEffect,
8586
ActionSetSequencerMIDITrack,
8687
ActionSetSequencerBlockTime,

src/audioCore/uiCallback/UICallbackType.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ enum class UICallbackType : int {
1616
EffectChanged,
1717
SeqChanged,
1818
SeqBlockChanged,
19-
SeqMuteChanged,
19+
SeqMuteSoloChanged,
2020
SeqInputMonitoringChanged,
2121
SeqRecChanged,
2222
TempoChanged,

src/ui/component/sequencer/SeqTrackComponent.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void SeqTrackComponent::update(int index) {
146146
}
147147
this->trackName->setButtonText(juce::String{ index } + " - " + name);
148148

149-
this->updateMute();
149+
this->updateMuteSolo();
150150
this->updateInputMonitoring();
151151
this->updateRec();
152152

@@ -169,7 +169,7 @@ void SeqTrackComponent::updateBlock(int blockIndex) {
169169
this->content->updateBlock(blockIndex);
170170
}
171171

172-
void SeqTrackComponent::updateMute() {
172+
void SeqTrackComponent::updateMuteSolo() {
173173
this->muteButton->update(this->index);
174174
}
175175

src/ui/component/sequencer/SeqTrackComponent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SeqTrackComponent final
3434

3535
void update(int index);
3636
void updateBlock(int blockIndex);
37-
void updateMute();
37+
void updateMuteSolo();
3838
void updateInputMonitoring();
3939
void updateRec();
4040
void updateInstr();

src/ui/component/sequencer/SeqTrackMuteComponent.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ void SeqTrackMuteComponent::paint(juce::Graphics& g) {
2121

2222
/** Color */
2323
auto& laf = this->getLookAndFeel();
24-
juce::Colour backgroundColor = laf.findColour(this->mute
24+
juce::Colour backgroundColor = laf.findColour(this->equivalentMute
2525
? juce::TextButton::ColourIds::buttonOnColourId
2626
: juce::TextButton::ColourIds::buttonColourId);
27-
juce::Colour textColor = laf.findColour(this->mute
27+
juce::Colour textColor = laf.findColour(this->equivalentMute
2828
? juce::TextButton::ColourIds::textColourOnId
2929
: juce::TextButton::ColourIds::textColourOffId);
3030

@@ -93,6 +93,7 @@ void SeqTrackMuteComponent::update(int index) {
9393
this->index = index;
9494
if (index > -1) {
9595
this->mute = quickAPI::getSeqTrackMute(index);
96+
this->equivalentMute = quickAPI::getSeqTrackEquivalentMute(index);
9697

9798
this->repaint();
9899
}

src/ui/component/sequencer/SeqTrackMuteComponent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class SeqTrackMuteComponent final
1919
private:
2020
int index = -1;
2121
bool mute = false;
22+
bool equivalentMute = false;
2223

2324
void changeMute();
2425
void showMenu();

src/ui/component/sequencer/SeqView.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ void SeqView::TrackList::updateBlock(int track, int index) {
5050
}
5151
}
5252

53-
void SeqView::TrackList::updateMute(int index) {
53+
void SeqView::TrackList::updateMuteSolo(int index) {
5454
if (index >= 0 && index < this->list.size()) {
55-
this->list[index]->updateMute();
55+
this->list[index]->updateMuteSolo();
5656
}
5757
}
5858

@@ -430,10 +430,10 @@ SeqView::SeqView()
430430
}
431431
}
432432
);
433-
CoreCallbacks::getInstance()->addSeqMuteChanged(
433+
CoreCallbacks::getInstance()->addSeqMuteSoloChanged(
434434
[comp = SeqView::SafePointer(this)](int index) {
435435
if (comp) {
436-
comp->updateMute(index);
436+
comp->updateMuteSolo(index);
437437
}
438438
}
439439
);
@@ -820,8 +820,8 @@ void SeqView::updateTempo() {
820820
this->updateGridTemp();
821821
}
822822

823-
void SeqView::updateMute(int index) {
824-
this->trackList->updateMute(index);
823+
void SeqView::updateMuteSolo(int index) {
824+
this->trackList->updateMuteSolo(index);
825825
}
826826

827827
void SeqView::updateInputMonitoring(int index) {

src/ui/component/sequencer/SeqView.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class SeqView final
2121
void update(int index);
2222
void updateBlock(int track, int index);
2323
void updateTempo();
24-
void updateMute(int index);
24+
void updateMuteSolo(int index);
2525
void updateInputMonitoring(int index);
2626
void updateRec(int index);
2727
void updateInstr(int index);
@@ -63,7 +63,7 @@ class SeqView final
6363

6464
void update(int index);
6565
void updateBlock(int track, int index);
66-
void updateMute(int index);
66+
void updateMuteSolo(int index);
6767
void updateInputMonitoring(int index);
6868
void updateRec(int index);
6969
void updateInstr(int index);

0 commit comments

Comments
 (0)