Skip to content

Commit

Permalink
Add MixerTrackComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Jan 31, 2024
1 parent 4db71be commit 8061159
Show file tree
Hide file tree
Showing 21 changed files with 322 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/audioCore/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,10 @@ namespace utils {
88200, 96000, 176400, 192000, 352800, 384000 };
}

juce::Colour getDefaultColour() {
return juce::Colour::fromRGB(98, 111, 252);
}

void bufferOutputResampledFixed(juce::AudioSampleBuffer& dst, const juce::AudioSampleBuffer& src,
juce::AudioSampleBuffer& temp1, juce::AudioSampleBuffer& temp2,
double resampleRatio, int channels, double dstSampleRate,
Expand Down
2 changes: 2 additions & 0 deletions src/audioCore/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ namespace utils {
const juce::StringArray getPluginFormatsSupported();
const juce::Array<double> getSourceSampleRateSupported();

juce::Colour getDefaultColour();

using AudioConnection = std::tuple<int, int, int, int>;
using AudioConnectionList = juce::Array<AudioConnection>;

Expand Down
5 changes: 5 additions & 0 deletions src/audioCore/graph/MainGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "../misc/Renderer.h"
#include "../misc/AudioLock.h"
#include "../misc/VMath.h"
#include "../uiCallback/UICallback.h"
#include "../source/CloneableSourceManager.h"
#include "../AudioCore.h"
#include "../Utils.h"
Expand Down Expand Up @@ -205,6 +206,10 @@ void MainGraph::clearGraph() {
this->removeNode(i->nodeID);
}
this->audioSourceNodeList.clear();

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::InstrChanged, -1);
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

const juce::Array<float> MainGraph::getOutputLevels() const {
Expand Down
48 changes: 48 additions & 0 deletions src/audioCore/graph/MixerGraph.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "MainGraph.h"
#include "../uiCallback/UICallback.h"

void MainGraph::insertTrack(int index, const juce::AudioChannelSet& type) {
/** Add Node To Graph */
Expand All @@ -19,6 +20,9 @@ void MainGraph::insertTrack(int index, const juce::AudioChannelSet& type) {
/** Prepare To Play */
ptrNode->getProcessor()->setPlayHead(this->getPlayHead());
ptrNode->getProcessor()->prepareToPlay(this->getSampleRate(), this->getBlockSize());

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, index);
}
else {
jassertfalse;
Expand Down Expand Up @@ -102,6 +106,9 @@ void MainGraph::removeTrack(int index) {

/** Remove Node From Graph */
this->removeNode(nodeID);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, index);
}

int MainGraph::getTrackNum() const {
Expand All @@ -117,6 +124,9 @@ void MainGraph::setTrackBypass(int index, bool bypass) {
if (index < 0 || index >= this->trackNodeList.size()) { return; }
if (auto node = this->trackNodeList.getUnchecked(index)) {
node->setBypassed(bypass);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, index);
}
}

Expand Down Expand Up @@ -144,6 +154,9 @@ void MainGraph::setMIDII2TrkConnection(int trackIndex) {
{nodeID, this->midiChannelIndex} };
this->addConnection(connection);
this->midiI2TrkConnectionList.add(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeMIDII2TrkConnection(int trackIndex) {
Expand All @@ -162,6 +175,9 @@ void MainGraph::removeMIDII2TrkConnection(int trackIndex) {
}
return false;
});

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::setAudioI2TrkConnection(int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -183,6 +199,9 @@ void MainGraph::setAudioI2TrkConnection(int trackIndex, int srcChannel, int dstC
this->addConnection(connection);
this->audioI2TrkConnectionList.add(connection);
}

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeAudioI2TrkConnection(int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -194,6 +213,9 @@ void MainGraph::removeAudioI2TrkConnection(int trackIndex, int srcChannel, int d
{ {this->audioInputNode->nodeID, srcChannel}, {nodeID, dstChannel} };
this->removeConnection(connection);
this->audioI2TrkConnectionList.removeAllInstancesOf(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::setAudioTrk2OConnection(int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -215,6 +237,9 @@ void MainGraph::setAudioTrk2OConnection(int trackIndex, int srcChannel, int dstC
this->addConnection(connection);
this->audioTrk2OConnectionList.add(connection);
}

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeAudioTrk2OConnection(int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -226,6 +251,9 @@ void MainGraph::removeAudioTrk2OConnection(int trackIndex, int srcChannel, int d
{ {nodeID, srcChannel}, {this->audioOutputNode->nodeID, dstChannel} };
this->removeConnection(connection);
this->audioTrk2OConnectionList.removeAllInstancesOf(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::setAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, int srcChannel, int dstChannel) {
Expand Down Expand Up @@ -255,6 +283,10 @@ void MainGraph::setAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, int
this->addConnection(connection);
this->audioTrk2TrkConnectionList.add(connection);
}

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, dstTrackIndex);
}

void MainGraph::removeAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex, int srcChannel, int dstChannel) {
Expand All @@ -274,6 +306,10 @@ void MainGraph::removeAudioTrk2TrkConnection(int trackIndex, int dstTrackIndex,
{ {nodeID, srcChannel}, {dstNodeID, dstChannel} };
this->removeConnection(connection);
this->audioTrk2TrkConnectionList.removeAllInstancesOf(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, dstTrackIndex);
}

void MainGraph::setMIDITrk2OConnection(int trackIndex) {
Expand All @@ -292,6 +328,9 @@ void MainGraph::setMIDITrk2OConnection(int trackIndex) {
{this->midiOutputNode->nodeID, this->midiChannelIndex} };
this->addConnection(connection);
this->midiTrk2OConnectionList.add(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeMIDITrk2OConnection(int trackIndex) {
Expand All @@ -310,6 +349,9 @@ void MainGraph::removeMIDITrk2OConnection(int trackIndex) {
}
return false;
});

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

bool MainGraph::isMIDII2TrkConnected(int trackIndex) const {
Expand Down Expand Up @@ -723,6 +765,9 @@ void MainGraph::removeIllegalAudioI2TrkConnections() {
}
return false;
});

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

void MainGraph::removeIllegalAudioTrk2OConnections() {
Expand All @@ -734,6 +779,9 @@ void MainGraph::removeIllegalAudioTrk2OConnections() {
}
return false;
});

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

int MainGraph::findTrack(const Track* ptr) const {
Expand Down
14 changes: 14 additions & 0 deletions src/audioCore/graph/SendGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ void MainGraph::setMIDISrc2TrkConnection(int sourceIndex, int trackIndex) {
{trkNodeID, this->midiChannelIndex} };
this->addConnection(connection);
this->midiSrc2TrkConnectionList.add(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeMIDISrc2TrkConnection(int sourceIndex, int trackIndex) {
Expand All @@ -40,6 +43,9 @@ void MainGraph::removeMIDISrc2TrkConnection(int sourceIndex, int trackIndex) {
}
return false;
});

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::setAudioSrc2TrkConnection(int sourceIndex, int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -66,6 +72,9 @@ void MainGraph::setAudioSrc2TrkConnection(int sourceIndex, int trackIndex, int s
this->addConnection(connection);
this->audioSrc2TrkConnectionList.add(connection);
}

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeAudioSrc2TrkConnection(int sourceIndex, int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -82,6 +91,9 @@ void MainGraph::removeAudioSrc2TrkConnection(int sourceIndex, int trackIndex, in
{ {srcNodeID, srcChannel}, {trkNodeID, dstChannel} };
this->removeConnection(connection);
this->audioSrc2TrkConnectionList.removeAllInstancesOf(connection);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::setAudioInstr2TrkConnection(int instrIndex, int trackIndex, int srcChannel, int dstChannel) {
Expand Down Expand Up @@ -111,6 +123,7 @@ void MainGraph::setAudioInstr2TrkConnection(int instrIndex, int trackIndex, int

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::InstrChanged, instrIndex);
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

void MainGraph::removeAudioInstr2TrkConnection(int instrIndex, int trackIndex, int srcChannel, int dstChannel) {
Expand All @@ -130,6 +143,7 @@ void MainGraph::removeAudioInstr2TrkConnection(int instrIndex, int trackIndex, i

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::InstrChanged, instrIndex);
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, trackIndex);
}

bool MainGraph::isMIDISrc2TrkConnected(int sourceIndex, int trackIndex) const {
Expand Down
3 changes: 3 additions & 0 deletions src/audioCore/graph/SeqSourceProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ SeqSourceProcessor::SeqSourceProcessor(const juce::AudioChannelSet& type)
/** Set Channel Layout */
this->setChannelLayoutOfBus(true, 0, type);
this->setChannelLayoutOfBus(false, 0, type);

/** Default Color */
this->trackColor = utils::getDefaultColour();
}

int SeqSourceProcessor::addSeq(const SourceList::SeqBlock& block) {
Expand Down
28 changes: 28 additions & 0 deletions src/audioCore/graph/Track.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Track.h"

#include "../misc/Renderer.h"
#include "../uiCallback/UICallback.h"
#include "../Utils.h"
#include <VSP4.h>
using namespace org::vocalsharp::vocalshaper;
Expand Down Expand Up @@ -63,6 +64,9 @@ Track::Track(const juce::AudioChannelSet& type)
/** Connect MIDI IO Node */
this->addConnection(
{ {this->midiInputNode->nodeID, this->midiChannelIndex}, {this->midiOutputNode->nodeID, this->midiChannelIndex} });

/** Default Color */
this->trackColor = utils::getDefaultColour();
}

bool Track::addAdditionalAudioBus() {
Expand Down Expand Up @@ -101,6 +105,9 @@ bool Track::addAdditionalAudioBus() {
{this->pluginDockNode->nodeID, i} });
}

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);

return true;
}

Expand Down Expand Up @@ -136,6 +143,9 @@ bool Track::removeAdditionalAudioBus() {
/** Auto Remove Connection */
this->removeIllegalConnections();

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);

return true;
}

Expand All @@ -145,6 +155,9 @@ int Track::getAdditionalAudioBusNum() const {

void Track::setMute(bool mute) {
this->isMute = mute;

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

bool Track::getMute() const {
Expand All @@ -154,6 +167,9 @@ bool Track::getMute() const {
void Track::setGain(float gain) {
auto& gainDsp = this->gainAndPanner.get<0>();
gainDsp.setGainDecibels(gain);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

float Track::getGain() const {
Expand All @@ -167,6 +183,9 @@ void Track::setPan(float pan) {

auto& panDsp = this->gainAndPanner.get<1>();
panDsp.setPan(pan);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

float Track::getPan() const {
Expand All @@ -176,6 +195,9 @@ float Track::getPan() const {
void Track::setSlider(float slider) {
auto& sliderDsp = this->slider.get<0>();
sliderDsp.setGainLinear(slider);

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

float Track::getSlider() const {
Expand All @@ -185,6 +207,9 @@ float Track::getSlider() const {

void Track::setTrackName(const juce::String& name) {
this->trackName = name;

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

const juce::String Track::getTrackName() const {
Expand All @@ -193,6 +218,9 @@ const juce::String Track::getTrackName() const {

void Track::setTrackColor(const juce::Colour& color) {
this->trackColor = color;

/** Callback */
UICallbackAPI<int>::invoke(UICallbackType::TrackChanged, -1);
}

const juce::Colour Track::getTrackColor() const {
Expand Down
9 changes: 9 additions & 0 deletions src/audioCore/quickAPI/QuickGet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,15 @@ namespace quickAPI {
return result;
}

const juce::Colour getMixerTrackColor(int index) {
if (auto graph = AudioCore::getInstance()->getGraph()) {
if (auto track = graph->getTrackProcessor(index)) {
return track->getTrackColor();
}
}
return utils::getDefaultColour();
}

const juce::AudioChannelSet getMixerTrackChannelSet(int index) {
if (auto graph = AudioCore::getInstance()->getGraph()) {
if (auto track = graph->getTrackProcessor(index)) {
Expand Down
1 change: 1 addition & 0 deletions src/audioCore/quickAPI/QuickGet.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ namespace quickAPI {
int getMixerTrackNum();
const juce::String getMixerTrackName(int index);
const juce::StringArray getMixerTrackNameList();
const juce::Colour getMixerTrackColor(int index);
const juce::AudioChannelSet getMixerTrackChannelSet(int index);
int getMixerTrackInputChannelNum(int index);
int getMixerTrackOutputChannelNum(int index);
Expand Down
1 change: 1 addition & 0 deletions src/audioCore/uiCallback/UICallbackType.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ enum class UICallbackType : int {
PluginSearchStateChanged,
SourceChanged,
InstrChanged,
TrackChanged,

TypeMaxNum
};
Loading

0 comments on commit 8061159

Please sign in to comment.