Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67911d47 authored by Shunkai Yao's avatar Shunkai Yao Committed by Automerger Merge Worker
Browse files

Merge "Support setting individual DP band" into main am: b1fd6953

parents dc1f5ca4 b1fd6953
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ static const DynamicsProcessing::EqBandConfig kEqBandConfigMax =
        DynamicsProcessing::EqBandConfig({.channel = std::numeric_limits<int>::max(),
                                          .band = std::numeric_limits<int>::max(),
                                          .enable = true,
                                          .cutoffFrequencyHz = 20000,
                                          .cutoffFrequencyHz = 20000.1,
                                          .gainDb = 200});

static const Range::DynamicsProcessingRange kPreEqBandConfigRange = {
@@ -144,7 +144,7 @@ static const Range::DynamicsProcessingRange kMbcBandConfigRange = {
                        {.channel = std::numeric_limits<int>::max(),
                         .band = std::numeric_limits<int>::max(),
                         .enable = true,
                         .cutoffFrequencyHz = 20000,
                         .cutoffFrequencyHz = 20000.1,
                         .attackTimeMs = 60000,
                         .releaseTimeMs = 60000,
                         .ratio = 50,
+16 −5
Original line number Diff line number Diff line
@@ -416,14 +416,25 @@ std::vector<DynamicsProcessing::EqBandConfig> DynamicsProcessingContext::getEqBa
template <typename T>
bool DynamicsProcessingContext::validateBandConfig(const std::vector<T>& bands, int maxChannel,
                                                   int maxBand) {
    std::vector<float> freqs(bands.size(), -1);
    std::map<int, float> freqs;
    for (auto band : bands) {
        if (!validateChannel(band.channel, maxChannel)) return false;
        if (!validateBand(band.band, maxBand)) return false;
        if (!validateChannel(band.channel, maxChannel)) {
            LOG(ERROR) << __func__ << " " << band.toString() << " invalid, maxCh " << maxChannel;
            return false;
        }
        if (!validateBand(band.band, maxBand)) {
            LOG(ERROR) << __func__ << " " << band.toString() << " invalid, maxBand " << maxBand;
            return false;
        }
        if (freqs.find(band.band) != freqs.end()) {
            LOG(ERROR) << __func__ << " " << band.toString() << " found duplicate";
            return false;
        }
        freqs[band.band] = band.cutoffFrequencyHz;
    }
    if (std::count(freqs.begin(), freqs.end(), -1)) return false;
    return std::is_sorted(freqs.begin(), freqs.end());
    return std::is_sorted(freqs.begin(), freqs.end(), [](const auto& a, const auto& b) {
        return a.second <= b.second; //index is already sorted as map key
    });
}

bool DynamicsProcessingContext::validateLimiterConfig(