Skip to content

Commit

Permalink
fix(match runner): set maximum number of bands
Browse files Browse the repository at this point in the history
  • Loading branch information
zsliu98 committed Dec 31, 2024
1 parent e11ac03 commit 63b666f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions source/dsp/eq_match/eq_match_optimizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace zlEqMatch {
zlFilter::FilterType::lowShelf, zlFilter::FilterType::peak, zlFilter::FilterType::highShelf
};
static constexpr size_t maximumOrder = 6;
static constexpr std::array<double, 3> initSol{6.907755278982137, 0.0, -0.3465735902799726};
static constexpr std::array<double, 3> initSol{6.214608098422191, 0.0, -0.3465735902799726};

EqMatchOptimizer() {
mFilter.prepare(48000.0);
Expand Down Expand Up @@ -90,7 +90,7 @@ namespace zlEqMatch {
for (size_t j = i + 1; j < filters.size(); j++) {
mseS[j] = mseS[i];
filters[j].setFilterType(zlFilter::FilterType::peak);
filters[j].setFreq(1000.);
filters[j].setFreq(500.);
filters[j].setGain(0.);
filters[j].setQ(0.707);
}
Expand Down Expand Up @@ -157,7 +157,7 @@ namespace zlEqMatch {
mseS[j] = mseS[i];
filters[j].setFilterType(zlFilter::FilterType::peak);
filters[i].setOrder(2);
filters[j].setFreq(1000.);
filters[j].setFreq(500.);
filters[j].setGain(0.);
filters[j].setQ(0.707);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ namespace zlPanel {
slopeSlider.getSlider().onValueChange = [this]() {
analyzer.setSlope(static_cast<float>(slopeSlider.getSlider().getValue()));
};
numBandSlider.getSlider().setRange(1.0, 16.0, 1.0);
numBandSlider.getSlider().onValueChange = [this]() {
matchRunner.setNumBand(static_cast<size_t>(numBandSlider.getSlider().getValue()));
matchRunner.update();
Expand Down Expand Up @@ -172,6 +171,7 @@ namespace zlPanel {
analyzer.setON(false);
analyzer.reset();

numBandSlider.getSlider().setRange(1.0, 16.0, 1.0);
numBandSlider.getSlider().setValue(8.0, juce::dontSendNotification);
numBandSlider.updateDisplayValue();
matchRunner.setNumBand(static_cast<size_t>(8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ namespace zlPanel {
size_t currentNumBand = numBand.load();
if (toCalculateNumBand.exchange(false)) {
currentNumBand = estNumBand;
size_t currentMaxBand = mFilters.size();
for (size_t i = 0; i < mFilters.size(); i++) {
if (std::abs(mFilters[i].getGain()) < 1e-6) {
currentMaxBand = i;
break;
}
}
slider.getSlider().setRange(1.0, static_cast<double>(currentMaxBand), 1.0);
slider.getSlider().setValue(static_cast<double>(currentNumBand), juce::dontSendNotification);
slider.getSlider().setDoubleClickReturnValue(true, static_cast<double>(currentNumBand));
slider.updateDisplayValue();
Expand Down

0 comments on commit 63b666f

Please sign in to comment.