Skip to content

Commit

Permalink
0.9.4 Bug Fix: can't set line num when the GUI is not open
Browse files Browse the repository at this point in the history
temp fix. Should not set lineNum in processblock every time
  • Loading branch information
jerryuhoo committed Nov 20, 2021
1 parent f9ffc42 commit e8fe8aa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
6 changes: 3 additions & 3 deletions Source/Panels/SpectrogramPanel/Multiband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void Multiband::paint (juce::Graphics& g)
updateLines(0);
setSoloRelatedBounds();
freqDividerGroup[i]->getCloseButton().setMouseClickState(true);
processor.setLineNum(lineNum);
processor.setLineNum();
}
}

Expand All @@ -256,7 +256,7 @@ void Multiband::paint (juce::Graphics& g)
stateComponent.setChangedState(false);
updateLines(1); // 1 means setBounds by setting frequency
setSoloRelatedBounds();
processor.setLineNum(lineNum);
processor.setLineNum();
}
}

Expand Down Expand Up @@ -635,7 +635,7 @@ void Multiband::mouseDown(const juce::MouseEvent &e)
freqDividerGroup[i]->getVerticalLine().setMoving(true);
freqDividerGroup[i]->setCloseButtonValue(true);
updateLines(0);
processor.setLineNum(lineNum);
processor.setLineNum();
setStatesWhenAddOrDelete(i, "add");
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ FireAudioProcessorEditor::~FireAudioProcessorEditor()
void FireAudioProcessorEditor::initEditor()
{
setSize(processor.getSavedWidth(), processor.getSavedHeight());
processor.setLineNum(multiband.getLineNum());
// processor.setLineNum(multiband.getLineNum());
//processor.setPresetId(processor.getPresetId());
//lastPresetName = stateComponent.getPresetName();

Expand Down
29 changes: 24 additions & 5 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,9 @@ void FireAudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::Mi
int freqValue2 = static_cast<int>(*treeState.getRawParameterValue(FREQ_ID2));
int freqValue3 = static_cast<int>(*treeState.getRawParameterValue(FREQ_ID3));

bool lineState1 = static_cast<int>(*treeState.getRawParameterValue(LINE_STATE_ID1));
bool lineState2 = static_cast<int>(*treeState.getRawParameterValue(LINE_STATE_ID2));
bool lineState3 = static_cast<int>(*treeState.getRawParameterValue(LINE_STATE_ID3));
bool lineState1 = static_cast<bool>(*treeState.getRawParameterValue(LINE_STATE_ID1));
bool lineState2 = static_cast<bool>(*treeState.getRawParameterValue(LINE_STATE_ID2));
bool lineState3 = static_cast<bool>(*treeState.getRawParameterValue(LINE_STATE_ID3));

// sort freq
std::array<int, 3> freqArray = {0, 0, 0};
Expand All @@ -464,6 +464,9 @@ void FireAudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::Mi
if (lineState2) freqArray[count++] = freqValue2;
if (lineState3) freqArray[count++] = freqValue3;

//TODO: Temp fix. Should not set lineNum in processblock every time.
lineNum = count;

std::sort(freqArray.begin(), freqArray.begin() + count);

freqValue1 = freqArray[0];
Expand Down Expand Up @@ -1324,9 +1327,25 @@ void FireAudioProcessor::mixProcessor(juce::String mixId, juce::SmoothedValue<fl
// return lineNum;
//}

void FireAudioProcessor::setLineNum(int lineNum)
void FireAudioProcessor::setLineNum()
{
this->lineNum = lineNum;
// maybe this method is useless, or delete "lineNum = count" in processBlock
int num = 0;

if (*treeState.getRawParameterValue(LINE_STATE_ID1))
{
num += 1;
}
if (*treeState.getRawParameterValue(LINE_STATE_ID2))
{
num += 1;
}
if (*treeState.getRawParameterValue(LINE_STATE_ID3))
{
num += 1;
}

this->lineNum = num;
}

// VU meters
Expand Down
2 changes: 1 addition & 1 deletion Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class FireAudioProcessor : public juce::AudioProcessor

// get number of activated lines
// int getLineNum();
void setLineNum(int lineNum);
void setLineNum();

// VU meters
float getInputMeterRMSLevel(int channel, juce::String bandName);
Expand Down

0 comments on commit e8fe8aa

Please sign in to comment.