Impulse response - accuracy


#1

Hello,
I have question probably more in audio processing, than programming at all.
Just for fun, for understand little bit more I made my own plugin to measure impulse response of the filters. Something that allows me to see various equalisers curves. Similar like it happens in Waves QClone plugin - but qClone can also implement those curves to other signals, like regular EQ, but my plugin just measure those curves - as I know VST Plugin Analyser can do similar things.
But with my plugin the problem is accuracy of low frequences, somewhere below 150 Hz it starts to show crazy curves, inappropriate to real EQ changes. But above 150 Hz everything is OK (almost OK - it shows almost perfectly the EQ curves, but has problem to show curves for very narrow Q parameters).
And I was wondering almost whole week, what I do wrong, I tried to change resolution o measured frequencies range, also tried to change buffersize for one impulse. Don’t know what to do and it is annoying hardly :slight_smile: please help me.
My code for measure impulse response is mainly like that:

float freqResolution = 1000.0f;

// it’s for set range of measured freq:
float minFreqIndex = log10(20.0f)*freqResolution / log10(wSampleRate);
float maxFreqIndex = log10(20000.0f)*freqResolution / log10(wSampleRate);

for(int sample=(int)minFreqIndex; sample < maxFreqIndex; sample++) {
    
    logScaleFreq = pow(10.0f, log10(wSampleRate) * (float)sample / (freqResolution-1.0f));
    
    
    _Re = processor.filteredImpulse[0];
    _Im = 0.0f;
    
    
    for (int i=1; i<buffersize; ++i) {
        _Re += processor.filteredImpulse[i] * cosf(-(float)i * 2 * double_Pi * logScaleFreq / wSampleRate);
        _Im += processor.filteredImpulse[i] * sinf(-(float)i * 2 * double_Pi * logScaleFreq / wSampleRate);
    }
    
    float _Re_2 = pow(_Re, 2.0f);
    float _Im_2 = pow(_Im, 2.0f);
    float _Hf = pow(_Re_2 + _Im_2, 0.5f);

    logScale_dB = 20*log10(_Hf);

Mainly it’s something like that, and then I print it as a logScale_dB in the function of logScaleFreq.
For any help, great thanks in advance.


#2

Of course

processor.filteredImpulse[i]

It’s an array of one impulse, something like [1, 0, 0, 0, 0, 0, 0, 0, 0…]
with length dependent on buffersize. But there is always only one 1, and many of zeros, like I think impulse should be :slight_smile:


#3

Sorry, my mistake.

processor.filteredImpulse[i]

is not impulse, it’s filtered impuls, but the source of it is array [1, 0, 0, 0, …\ which I described.