Add per-band frequency control and static EQ curve overlay

This commit is contained in:
Gelyk 2026-08-29 15:42:21 +02:00
commit 8e9eb733cb
5 changed files with 172 additions and 11 deletions

View file

@ -3,6 +3,52 @@
namespace gelyk
{
void computeEQResponse(const FilterBand::Type* types,
const float* gains, const float* freqs, const float* qs,
int numBands, double sampleRate, float* outDb, int numBins)
{
if (numBins <= 0)
return;
for (int b = 0; b < numBins; ++b)
outDb[b] = 0.0f;
const float fMin = 20.0f;
const float fMax = 20000.0f;
const float logMin = std::log10(fMin);
const float logMax = std::log10(fMax);
for (int i = 0; i < numBands; ++i)
{
const float g = juce::jlimit(-24.0f, 24.0f, gains[i]);
const float gainFactor = juce::Decibels::decibelsToGain(g);
const float f = juce::jlimit(20.0f, 20000.0f, freqs[i]);
const float q = juce::jlimit(0.1f, 6.0f, qs[i]);
FilterBand::Coeffs::Ptr c;
switch (types[i])
{
case FilterBand::Type::lowShelf:
c = FilterBand::Coeffs::makeLowShelf(sampleRate, f, q, gainFactor);
break;
case FilterBand::Type::highShelf:
c = FilterBand::Coeffs::makeHighShelf(sampleRate, f, q, gainFactor);
break;
case FilterBand::Type::peak:
default:
c = FilterBand::Coeffs::makePeakFilter(sampleRate, f, q, gainFactor);
break;
}
for (int b = 0; b < numBins; ++b)
{
const float ratio = (float) b / (float) (numBins - 1);
const double freq = std::pow(10.0, logMin + ratio * (logMax - logMin));
outDb[b] += 20.0f * std::log10((float) c->getMagnitudeForFrequency(freq, sampleRate));
}
}
}
// ---------------------------------------------------------------------------
// FilterBand
// ---------------------------------------------------------------------------