DSPRelated.com
Forums

Linear phase vs Min. Phase

Started by Max October 18, 2014
>Would you mind elaborating on that? When you refer to a 'numeric >solver' for dealing with this, are there examples or apps that you can >point to?
Hi, I've got an example here that solves a FIR filter via fminsearch / fminunc in Matlab / Octave (Matlab is twice as fast, Octave is free). http://www.dsprelated.com/showarticle/180.php There are two cases in the code, the "frequency-masking" filter, and a reference FIR. Use the latter as a starting point. I suggest you simply keep the group delay target of the symmetric FIR but change to asymmetric coefficients and then skip the leading ones. You'll probably have to implement your own objective function at some point, that's where most of the work goes. An alternative solver for IIRs is here: https://drive.google.com/file/d/0B1gLUU8hXL7vN0ZQZHFjUlo3VG8/view?usp=sharing Conceptually, IIR offers no advantage over FIR if the number of coefficients is unlimited: I could simply sample the IIR impulse response into an FIR filter. I'd use FIR first to investigate what can be achieved. They are easier to optimize because of guaranteed stability. Then there is Julius O. Smith's "invfreqz": http://www.dsprelated.com/showarticle/110.php A good reference is Mathias Lang's Dissertation: http://www.nt.tuwien.ac.at/fileadmin/users/gerhard/diss_Lang.pdf There is a zip file with the code somewhere on the web, I think I found it once by searching for some lines of code from the appendix. Now all those are examples of similar numeric solvers, but none does exactly what you want. I'd start with fminunc(), try to formulate some meaningful objective function (for example split the vector error into amplitude and phase error, and apply different weighting). An optimal result isn't necessarily the best that can be done - this may sound weird, but more often than not it's impossible to nail down all angles of the problem in the objective function. What's usually needed is some common sense and iteration and "cooking". _____________________________ Posted through www.DSPRelated.com
On Thu, 23 Oct 2014 14:31:11 -0500, "mnentwig" <24789@dsprelated>
wrote:

>>Would you mind elaborating on that? When you refer to a 'numeric >>solver' for dealing with this, are there examples or apps that you can >>point to? > >Hi, > >I've got an example here that solves a FIR filter via fminsearch / fminunc >in Matlab / Octave (Matlab is twice as fast, Octave is free). >http://www.dsprelated.com/showarticle/180.php > >There are two cases in the code, the "frequency-masking" filter, and a >reference FIR. Use the latter as a starting point. >I suggest you simply keep the group delay target of the symmetric FIR but >change to asymmetric coefficients and then skip the leading ones.
Wow, terrific feedback! Thanks, mn. I've logged this for later study (as well as the previous replies...appreciated).
>Now all those are examples of similar numeric solvers, but none does >exactly what you want. I'd start with fminunc(), try to formulate some >meaningful objective function (for example split the vector error into >amplitude and phase error, and apply different weighting).
Not sure if I get you comment about skipping leading coefficients, or the paragraph above re splitting the vector error. Are these covered in any books that you know of?
>An optimal result isn't necessarily the best that can be done - this may >sound weird, but more often than not it's impossible to nail down all >angles of the problem in the objective function. > >What's usually needed is some common sense and iteration and "cooking".
I'm starting to get a better understanding of the problem. Some misdirection here and there on the web, but after seeing a lot of various opinions on how to handle the problem, it's a bit more clear. This is a beyond the typical pre-cooked filter recipes that I've seen, so I'll have to learn how to generate coefficients without screwing anything up too badly. It would be nice to find a couple books that treat this subject in depth, along with Matlab code (or C, C++). If anyone has a suggestions, please feel free.
On Thu, 23 Oct 2014 12:37:40 GMT, N0Spam@daqarta.com (Bob
Masta) wrote:

>On Wed, 22 Oct 2014 19:18:35 -0400, Max <Max@sorrynope.com> >wrote: > >>On Wed, 22 Oct 2014 12:22:47 GMT, N0Spam@daqarta.com (Bob Masta) >>wrote: >> >>>On Wed, 22 Oct 2014 08:06:27 -0400, Max <Max@sorrynope.com> >>>wrote: >> >>>>Hi Bob, >>>> >>>>Actually I was speaking about filters in general, but I'm interested >>>>in how this is avoided in anti-aliasing filters. I assumed that the >>>>anti-aliasing filter would exhibit the same behavior as the mid-band >>>>filters in those sound samples, albeit for shorter duration due to the >>>>rolloff frequency. Is that not correct? >>> >>>Since the cutoff frequency for an anti-aliasing filter is >>>above the audible range (for most folks anyway, and probably >>>*especially* for those involved in the music scene due to >>>cumulative loud exposures), the "ring" at the cutoff is >>>inaudible. Nobody (even a young kid) is very sensitive in >>>this range compared to the normal speech/music range, and >>>the Gibbs phenomenon (the pre/post ring) is only about 9% of >>>the total... about 15 dB below the fundamental of a square >>>wave. Since you only see the Gibbs effect on transients, >>>and since transients have lots of harmonics, you can't >>>detect this tiny added amount against the wall of harmonics >>>(even if you are a young kid who still has hair cells in the >>>20 kHz range). >> >>Hi Bob, >> >>Here's my own impression from what I've read so far, and from those >>audio mid-band samples: There is a pre-echo that spans many sample >>intervals. This would seem logical given the number of filter >>elements in front of the center/peak in a linear phase filter. Given >>that humans spacial perception involves left-right phase differences >>of around 10 microseconds, the CD sampling rate is already on the >>edge. But given that the 'phase smear' extends over multiple samples, >>that would be a significant time interval even at 44.1khz. That is >>apparently why filter designers have started using minimal phase >>filters for pro audio apps. FabFilter and others have Youtube video >>docs on the subject. But of course minimal phase has separate >>disadvantages. >> >>You're the DSP engineer, so there's a significant chance that I am >>overlooking something. :-) I'm still researching the replies posted >>here (thanks to all!), but I wanted to make sure I'm on the right >>track before this thread goes too stale. > >First off, I don't think it's fair to compare audio >equalization filters (whith cutoffs in the middle of the >audible spectrum) with anti-aliasing filters having >band-limit cutoffs.. > >Second, I haven't looked at (hardware-type) scope responses >of those mid-band equalizers to actually see what "before" >and "after" look like. However, I have shown you a scope >response of a typical anti-aliased square wave. Note that >there is nothing you could call a "pre-echo"; the "ring" >starts right at the rising (or falling) edge, exactly at the >time it would be least audible due to masking. > >So whatever the equalizer guys are doing, it's not >equivalent to anti-aliasing at all if there is anything like >a pre-echo (a transient that appears before the original >transient). Off the top of my head, I can't guess how you >would create a pre-echo with an FIR-type structure... it >seems like you'd need a separate delay just for the "pre", >not a simple sum of all taps as in a conventional FIR. But >then it's not something I've given a great deal of thought >to!
Oops... post in haste, repent at leisure! I realized (many hours later) that the "pre-echo" you were hearing in the linked samples was undoubtedly the rising-amplitude "reverse ring" that precedes the transient edge, not a separate transient event like the pre-echo from magnetic tape or phonograph records that others have mentioned here. So yeah, this is exactly as expected from an ordinary FIR filter. I still don't think this is any cause for concern in anti-aliasing applications. The ear is pretty insensitive to absolute phase; as you mention, it's only between-ear phase *difference* that we can detect well. That detection depends upon detecting the waveform in question (sorta), so the mechanism is pretty unlikely at 20+ kHz. The "sorta" is because the sensory cells (inner hair cells) can only fire at a few hundred Hz max, so there is no way they can actually track the waveform at high frequencies (or even moderately high frequencies). But the process of firing is sorta like charging up a capacitor to reach some trigger voltage, and in this case the charging waveform (current of potassium ions, modulated by the motion of stereocilia at the tops of the cells) has an AC component. So when the charge is nearly at threshold, a little nudge from the peak of the AC will take it over the limit. The upshot is that statistically the cell is more likely to fire on waveform peaks than valleys. The difference in firing patterns between the same-frequency receptors for the two ears can be detected by fairly simple neural circuits. That's on nice clean (and plainly audible) pure-tone test signals. Dunno how high the test frequencies have been, but I imagine 20 kHz would be a bear to test. (Doing anything with sound at these frequencies is a bear, due to reflections and standing waves, both in the test apparatus and measurement mic, and the ear canal itself.) So in the first place I'd be very skeptical of any experiment that claimed this sort of phase difference detection when the claimed frequency is only a small part of a much louder waveform that doesn't have a phase difference. But more to the point, with anti-aliasing you aren't creating a phase difference; the same Gibbs phenomenon goes on in both channels in exactly the same way. (At least with modern DSP methods, as opposed to old analog filters.) I can't see how these can cause a problem. Best regards, Bob Masta DAQARTA v7.60 Data AcQuisition And Real-Time Analysis www.daqarta.com Scope, Spectrum, Spectrogram, Sound Level Meter Frequency Counter, Pitch Track, Pitch-to-MIDI FREE Signal Generator, DaqMusiq generator Science with your sound card!
On 10/24/14 8:51 AM, Bob Masta wrote:
> On Thu, 23 Oct 2014 12:37:40 GMT, N0Spam@daqarta.com (Bob > Masta) wrote: >
...
>> >> So whatever the equalizer guys are doing, it's not >> equivalent to anti-aliasing at all if there is anything like >> a pre-echo (a transient that appears before the original >> transient). Off the top of my head, I can't guess how you >> would create a pre-echo with an FIR-type structure... it >> seems like you'd need a separate delay just for the "pre", >> not a simple sum of all taps as in a conventional FIR. But >> then it's not something I've given a great deal of thought >> to! > > Oops... post in haste, repent at leisure! I realized (many > hours later) that the "pre-echo" you were hearing in the > linked samples was undoubtedly the rising-amplitude "reverse > ring" that precedes the transient edge, not a separate > transient event like the pre-echo from magnetic tape or > phonograph records that others have mentioned here. So > yeah, this is exactly as expected from an ordinary FIR > filter.
pay attention, Max. i already outlined the mathematical source to this pre-echo. since the Fourier Transform is invertable or one-to-one, it's the *only* reason for it (i.e. you can map that pre-echo in the time domain back to ripples in the passband in the frequency domain). -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."