Coder Social home page Coder Social logo

Comments (4)

drewandre avatar drewandre commented on June 29, 2024 1

It has been a long time since I've worked on this project but I pulled up the function where I averaged the filter output. Hopefully this helps.

void calculate_iir_filter_bank() {
  float avg, x;
  for (int i = 0; i < NUM_AUDIO_ANALYSIS_BANDS; i++) { // NUM_AUDIO_ANALYSIS_BANDS was 7 in my case to match MSGEQ7
    avg = 0.0f;

    dsps_biquad_f32(buffer, filter_output, N_SAMPLES, filter_coefficients[i], filter_delay_lines[i]);

    for (int t = 0; t < N_SAMPLES; t++)
    {
      x = fabs(filter_output[t]) * 4.0f;
      avg += x;
    }
    avg /= (float)N_SAMPLES;

    avg *= filters_amp_adjustments[i];

    if (avg > 1) {
      avg = 1;
    }

    averages[i] = (SMOOTHING_FACTOR * averages[i]) + ((1 - SMOOTHING_FACTOR) * avg);
  }
}

from esp-dsp.

dmitry1945 avatar dmitry1945 commented on June 29, 2024

Hi @drewandre
For this purpose better if you will use IIR filter bank.
You can look to the esp-dsp/examples/iir.

There you will find how to generate a single IIR filter:
ret = dsps_biquad_gen_lpf_f32(coeffs_lpf, freq, qFactor);

The frequency is just: your_frequency/sample_frequency. In your case it will be 163/44100, and so on. You will have 7 filters.
The Q factor you have to play with this parameter.
In this example you can tune your filters.

At the output of your filters you make:
average[i] = K*average[i] + (1 - K)*absf(output[i]);

Where:
i - bank number from 0 to 6
K - smoothing coefficient 0.9..0.9999, 0.9999 - very smooth.
output[i] - output of i'th filter.
average[i] - result of your equalizer for i'th bank
absf - module operation.

Regards,
Dmitry

from esp-dsp.

drewandre avatar drewandre commented on June 29, 2024

@dmitry1945 thanks, this was very helpful!

from esp-dsp.

generic-beat-detector avatar generic-beat-detector commented on June 29, 2024

@dmitry1945

Hello sir. I applaud the effort behind this wonderful project!

I'd like some clarification please -- assuming the following for a single filter instance:

dsps_biquad_f32(x, y, N, coeffs_lpf, w_lpf);

How did the output y (array of floats) compute to output[i] (single float value)? I'm I missing something?

Regards.

from esp-dsp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.