Hi Gentlemen, Please advise if you have thoughts on my questions. I'm developing a program which will be used as audio cross-over, meaning that I need to filter the audio signal (HP, LP). I'm using SPUC library and FIR class defined there. FIR coeffs are calculated using Remez algorithm (remez_fir class) and Blackman window applied to them as well. Everything seems to be good - impulse response graph looks ideal, FFT performed on impulse response gives nice picture in frequency domain. But when I put a test .wav in I hear crackling sounds at some moments during the playback (while frequencies seem to be filtered correctly). And looks like this happens mainly in LP filter. All calculations are done using doubles (converted to ints only in the output). Number of taps doesnt seem to affect the issue greately - I went up to 1000 taps, but crackles are still there. Can anyone advise what could be the reason for this and how to avoid it? If it's hard to say like that, may be some recommendation on which tests to perform to find out the root cause. Thanks to everyone!
crackling sound after FIR filtration
Started by ●February 27, 2008
Reply by ●February 27, 20082008-02-27
Reply by ●February 27, 20082008-02-27
"Decay" <dan_nomad@mail.ru> writes:> Hi Gentlemen, > > Please advise if you have thoughts on my questions. > I'm developing a program which will be used as audio cross-over, meaning > that I need to filter the audio signal (HP, LP). > I'm using SPUC library and FIR class defined there. FIR coeffs are > calculated using Remez algorithm (remez_fir class) and Blackman window > applied to them as well. > Everything seems to be good - impulse response graph looks ideal, FFT > performed on impulse response gives nice picture in frequency domain. > But when I put a test .wav in I hear crackling sounds at some moments > during the playback (while frequencies seem to be filtered correctly). And > looks like this happens mainly in LP filter. > All calculations are done using doubles (converted to ints only in the > output). Number of taps doesnt seem to affect the issue greately - I went > up to 1000 taps, but crackles are still there. > > Can anyone advise what could be the reason for this and how to avoid it? > If it's hard to say like that, may be some recommendation on which tests > to perform to find out the root cause. > > Thanks to everyone!You're probably overflowing the output. Should be a simple matter to put in a test: if ((float)x > 32767.0) || (float)x < -32768.0)) { overflow(); } -- % Randy Yates % "She's sweet on Wagner-I think she'd die for Beethoven. %% Fuquay-Varina, NC % She love the way Puccini lays down a tune, and %%% 919-577-9882 % Verdi's always creepin' from her room." %%%% <yates@ieee.org> % "Rockaria", *A New World Record*, ELO http://www.digitalsignallabs.com
Reply by ●February 27, 20082008-02-27
Randy Yates <yates@ieee.org> writes:> [...] > if ((float)x > 32767.0) || (float)x < -32768.0))Damned parentheses! : if ( ((float)x > 32767.0) || ((float)x < -32768.0) ) -- % Randy Yates % "My Shangri-la has gone away, fading like %% Fuquay-Varina, NC % the Beatles on 'Hey Jude'" %%% 919-577-9882 % %%%% <yates@ieee.org> % 'Shangri-La', *A New World Record*, ELO http://www.digitalsignallabs.com
Reply by ●February 27, 20082008-02-27
Hi Randy You're good! That's really happening, i'm falling out of 16 bits. So my next question is WHY? I was under impression that if sum of all coeffs is 1, then output will never be greater than input, I'm filtering, not equalizing anything. Is it because of the passband ripples? How can I avoid it and be sure that I'll never get values above those maximal of bit-per-second I use?
Reply by ●February 27, 20082008-02-27
>Hi Randy > >You're good! That's really happening, i'm falling out of 16 bits. > >So my next question is WHY? > >I was under impression that if sum of all coeffs is 1, then output will >never be greater than input, I'm filtering, not equalizing anything. > >Is it because of the passband ripples? How can I avoid it and be surethat>I'll never get values above those maximal of bit-per-second I use? >bits-per_SAMPLE of course p.s. replacing failing samples with +-32767 will not solve the problem - crackles are not that disturbing in this case, but it's not good since it's clipping, distorting the sound. And it's audible.
Reply by ●February 27, 20082008-02-27
Decay wrote:>> Hi Randy >> >> You're good! That's really happening, i'm falling out of 16 bits. >> >> So my next question is WHY? >> >> I was under impression that if sum of all coeffs is 1, then output will >> never be greater than input, I'm filtering, not equalizing anything. >> >> Is it because of the passband ripples? How can I avoid it and be sure > that >> I'll never get values above those maximal of bit-per-second I use? >> > > bits-per_SAMPLE of course > > p.s. replacing failing samples with +-32767 will not solve the problem - > crackles are not that disturbing in this case, but it's not good since > it's clipping, distorting the sound. And it's audible.I'll bet that real infrequent clipping would be inaudible. I think Randy has it right: the signal is wrapping around. The sum of the coefficients being 1 or less doesn't guarantee no overflow. If someone told you that it does, he probably omitted "absolute value" from the sum. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●February 27, 20082008-02-27
Decay wrote:> Hi Gentlemen, > > Please advise if you have thoughts on my questions. > I'm developing a program which will be used as audio cross-over, meaning > that I need to filter the audio signal (HP, LP). > I'm using SPUC library and FIR class defined there.First mistake. Don't use FIRs for the audio crossover.> FIR coeffs are > calculated using Remez algorithm (remez_fir class) and Blackman window > applied to them as well.Second mistake. The filters are designed either by Remez or by windows. Remez and windows altogether do not make sense.> Everything seems to be good - impulse response graph looks ideal, FFT > performed on impulse response gives nice picture in frequency domain. > But when I put a test .wav in I hear crackling sounds at some moments > during the playback (while frequencies seem to be filtered correctly). And > looks like this happens mainly in LP filter.Apparently there is an error with the data manipulation, or some buffer overrun/underrun issue.> All calculations are done using doubles (converted to ints only in the > output). Number of taps doesnt seem to affect the issue greately - I went > up to 1000 taps, but crackles are still there. > > Can anyone advise what could be the reason for thisThe reason for that is the lack of experience. > and how to avoid it? Hire the consultant :)> If it's hard to say like that, may be some recommendation on which tests > to perform to find out the root cause.Check everything. Can you just pass the signal straight through without any filters? Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
Reply by ●February 27, 20082008-02-27
Hello, Even though the filter sum of coefficients is 1. It's output can still go above +/- 1 (for input in the range of +/-1). This is possible due to continous transients at input. So you should check your filter for following inputs. 1. sinewave -> perform SNR analysis (check SNR_in and SNR_out). 2. impulse response -> check that u get all the coefficients. 3. step response -> check for overshoot/undershoot and rollovers. 4. pseudo-random input -> check for max/min any node can reach. If input is 16 bits, then filter output will be 17 bits. You need to put round+saturate module before you give out the output as 16 bits. Also you need to perform SNR analysis to make sure you have maintained enough bits on LSB side. Not sure, but maybe the band splitting also can be checked. Instead of having simple split criteria like Hlpf(w) + Hhpf(w) = 1. you may want to split using power law criteria. Hlpf^2 + Hhpf^2 = 1. Vladimir might want to comment more on this. Thanks and Regards Bharat Pathak Arithos Designs www.Arithos.com IP Development...........DSP Design Consultancy..........Training.> >I was under impression that if sum of all coeffs is 1, then output will >never be greater than input, I'm filtering, not equalizing anything. > >Is it because of the passband ripples? How can I avoid it and be surethat>I'll never get values above those maximal of bit-per-second I use? >
Reply by ●February 27, 20082008-02-27
>First mistake. Don't use FIRs for the audio crossover.Why? IIR instead? What about non-linear phase?>Second mistake. The filters are designed either by Remez or by windows. >Remez and windows altogether do not make sense.I'm not sure if it makes sense to gurus, but in my case simple Remez (at lease as implemented in SPUC) didn't give me zero values at the ends of the IR. Blackman's window corrected that. But anyway, this was not the cause of the issue (neither was a cure)..>Apparently there is an error with the data manipulation, or some buffer >overrun/underrun issue.No, nothing like that. I do not do any buffer swaping or multi-buffered reading. Whole file is read into memory and processed (that's for testing). And crackles (read INT16 overflows) appear in loudest passages - which makes sense..>The reason for that is the lack of experience. > > > and how to avoid it? > >Hire the consultant :)Thanks, but that's not constructive. This way we can get to "Go buy Tact amplifier instead". :)> >> If it's hard to say like that, may be some recommendation on whichtests>> to perform to find out the root cause. > >Check everything. Can you just pass the signal straight through without >any filters?Sure, I did check bypass. Sounds ok. LP also sounds good until large levels come. Spasibo za otveti!> > > >Vladimir Vassilevsky >DSP and Mixed Signal Design Consultant >http://www.abvolt.com > > >