I am using a high-pass IIRFilter (at 5000Hz) on a buffer of float audio samples (at 44100Hz). I have filled the buffer with white noise I created myself, so I know that the samples are in the range -1 to 1, as is normal. However, after I apply the high-pass filter by calling processSamples, some of the samples are greater than 1 or less than -1. This seems like a problem of some kind. Can anyone explain? Why would the buffer get louder? It seems like it should get quieter.
Your filter is probably unstable - IIR filters have a feedback loop so the design is important - how did you set the coefficients? Post some code and I'll take a look.
I'm just using the built-in makeHighPass function. Could there be a bug in it?
Highly unlikely, I (and many others) use it extensively. Hard to see where you are going wrong without further info!
Ok here's basically what I'm doing. Simplified a bit for explanation purposes.
IIRFilter highPassFilter; // high pass filter at 5000 Hz: highPassFilter.setCoefficients(IIRCoefficients::makeHighPass(44100, 5000)); // ... // now, for every audio buffer, i'm artificially generating random samples: for (int i=0; i<numSamples; i++) tempBuffer[i] = 2.f*randomNumberGen.nextFloat()-1.f; // so, the temp buffer is guaranteed to have samples between -1.f and 1.f. // now apply the filter: highPassFilter.processSamples(tempBuffer, numSamples); // now, some of the samples in tempBuffer are greater than 1.f or less than -1.f ... ??
Any help appreciated.
hum.. I just got the same behaviour with a simple hipass, and I was not expecting that too. Did you find out something weird in the iirfilter in the end?
Or square wave with a more modest amplitude? Another break point frequency?
with a sine it seems ok, but I want to filter a simple noise. I tried a couple of frequencies, and I always had about +1.6dB
Just a thought, noise is not same as noise, see: https://en.wikipedia.org/wiki/Colors_of_noise
If your noise is simply random numbers as samples, there might be frequencies with higher amplitude than 0.0 dbFS, right?
So after applying a filter having an amplitude higher than 0.0 might be the correct result, isn't it?
Maybe try again with white noise, i.e. a signal which has equal power over all frequencies.
hum.. I did not think that much about it, but whatever the input signal, I was just not expecting a simple Hipass filter to amplify it. The default hipass does not have any resonance or gain boost, so I was not expecting to get samples > 1, but maybe I'm wrong?
I did use white noise yes, just a basic :
hpFilter.processSingleSampleRaw (rand.nextFloat() * 2.f - 1.f);
I totally don't know, if this can be in that dimension. I was just wondering, if filtering a random signal may expose unexpected contents... I am just a sceptic, not an expert on that topic...
i've been trying to figure this out too. My knowledge of filter maths is almost non existant. But just found this graph, which shows a simple highpass filter going out of bounds:
A filter may produce higher output than input, because of resonance and impulse responses. This is not necessarily related to the filter being stable.
This is also why adding a lowcut to a mix to increase headroom by removing subsonic frequencies doesn't always actually achieve that goal (the resonance at the cutoff contributes more RMS than the reduced frequency material).
yes, I guess the default filter made with makeHiPass is a butterworth?
I was just not expecting any resonance or gain there, and the doc does not say that much.
it would be great to have Q and Gain parameters to the MakeHiPass & MakeLowPass, but anyway, I guess the upcoming dsp module will be much better concerning filters & co.
Checkout the dRowAudio filters - Dave’s implementation of HiPass and LoPass have a Q parameter.
If it’s a Butterworth filter you change the slope with the number of poles… which neither implementation provides. For that you may need to check out Vinnie’s DSP library.
Maybe that's the perfect moment to ask Jules et al., if there is an update on the planned DSP module? Still looking forward for it...
It's either going to be like Duke Nukem Forever or Half Life 3.
Releasing a first version of the DSP module is on our roadmap for the next couple of months.
As it looks right now, there are a few things that need to happen first, like support for AudioUnit 3 and certain necessary improvements in the Introjucer/Projucer. After this, the DSP module is one of the major topics we want to tackle next.