Skip to content

Commit

Permalink
Fixed track with no channels
Browse files Browse the repository at this point in the history
  • Loading branch information
FangCunWuChang committed Jul 13, 2024
1 parent 2d13ea5 commit 3e37b64
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/audioCore/graph/SeqSourceProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ void SeqSourceProcessor::prepareToPlay(
void SeqSourceProcessor::processBlock(
juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages) {
/** Check Buffer Is Empty */
if (buffer.getNumChannels() <= 0) { return; }
if (buffer.getNumSamples() <= 0) { return; }

/** Clear Audio Channel */
Expand Down
29 changes: 18 additions & 11 deletions src/audioCore/graph/Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ bool Track::removeAdditionalAudioBus() {
}

int Track::getAdditionalAudioBusNum() const {
if (this->audioChannels.size() <= 0) { return 0; }
return this->getTotalNumInputChannels() / this->audioChannels.size() - 1;
}

Expand Down Expand Up @@ -256,17 +257,19 @@ void Track::prepareToPlay(double sampleRate, int maximumExpectedSamplesPerBlock)
return;
}

/** Prepare Gain And Panner */
this->gainAndPanner.prepare(juce::dsp::ProcessSpec(
sampleRate, maximumExpectedSamplesPerBlock,
this->audioChannels.size()
));

/** Prepare Slider */
this->slider.prepare(juce::dsp::ProcessSpec(
sampleRate, maximumExpectedSamplesPerBlock,
this->audioChannels.size()
));
if (this->audioChannels.size() > 0) {
/** Prepare Gain And Panner */
this->gainAndPanner.prepare(juce::dsp::ProcessSpec(
sampleRate, maximumExpectedSamplesPerBlock,
this->audioChannels.size()
));

/** Prepare Slider */
this->slider.prepare(juce::dsp::ProcessSpec(
sampleRate, maximumExpectedSamplesPerBlock,
this->audioChannels.size()
));
}

/** Prepare Current Graph */
this->AudioProcessorGraph::prepareToPlay(sampleRate, maximumExpectedSamplesPerBlock);
Expand Down Expand Up @@ -363,6 +366,10 @@ bool Track::canRemoveBus(bool isInput) const {
}

void Track::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages) {
/** Check Buffer Is Empty */
if (buffer.getNumChannels() <= 0) { return; }
if (buffer.getNumSamples() <= 0) { return; }

/** Process Gain And Panner */
int mainChannels = this->audioChannels.size();
auto block = juce::dsp::AudioBlock<float>(buffer).getSubsetChannelBlock(
Expand Down
85 changes: 53 additions & 32 deletions src/ui/component/askfor/ChannelLinkView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,50 @@ void ChannelLinkViewContent::paint(juce::Graphics& g) {
g.setColour(lineColor);
g.drawRect(tableRect, lineThickness);

/** Table Content Line */
juce::Rectangle<float> tableContentHLineRect(
paddingWidth + titleWidth + 2 * cellWidth - lineThickness / 2,
paddingHeight + titleHeight,
lineThickness, tableHeight);
juce::Rectangle<float> tableContentVLineRect(
paddingWidth + titleWidth,
paddingHeight + titleHeight + 2 * cellHeight - lineThickness / 2,
tableWidth, lineThickness);
g.setColour(lineColor);
g.fillRect(tableContentHLineRect);
g.fillRect(tableContentVLineRect);

/** H Line */
g.setColour(lineColor);
int dstChannelPerBus = this->dstChannels.size();
for (int i = 0; i <= this->dstChannelNum + 2; i++) {
if (i >= 2) {
bool longLine = ((i - 2) % dstChannelPerBus) == 0;
juce::Rectangle<float> lineRect(
paddingWidth + titleWidth + i * cellWidth - lineThickness / 2,
paddingHeight + titleHeight + (longLine ? 0 : cellHeight),
lineThickness,
(this->srcChannelNum + 2) * cellHeight - (longLine ? 0 : cellHeight));
g.fillRect(lineRect);
if (dstChannelPerBus > 0) {
for (int i = 0; i <= this->dstChannelNum + 2; i++) {
if (i >= 2) {
bool longLine = ((i - 2) % dstChannelPerBus) == 0;
juce::Rectangle<float> lineRect(
paddingWidth + titleWidth + i * cellWidth - lineThickness / 2,
paddingHeight + titleHeight + (longLine ? 0 : cellHeight),
lineThickness,
(this->srcChannelNum + 2) * cellHeight - (longLine ? 0 : cellHeight));
g.fillRect(lineRect);
}
}
}

/** V Line */
g.setColour(lineColor);
int srcChannelPerBus = this->srcChannels.size();
for (int i = 0; i <= this->srcChannelNum + 2; i++) {
if (i >= 2) {
bool longLine = ((i - 2) % srcChannelPerBus) == 0;
juce::Rectangle<float> lineRect(
paddingWidth + titleWidth + (longLine ? 0 : cellWidth),
paddingHeight + titleHeight + i * cellHeight - lineThickness / 2,
(this->dstChannelNum + 2) * cellWidth - (longLine ? 0 : cellWidth),
lineThickness);
g.fillRect(lineRect);
if (srcChannelPerBus > 0) {
for (int i = 0; i <= this->srcChannelNum + 2; i++) {
if (i >= 2) {
bool longLine = ((i - 2) % srcChannelPerBus) == 0;
juce::Rectangle<float> lineRect(
paddingWidth + titleWidth + (longLine ? 0 : cellWidth),
paddingHeight + titleHeight + i * cellHeight - lineThickness / 2,
(this->dstChannelNum + 2) * cellWidth - (longLine ? 0 : cellWidth),
lineThickness);
g.fillRect(lineRect);
}
}
}

Expand All @@ -160,25 +177,29 @@ void ChannelLinkViewContent::paint(juce::Graphics& g) {
/** H Bus ID */
g.setColour(textColor);
g.setFont(textFont);
int dstBusNum = this->dstChannelNum / dstChannelPerBus;
for (int i = 0; i < dstBusNum; i++) {
juce::Rectangle<int> textRect(
paddingWidth + titleWidth + cellWidth * 2 + i * cellWidth * dstChannelPerBus,
paddingHeight + titleHeight, cellWidth * dstChannelPerBus, cellHeight);
g.drawFittedText(juce::String{ i }, textRect,
juce::Justification::centred, 1, 0.f);
if (dstChannelPerBus > 0) {
int dstBusNum = this->dstChannelNum / dstChannelPerBus;
for (int i = 0; i < dstBusNum; i++) {
juce::Rectangle<int> textRect(
paddingWidth + titleWidth + cellWidth * 2 + i * cellWidth * dstChannelPerBus,
paddingHeight + titleHeight, cellWidth * dstChannelPerBus, cellHeight);
g.drawFittedText(juce::String{ i }, textRect,
juce::Justification::centred, 1, 0.f);
}
}

/** V Bus ID */
g.setColour(textColor);
g.setFont(textFont);
int srcBusNum = this->srcChannelNum / srcChannelPerBus;
for (int i = 0; i < srcBusNum; i++) {
juce::Rectangle<int> textRect(paddingWidth + titleWidth,
paddingHeight + titleHeight + cellHeight * 2 + i * cellHeight * srcChannelPerBus,
cellWidth, cellHeight * srcChannelPerBus);
g.drawFittedText(juce::String{ i }, textRect,
juce::Justification::centred, 1, 0.f);
if (srcChannelPerBus > 0) {
int srcBusNum = this->srcChannelNum / srcChannelPerBus;
for (int i = 0; i < srcBusNum; i++) {
juce::Rectangle<int> textRect(paddingWidth + titleWidth,
paddingHeight + titleHeight + cellHeight * 2 + i * cellHeight * srcChannelPerBus,
cellWidth, cellHeight * srcChannelPerBus);
g.drawFittedText(juce::String{ i }, textRect,
juce::Justification::centred, 1, 0.f);
}
}

/** H Channel Name */
Expand Down

0 comments on commit 3e37b64

Please sign in to comment.