Re:Digital sound processing tutorial
by willis936 on Tuesday November 10, 2020 @09:07AM
(#25046039)
This is off topic but I’m assuming difficult-to-gather DSP peers will be in this comments section.
I have run into the limit of double precision floating point when making high order (20+) IIR filters in MATLAB. My solution in the past has been FIR filters and waiting a long time. I recently experimented with alternative forms of IIR representation. I found that converting from transfer function (B,A) to zero-pole-gain (z,p,k) form, then to second order sections (sos,g) form, then using the MATLAB filter function, the issues with double floating point precision go away in my use cases.
Is this a well known trick that I just stumbled upon?
Re:Digital sound processing tutorial
by colanderman on Tuesday November 10, 2020 @10:28AM
(#25046992)
Yes, second-order/biquad sections are less sensitive to coefficient quantization than high-order filters. I think they benefit from interleaving zero+pole stages as well.
You can even ask MATLAB to generate the (z,p,k) form directly rather than (b,a) form when using its filter-design functions, saving a step (just ask for a three-argument result instead of a two-argument result).
(I am not an expert but I just so happened to have run across this feature and explanation last week, after vaguely remembering from college that biquad sections are "better" for some reason.)
High-order polynomials are very sensitive to small deltas in the coefficients of their high-order terms. Representing the same function as the product of low-order factors is much more stable numerically.
Re:Digital sound processing tutorial
by mikewarot on Tuesday November 10, 2020 @06:01PM
(#25053253)
I'm no DSP expert, but I did run into a problem in GNU Radio which I think applies because it happens to floating point numbers in general.
GNU radio has a component called "DC Block" which has a length of N samples... it averages those samples, and subtracts that average from the input... giving an output.
If you exceed the dynamic range of floating point by mixing inputs of lets say 1e12 and 1e-12... the filter can develop a permanent output bias.
The reason is performance... the samples are stored in a ring buffer, and they subtract the value when it leaves the buffer, and add the new value as it goes it. This is N times faster than adding up all the values, and subtracting. However... this bug can happen.
I suspect you have similar behavior occurring due to the smaller coefficients at the tails of the function.
That's my 2cents, I hope it made sense, and helps explain what you've encountered.
Re:Digital sound processing tutorial
by willis936 on Tuesday November 10, 2020 @10:44PM
(#25055295)
Yeah it’s definitely a FP dynamic range issue. Moving to extended point is impractical for a great many reasons. Transfer function form IIRs put high demands on FP dynamic range that other forms do not. This has real world parallels too, since the most basic way to realize an analog filter is with the transfer function method. I don’t know of anyone who makes a 2 F capacitor with tolerances that are within 2 pF.
Re:Digital sound processing tutorial
by W0lf on Tuesday November 10, 2020 @07:00AM
(#25044995)
I did develop a proof-of-concept for a client recently which involved some digital sound processing on mobile devices and used this[1] book as a reference to refresh some (advanced) basics again. Can recommend this to anybody who is interested in digital signal processing as I really liked the style and density in this book
[1] Discrete-Time Signal Processing: Pearson New International Edition
Re:Digital sound processing tutorial
by crshults on Tuesday November 10, 2020 @10:01AM
(#25046697)
Crazy. I was just shopping for this book last night but got hung up on different editions. This one[1] also claims to be the 3rd Edition but looks to have an early publish date. I guess go with whatever's newest?
[1] Discrete-Time Signal Processing (Prentice-Hall Signal Processing Series) 3rd Edition
Re:Digital sound processing tutorial
by mikewarot on Tuesday November 10, 2020 @06:08PM
(#25053318)
If you're interested in this topic, and want to play. I highly recommend GNU Radio. It lets you build flowcharts that can actually do I/O with your soundcard, as well as File I/O, etc.
I have run into the limit of double precision floating point when making high order (20+) IIR filters in MATLAB. My solution in the past has been FIR filters and waiting a long time. I recently experimented with alternative forms of IIR representation. I found that converting from transfer function (B,A) to zero-pole-gain (z,p,k) form, then to second order sections (sos,g) form, then using the MATLAB filter function, the issues with double floating point precision go away in my use cases.
Is this a well known trick that I just stumbled upon?
You can even ask MATLAB to generate the (z,p,k) form directly rather than (b,a) form when using its filter-design functions, saving a step (just ask for a three-argument result instead of a two-argument result).
(I am not an expert but I just so happened to have run across this feature and explanation last week, after vaguely remembering from college that biquad sections are "better" for some reason.)
High-order polynomials are very sensitive to small deltas in the coefficients of their high-order terms. Representing the same function as the product of low-order factors is much more stable numerically.
GNU radio has a component called "DC Block" which has a length of N samples... it averages those samples, and subtracts that average from the input... giving an output.
If you exceed the dynamic range of floating point by mixing inputs of lets say 1e12 and 1e-12... the filter can develop a permanent output bias.
The reason is performance... the samples are stored in a ring buffer, and they subtract the value when it leaves the buffer, and add the new value as it goes it. This is N times faster than adding up all the values, and subtracting. However... this bug can happen.
I suspect you have similar behavior occurring due to the smaller coefficients at the tails of the function.
That's my 2cents, I hope it made sense, and helps explain what you've encountered.
[1] Discrete-Time Signal Processing: Pearson New International Edition
[1] Discrete-Time Signal Processing (Prentice-Hall Signal Processing Series) 3rd Edition
https://github.com/lv2/lv2/wiki
Epic!