IIR_Lab : a design help for digital audio filters - Page 3 - diyAudio
Go Back   Home > Forums > Source & Line > Digital Line Level

Digital Line Level DACs, Digital Crossovers, Equalizers, etc.

Please consider donating to help us continue to serve you.

Ads on/off / Custom Title / More PMs / More album space / Advanced printing & mass image saving
Reply
 
Thread Tools Search this Thread
Old 20th May 2012, 05:22 PM   #21
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
Quote:
Originally Posted by twest820 View Post
Hmm, wiggles should be visible at Q = sqrt(2)/2. They get worse at higher Q. Attaching a few screen grabs from IIR lab on my side.
Hey, for the last three plots, you selected a Rect. Window for the BodeGen. You need to remember that the BodePlot gets "brute force" computed using the White (Noise) test signal, not periodic, hence the importance of the Windows. Use the Triangle Windows and you'll see the change.

Quote:
Originally Posted by twest820 View Post
From what I can tell at a glance the filters seem to be direct form 1 and I get that the blending is controlled by the numerator coefficients. The BP looks like the 0dB peak gain form and the weighting of each form by the HP, BP, or LP coefficient entered in the UI is clear.
You are all right. In an infinite resolution system, Direct Form I is numerically equivalent to Direct form II. However, in a finite resolution system (like simulated here), Direct Form I needs to be used for avoiding saturation.

Quote:
Originally Posted by twest820 View Post
What's not clear to me is how the numerator coefficients are calculated.
You used the term "blending". You almost answered the question. Consider the three canonical numerators : HP, BP and LP. The Cookbook formulae for audio EQ biquad filter coefficients from Robert Bristow-Johnson is the classic source. IIR_Lab linearly combines the HP, BP and LP numerators using the weighting factors you manually specify. By specifying 0.0 1.0 0.0 like you did, you know by advance it is the pure bandpass peaking at 0dB. By specifying 1.0 0.0 1.0 you know by advance it is the infinite depth notch. By specifying 1.0 -1.0 1.0 you know by advance it is the pure phase shifter. Up to you to manually specify any other pattern, and IIR_Lab will graph the corresponding 2nd order transfer function (BodePlot), and distorsion spectrum (SpectrumPlot).

Last edited by steph_tsf; 20th May 2012 at 05:31 PM.
  Reply With Quote
Old 20th May 2012, 05:43 PM   #22
diyAudio Member
 
Join Date: Jun 2009
Quote:
Originally Posted by steph_tsf View Post
Use the Triangle Windows and you'll see the change.
I tried that too. From what I can tell triangle lowpasses the noise used for Bode generation. Fewer high frequency errors but doesn't change the low frequency errors. Seems like a less brute force Bode would be helpful.

Quote:
Originally Posted by steph_tsf View Post
IIR_Lab linearly combines the HP, BP and LP numerators using the weighting factors you manually specify
Ah, so it is that simple. Thanks.
  Reply With Quote
Old 20th May 2012, 06:11 PM   #23
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
Quote:
Originally Posted by twest820 View Post
I tried that too. From what I can tell triangle lowpasses the noise used for Bode generation. Fewer high frequency errors but doesn't change the low frequency errors. Seems like a less brute force Bode would be helpful.
Be careful what you say. You need to understand the implications of a non-periodic signal being FFT processed. You also need to understand the uncompromized "what you see is what you get" IIR_Lab purpose.
A bad move would be to compute the BodePlot in an analytical way, only looking at the IIR coefficients. Doing so, you'll get smooth BodePlot curves, but they can't reflect anymore the arithmetic errors introduced by the finite-lenght representation.
For IIR_Lab, the "brute force" BodePlot computing is thus the only way.
There are three ways for improving the BodePlot rendering when dealing with very low frequency IIRs like 40 Hz. One could use a Pink noise as test signal (more energy in the bass), one could do the FFT on more than 65536 samples, and one could apply a more elaborate Windows than the Triangle one.
An more elaborate test signal for the BodePlot would be a pink noise (a good match with the BodePlot log frequency scale) for providing the needed wideband signal, additionned to some bandpass filtered pink noise (for adding energy in any wanted frequency band). The flip side would be that, due to the added complexity, most people would not understand the setup.

Last edited by steph_tsf; 20th May 2012 at 06:35 PM.
  Reply With Quote
Old 20th May 2012, 09:58 PM   #24
diyAudio Member
 
Join Date: Jun 2009
Direct impulse calculation, swept sine, chirp, and structured noise all work too. Music's power spectral density tends to fall in the 1/sqrt(f) to 1/f range so structured f^(-0.75) noise is probably the most realistic default. It would be interesting to compare the results from that to an FFT of the impulse and see if there's a meaningful difference. My guess would be the method's analytic capability will limit on the noise structuring in which case one of the simpler, deterministic methods would be just as informative. One would have to try it and see but, generally, I've found swept sine or direct impulse more useful than MLS.

Another straighforward approach is to filter some real music and calculate the transfer function as the ratio of the FFTs of the input and output.
  Reply With Quote
Old 21st May 2012, 03:06 AM   #25
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
Quote:
Originally Posted by twest820 View Post
Another straighforward approach is to filter some real music and calculate the transfer function as the ratio of the FFTs of the input and output.
Call it hyper brute force when the test signal is a 3 minute song. As generally a song starts with a fade-in and stops with a fade-out, if you manage to do a FFT on the whole song (plus some added silence for meeting the power of two FFT lenght), you meet the periodic criterion so the uncertainty on the FFT result vanishes. In such hyper brute force context, if you continue getting wobbles in the Bode Plot, then for sure you know the IIR filters introduce non linearities do to their finite-lengt binary word representation. You need to compute a FFT on at least 8 million samples. That's still a lot, even nowadays with GHz computers.

In IIR_lab, you get the Spectrum Plot, dedicated to the representation of non-linearities. Spectrum Plot does the job of detecting non-linearities with a moderate length FFT provided you select a SpectrumGen test signal that's synchronized with the sampling frequency.

The Bode Plot is only there to graphically confirm that you have correctly set the IIR coefficients.

In IIR_lab, the Bode Plot shows wobbles in the frequency bands where there are non-linearities caused by the finite-lenght binary word representation, that you should see confirmed on the Spectrum Plot. Therefore, the less the test signal has energy (in the considered frequency bands), the more Bode Plot wobbles.
In IIR_Lab, the Bode Plot also shows wobbles due to the non-periodic nature of the test signal that's used (a White Noise). Using a more advanced Windowing function than the Triangle, one could reduce the wobbles. See how the Bode Plot degrades (huge wobbles) when selecting the Rect. Window. Remember to never draw conclusions basing on the Bode Plot, when the Bode Plot got computed using a Rect. Window.

When you see wobbles in the Bode Plot you need to ask yourself : a) is my BodeGen Signal Level correct (you may have set it to -60 dB in a previous session) - b) am I using the BodeGen Triangle Window - c) am I testing using Double Float - d) is the Spectrum Plot clean ?

Last edited by steph_tsf; 21st May 2012 at 03:11 AM.
  Reply With Quote
Old 21st May 2012, 05:10 AM   #26
diyAudio Member
 
Join Date: Jun 2009
Quote:
Originally Posted by steph_tsf View Post
You need to compute a FFT on at least 8 million samples.
Why? 64k points is 64k points regardless of what the data source is.
  Reply With Quote
Old 21st May 2012, 05:29 AM   #27
diyAudio Member
 
abraxalito's Avatar
 
Join Date: Sep 2007
Location: Hangzhou - Marco Polo's 'most beautiful city'. 700yrs is a long time though...
Blog Entries: 101
Send a message via MSN to abraxalito Send a message via Yahoo to abraxalito Send a message via Skype™ to abraxalito
Because he's talking about taking the FFT of a whole song here, using the fade-in and fade out as a kind of natural windowing function.
__________________
No matter if we meanwhile surrender every value for which we stand, we must strive to cajole the majority into imagining itself on our side - Everett Dean Martin
  Reply With Quote
Old 21st May 2012, 06:36 AM   #28
diyAudio Member
 
Join Date: Jun 2009
The argument seems to be more that the whole song has to be processed for transfer function extraction via FFT comparison to be valid. I'm not seeing how that holds. Certainly, some intelligence is required in selecting input data points from a recording---a bunch of zeros wouldn't be very useful---but that's also a requirement for approaches using random inputs. There's also some excess phase to be removed from the group delay with both approaches.

Personally, the more I think about this the more I'm inclined to run tracks through equivalent filter banks, one implemented with doubles, one with fixed point implementation equivalent to arm_biquad_cascade_df1_q31 / arm_biquad_cas_df1_32x64_q31 (Q1.31 storage, Q1.63 or Q2.62 accumulator), one with an arm_biquad_cascade_df1_fast_q31 equivalent (Q1.31 storage and Q2.30 accumulator) and look at the differences between the output samples. If the differences are underflows after converting back to 24 bit the filter banks can reasonably be said to be functionally equivalent. Back of the envelope it'd take about two hours to perform this measurement on the portion of my music collection I've ripped. So the bottleneck's me getting around to implementing the fixed point code---it's just about summer here, meaning my DIY pace is likely to slow down quite a bit until October.

Last edited by twest820; 21st May 2012 at 06:39 AM.
  Reply With Quote
Old 21st May 2012, 09:00 AM   #29
diyAudio Member
 
steph_tsf's Avatar
 
Join Date: Mar 2008
Quote:
Originally Posted by twest820 View Post
Personally, the more I think about this the more I'm inclined to run tracks through equivalent filter banks, one implemented with doubles, one with fixed point implementation equivalent to arm_biquad_cascade_df1_q31 / arm_biquad_cas_df1_32x64_q31 (Q1.31 storage, Q1.63 or Q2.62 accumulator), one with an arm_biquad_cascade_df1_fast_q31 equivalent (Q1.31 storage and Q2.30 accumulator) and look at the differences between the output samples. If the differences are underflows after converting back to 24 bit the filter banks can reasonably be said to be functionally equivalent. Back of the envelope it'd take about two hours to perform this measurement on the portion of my music collection I've ripped.
While in less than two minutes, IIR_Lab delivers the Spectrum Plot. Provided you are using a synchronous (Fs/N) sinus, the Spectrum Plot graphically and accurately represents all kind of artefacts introduced by the finite-lenght word representation. For determining if an artefact is below the quantization level that's in use, read the Spectrum Plot and remember that 16-bit is -96 dB and 24-bit is -144 dB. The Spectrum Plot enables you to see the artefacts spectral pattern. IIR_Lab thus quickly and scientifically assesses if a given IIR filter is "bit exact" for a given input signal. Using different input signals (always within the Fs/N family), IIR_lab also helps you determine in which domain (frequency - level) a given filter deviates from remaining "bit exact". The operation speed of IIR_lab enables working interactively in a trial and error way for developing your engineering skills. Once you get confident about a given filter, having assessed it on IIR_Lab, nothing prevents you applying some hyper brute force as "real world" check : your two hours measurement using a full music track.

Last edited by steph_tsf; 21st May 2012 at 09:28 AM.
  Reply With Quote
Old 21st May 2012, 07:54 PM   #30
diyAudio Member
 
Join Date: Jun 2009
THD and IMD are measurements of the same underlying phenomena and hence are usually strongly correlated. I tend to prefer multitone IMD as it's a bit more thorough, though---synchronous sines are a subset of a THD sweep. As pointed out earlier there's no requirement to take the measurement at scale; 64k points is 64k points. But, having gotten the code together, there's no particular reason not to let the computer run whilst one goes to the pub.
  Reply With Quote

Reply


Hide this!Advertise here!
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
great digital filters? audiophail Digital Line Level 1 20th December 2010 04:35 PM
Any new digital filters ? percy Digital Source 17 20th July 2008 12:39 AM
Why do manufacturers use crappy digital filters? John007 Digital Source 23 7th May 2008 06:54 AM
Convolving digital filters? birkinshawc Digital Source 4 1st April 2005 02:17 AM
do digital filters also affect the phse of a signal? weissi Digital Source 4 20th April 2003 01:32 AM


New To Site? Need Help?

All times are GMT. The time now is 01:36 AM.


vBulletin Optimisation provided by vB Optimise (Pro) - vBulletin Mods & Addons Copyright © 2014 DragonByte Technologies Ltd.
Copyright Đ1999-2014 diyAudio

Content Relevant URLs by vBSEO 3.3.2