Saturday, 23 December 2017

HOWTO / MUSINGS: Playing with Digital Filtering - Impulse Responses and Frequency Effects resembling Chord, Old-Skool Meridian, MQA, NOS...

Remember folks... With anti-imaging filtering applied to digital playback, there are no gross "stairsteps" in the oversampled/upsampled analogue output. Regardless of what you might see from misleading audio ads trying to pigeon-hole "digital". The exception being non-oversampling DACs that specifically choose to go down the stair-step path.

As you may know, I've been using a Raspberry Pi streamer with LMS over the last year for most of my listening. As described in that Pi "HOWTO" article, I've been using the piCorePlayer software to stream.

One of the nice features of piCorePlayer is that it allows easy control of upsampling by using SoX; in the "Advanced" settings is the ability to pass along instructions to control the digital filtering used. Combined with a good DAC that accepts high sample rate PCM, we can try listening for ourselves and gain an appreciation of the differences that digital filtering make. The cool part of this is that it allows us to "emulate" the kinds of filters used in the audiophile world.

In this post, let's play with some of the parameters and show the kinds of impulse responses and "digital filter composite" graphs we can achieve...

As per the post last week on Bluetooth, I mentioned that I used to have the Oppo Sonica DAC until recently. The demonstration in this post actually used the Sonica DAC to grab some impulse responses and frequency spectrum results while playing with piCorePlayer a few months back. One of the nice features of the Sonica DAC and some other modern devices is the capability of USB input at 24-bit/768kHz! Seriously, we're never going to be buying "high-resolution" files at 768kHz (heck, I don't even see value in 176.4/192kHz). The only "value" therefore of this feature is for the purpose of running our own upsampling like what we'll be exploring today or with commercial offerings like Signalyst's HQPlayer. At such high sampling rates, the device's own upsampling digital filter will be bypassed.

Remember, you can just as well upsample to 176.4/192kHz or 352.8/384kHz with many if not most DACs these days to experiment with filter settings.

Here ya go. Sonica DAC upsampling to 768kHz.
Upsampling is quite easy with piCorePlayer. You just make sure the bottom "Advanced" tab is selected and go into "Squeezelite Settings" where you can set the "Max sample rate" and "Upsample setting" parameters.

So, let's get at this and play with a few parameters and show what the output looks like!

1. Linear phase sharp "brick wall" filter... "Chord-like" impulse response.

First, let's have a look at a technically ruler flat filter. About the best anti-imaging filter you're ever going to see. Because this baby is linear phase, there is no phase shift across the spectrum which generally is a good thing that reduces temporal smearing.


A quick primer on the "Upsampling setting" parameters. The "recipe" goes like this as per the piCorePlayer "more" button:
  • recipe = (v|h|m|l|q)(L|I|M)(s) [E|X]
    • E = exception - resample only if native rate not supported
    • X = async - resample to max rate for device, otherwise to max sync rate
  • flags = num in hex
  • attenuation = attenuation in dB to apply (default is -1db if not explicitly set)
  • precision = number of bits precision (HQ = 20. VHQ = 28)
  • passband_end = number in percent (0dB pt. bandwidth to preserve. nyquist = 100%)
  • stopband_start = number in percent (Aliasing/imaging control. > passband_end)
  • phase_response = 0-100 (0 = minimum / 50 = linear / 100 = maximum)
So, what I'm doing with "vX::4:28:99:100:50" is that we're telling SoX to resample at very high quality "v", asynchronously "X" (everything gets converted to highest 768kHz even if non-multiples), attenuate by -4dB (protects from intersample overload), using 28-bits precision (more than enough), passband ends at 99% which is 21.8kHz audio for standard 44.1kHz samplerate, and stopband at 100% or 22.05kHz for 44.1kHz samplerate audio. This of course makes for a very sharp filter with very narrow transition band. "50" for phase response is a linear phase filter where there are no phase shifts across the spectrum.

Using the Juergen Reis inspired "Digital Filter Composite" (DFC) graph, it looks like this coming out of the Sonica DAC:


Note the small amount of harmonic distortion as a result of hardware limitations. Remember, this is an actual measurement from the DAC using my Focusrite Forte ADC so it's not a representation of the "perfect" digital data itself; rather real-life output.

And check out the impulse response - beautiful :-) !
Click on image to zoom in and have a look...
As I noted in the section header, this is "Chord-like" in the impulse response (have a look at Stereophile's DAVE measurements). You can see that the DFC is very similar to those Stereophile measurements as well showing a very steep filter at Nyquist; that proverbial "brick wall".

By the way, if you're interested in hearing more about Rob Watts' WTA Chord filter, check this out (CanJam RMAF 2017):



Check out particularly from 14:15 onward where he talks about tap length, temporal reconstruction, etc... Hmmm, while I agree that we typically don't have to worry about ringing, to claim that going from a long 26,000 to 164,000 to 1,000,000 tap filters result in significant improvements each time (~23:30 onwards, 25:30 for 1M taps) obviously is suspicious since biology doesn't work like this - qualitative plateau with diminishing returns is the rule. Let's also not forget that a large number of taps adds to latency which may or may not be significant (depending on samplerate) and will waste more processing power for likely no ultimate gain. I'm sure big numbers help sell the next generation of products though...

Coming back to our filter setting above, the price to pay for this long filter is a bit more CPU cycles as expected. With the Raspberry Pi 3, doing this uses ~25% of processor cycles for 768kHz upsampled output - no big deal even for a low power machine.

2. Linear phase sharp but less steep filter... "Typical" DAC settings.

"vX::4:28:70:110:50"
Okay, this one is typical for many good DACs with "sharp" linear phase filters. Basically, it's just a wider transition band compared to the "brick wall" of the setting above. Passband end is set to 70% or 15.4kHz (44.1kHz samplerate), and the stopband starts at 110% or 24kHz which allows potentially some mild ultrasonic imaging to pass.  Note that because we're still doing this in high-precision software with -4dB attenuation to prevent intersample overflows, the quality remains excellent and surpasses that of essentially all off-the-shelf DAC chips I've seen.


As expected then, the impulse response isn't as long in duration as the "brick wall" above:

3. Minimum phase sharp filter... "Old-Skool Meridian"-like.

Remember back in 2009, Meridian came out with their 808.2 devices basically featuring minimum phase filters. Seemed cool back then; this idea of fancy mysterious filtering and all.

Here's something similar to try:
"vX::4:28:75:120:0"
No big deal. Just a 75%/120% minimum phase filter. In fact, the original Meridian filter was steeper and had a longer impulse response. And at 120% "stopband start", I'm allowing aliasing to creep in which can be easily seen with the 19 & 20kHz sine tone.


Here's what the impulse response looks like:


Classic minimum phase without that "pre-ringing". Remember the "price" to pay for this kind of behaviour - a phase shift:

Comparison of SoX linear vs. minimum phase response.

The image above is a demonstration of the variation in phase across the frequency spectrum when we use minimum phase antialiasing filters. Unfortunately RightMark messes up the Y axis which should correspond to the degree of the phase shift.

Thankfully, humans are not very good at detecting phase anomalies (check out this excellent Audioholics research article from back in 2005). Remember that minimum phase filters have been in use in Apple products like iPhones and iPads for ages (but not the classic iPods though)!


4. Minimum phase, very slow roll off, highly aliasing filter - "MQA-like".

Ahhh, so you want to try something that looks/sounds like MQA's filtering? Give this one a try:

"vX::4:28:30:200:0"
30%/200% minimum phase filter. It lets all kinds of aliasing to creep through. For example, you can easily see the second order harmonic for the 19 & 20kHz tone featuring very prominently in the DFC spectrum; potentially inducing all kinds of nonlinear distortions like intermodulation through your speakers during playback. You can compare this to Stereophile's measurement of the Mytek Brooklyn (Figure 6) showing that the MQA filter actually overloads quite substantially with their 0dBFS 19.1kHz tone - not an issue here though because of that -4dB attenuation to provide overhead.


And here's the MQA-like impulse response (the filter is actually a little steeper than what the MQA folks use even!):


I see that others are using "vM::1:28:25:180:0" settings here that may be even closer... But at the end of the day, let's face it, this is simply a very weak antialiasing filter setting.

Since this is a minimum phase filter, it will also have a non-flat phase response graph similar to (3) above but because of the extremely slow roll-off, not nearly as remarkable.

Remember that phase is related to timing and a non-linear phase thus represents variation in temporal delay in the frequency spectrum. So when MQA talks about achieving some kind of temporal "debluring" or reducing "smearing", it's hard to understand what exactly is meant by this claim and how this is supposed to be implemented if the filter selection itself tends toward a non-flat phase response.

Addendum: Remember that over the years there have been other DACs that use slow roll-off filters but are linear. A "classic" is the Wadia 121 "Decoding Computer" with the look of the old "DigiMaster" interpolation algorithm which came out at a time when computational power was limited. You can recreate a similar filter with:
"vX::4:28:30:200:50"
Basically just use the phase parameter of "50" for linear phase.

5. The "Ultralax" NOS-like Filter

Finally, suppose you say "the hell with antialiasing and frequency side effects!", here's one you can try:
"q"
That friends is simply a setting using SoX's "quick" cubic interpolation with little regard for trying to actually perform anti-image filtering. It takes essentially no CPU power to perform but obviously this is far from ideal in terms of "accuracy"!

First check out the severe frequency anomalies with this filter:




Notice all the ultrasonic imaging artifacts. Just as important is the slow roll-off characteristic within the audible spectrum. In fact, if I just run a 16/44 test signal through this filter, the frequency response looks like this:


Behold, the "nice" looking impulse response responsible for all this frequency anomaly:


In the original version of this article, RightMark choked on the phase measurement with this filter setting. I have since checked with REW and we can see that in fact the phase is flat, remaining at 0°. Here's a comparison with minimum phase showing the shift found in minimum phase settings. Notice that the polarity of the degrees in this graph is opposite of the RightMark graph.
 

While not exactly the same, many of the characteristics described for this "ultralax" (SoX quick interpolation) filter are the same as non-oversampling (NOS) DACs. By not performing proper antialiasing/anti-imaging, the frequency anomalies will look like the above, and there will be a slow roll-off frequency response. As you know, there are some companies like Audio Note that sell very expensive non-oversampling devices (and even proudly call it "1x oversampling"!). Not my cup of tea - IMO NOS DACs are not "high fidelity" devices even if some pay big money as "high end" products.

So... How do these filters sound?

Why don't you have a try and listen for yourself. The cost of admission to build a little Raspberry Pi 3 streamer to connect to a good USB DAC capable of high sample rates is really cheap. Alternatively, you can simply try out some of these settings on a standard PC with SoX (here is the command line flags cheat sheet).

The point is that there's no magic to digital filters and impulse responses. And as I discussed a year back about "ringing" and digital antialiasing filters, remember to not just look at these impulse response graphs and freak out or jump to unnecessarily positive conclusions just because something looks like it doesn't "pre-ring" and has a short duration (the "Ultralax" setting above has a cute looking impulse response, right?)!

Remember that an impulse is an "illegal", non-bandwidth limited test signal that would not exist in nature nor in decent PCM recordings (alas, there are non-decent recordings out in the wild). I would love to have someone show me a favoured audiophile recording where ringing can be an issue on playback! Remember to ask to see the frequency-domain graphs as well (ie. those "DFC"-type plots) so one can appreciate the potential antialiasing limitations when it's being suggested to you that a certain impulse response is desirable. Furthermore, many slow roll-off filters that minimize ringing can act as a type of "tone control" that dulls the high-frequencies (PonoPlayer for example).

For completeness, even though I do not believe ringing is an issue with these antialiasing filters, I must note that this doesn't mean ringing from a linear phase DSP would not be audible in some circumstances with strong transients (eg. snare drum attack). For example, see and listen to this demonstration for what potent ringing sounds like using an extremely high "Q" factor in a low shelf EQ filter when frequencies are being manipulated. An antialiasing playback filter is not manipulating frequencies like this.

-----------------------

From this month, Stereophile has started to publish a series on MQA by Jim Austin with the first article here. As you can see, the article simply shows impulse responses of a few DACs and compares it to MQA. No side-by-side comparison of frequency / aliasing effects. I think it's disingenuous (if not even dishonest) to not show frequency-domain performance as if it doesn't matter (this is part of the MQA MO and claims that they somehow have achieved time-domain mastery from recording to playback, LOL)!

Austin says that "MQA's approach may improve the shape of the impulse response". Hmmm, based on the filter examples I've shown above, all that "shape" means is that they don't have any issues with introducing phase anomalies (a side effect of minimum phase filtering) and they don't care about aliasing (a side effect of MQA's very short, slow roll-off)! Furthermore, as we can see with the Mytek Brooklyn measurements (back in October 2016), the MQA filtering itself is prone to intersample overloading.

I find the tone of the article quite disturbing. There's seemingly the implication that we can look at an impulse response graph, and somehow assume that this is "good". MQA and Stereophile seem to want to "sell" this image of the impulse response as indicative of fidelity which is simply not based in reality! Is it any wonder the negative comments to this article based on technical grounds?

I seriously hope that Stereophile digs deeper for the upcoming parts of their MQA series. Jim Austin states "I hope to find a way to demonstrate and test deblurring - how MQA handles imperfect files - for a future article". Yes, please do that.

I hope that Mr. Austin can truly keep an open mind and report honestly with full journalistic freedom; recognizing that perhaps what he uncovers could suggest that MQA is not in the best interest of audiophiles seeking highest sound quality. Surely there must be some "cons" to all the apparent "pros" reported about MQA in the mainstream audiophile media, right, Jim?


-------------------------

I see that Rocky Mountain Audio Fest 2017 has now uploaded a bunch of the seminar videos. Probably the most interesting talk is this one given by Bob Carver (check out 24:45 - Stereophile with Peter Aczel "The Carver Challenge" and accuracy, philosophical comment about "facsimile" reproduction, measured transfer functions, and voicing):



Holiday time for Christmas and New Years. Here's hoping peace, joy, and a wonderful 2018 to you and yours...

Enjoy the music and hope you're having fun with the hobby!

28 comments:

  1. Merry Christmas and Happy New Year to you! Thank you for the consistently interesting, useful, and grounding musings, and looking forward to more in 2018.

    Re: 1M taps discussion, if you happen to be visiting San Diego at some point, please drop a note. Having just received my Chord Blu2, it is one of the most transformational music experiences I've had. There seems to be some sort of cognitive phase transition at work, where the Blu2 pushes most (but not all) recordings to that other side of it. Fascinating experience, but also a fragile one (doesn't take much to push to the "normal" side of that phase transition). I'm delightfully chasing down this effect and trying to understand it.

    ReplyDelete
    Replies
    1. Merry Christmas Ray.

      Awesome DAC man. No doubt Chord has pushed the processing envelope with this device!

      Sure, will certainly send you a note if I'm down at SD :). In the meantime I'll keep a lookout for one of these DACs locally to have a listen myself!

      Delete
  2. Nice write up! AKM's very popular AK4490 has sharp and slow filters, and an additional one called 'Super Slow', which is not described in detail in it's data sheet. You can read about it in RME's manual for the ADI-2 Pro (I think I gave a link earlier). This filter seems to be an oversampling filter running on a lower frequency as usual, it is not real NOS, but something in-between. A DSO shows stair steps as output signal, but it seems less than a real R2R converter would produce. IMHO this filter can not be reproduced with your solution. Just saying, the filter is fun to realize that you can't hear any difference from the impulse response, but just from the damping in treble :)

    ReplyDelete
    Replies
    1. Hey there Techland,

      Yep. SoX is versatile but there are limitations to the kinds of filter / impulse shaping it can do. No question that it's very powerful though and I think within it's algorithms, I can find one that suites my tastes :-). Will probably talk more about this next week as I've been playing with settings over the last >1 month...

      Delete
    2. Sox itself can apply any FIR filter using the "fir" effect. This might not be available through that GUI, though.

      Delete
    3. Thanks for the reminder Mans!

      Will have to play more with this in the new year :-).

      Delete
  3. Thanks for another great article, and so well timed! Just a few more hours before I see if Santa grants me my wish: a Raspi3+touchdisplay+miniDSP U-DAC8 so I can apply room correction filters on individual speaker drivers. I will definitely play around with your upsampling filters to see what I can hear.
    FYI an interesting thread by another crazy Canuck suggesting most DACs are good enough: www.diyaudio.com/forums/digital-line-level/314762-dac-blind-test-audible-difference-whatsoever.html
    Still, I'd love to see you test the MSB Select II DAC ;-]

    ReplyDelete
    Replies
    1. Thanks Edika for the note and link,
      Well, with cold temperatures outside, either we're out skiing/boarding/snowshoeing or indoors tweaking :-).

      "I sense a disturbance in the Audiophile Force". :-)

      As usual, blind testing is tricky business here in the world of audiophilia with 1000x difference between DAC prices and whatnot. We just have to stay reasonably rational and not get too hyped up about claims but at the same time have fun with the "non-utilitarian" aspects of the toys we buy...

      Have a great time with your new gear!

      Delete
  4. Does the first filter video suggest that sharp FIR filter's ringing is currently not considered that bad, e.g. it is better to have steeper filter with more taps rather than "relaxed" one?

    ReplyDelete
    Replies
    1. Hi Honza,
      Yes. Filter ringing IMO was never a significant problem with properly lowpassed music - which is essentially any decent recording with good sound quality.

      Delete
  5. I have been experimenting with FIR filters and while the standard passband of 91 or 92 at 44.1 kHz sample rate sounds good, I also tried passband 97 and the results are subjectively pleasant (I would not probably experiment with supersteep passbands like 99). I didi not use aliasing in my experiments although in the past I also used it, now I usually upsample without any alias for my Schiit Modi 2 Uber. If today's knowledge says that steeper filters with more taps do not pose a danger to sound quality or fatigue of ears from ringing, then I may consider moving to 97 passband ...

    ReplyDelete
    Replies
    1. Honza,
      Give it a try at 97!

      Personally I use 95 with my Raspberry Pi 3 streamer... I will speak more about some personal preferences and show my rationale next time.

      Delete
    2. Hello Archimago,

      thanks for reply. I also have read Rob Watts' discussion thread here. https://www.head-fi.org/threads/watts-up.800264/ Sounds interesting, for example his opinion on aliasing seems consistent with my experience that it can colorize the sound "nicely" but makes it different to the original.
      As for the tap length, Rob Watts says that it has big significance with his WTA filter. But from what he wrote and argues it is clear that having more taps even with conventional filters can make the interpolation filter work better to some extent. Based on this argumentation I changed a little my position on filtering, and this is also consistent with my experience that in the past I tried to use less steep filters with e.g. 48 kHz (from 20-24 kHz) and the results were not subjectively that good. On the other hand I am not convinced now that supersteep filters with normal resamplers like SoX or Resampler (BTW great offline resampling software https://github.com/jniemann66/ReSampler/releases/tag/v1.3.6 ) do not have some side effects. And yes I agree with Rob's opinion that theh filtering quality is most important when playing back 44.1 sample rate becuase theoretical inaccuracies can be more prominent.
      Nice to know that you use 95 now (probably without aliasing?).
      I will probably try 97 in following weeks (the effects are more prominent with longer listening). So far it seems promising, but based on my experience from the past I try to be careful with
      judging.

      Delete
    3. Hi Honza,
      Yeah, I'll show you what I use and why with my next post in the next few days :-). Just putting together some diagrams and such!

      Delete
    4. It always amazes me the influence that filtering type has on playback. I have found out some nice sounding options like passband 91,92,95, --steepLPF (95.45 in Resampler) or 97.8 (steep but nice sound). But it is very hard to discern among them (probably not ABXable under common conditions) and their performance also depends on the DAC that is used for further interpolation.

      Delete
    5. BTW, also for Foobar/SoX combination, 97.5 passband (with no aliasing) sounds nice.

      Delete
    6. And to add up, new version of Resampler has been released today

      https://github.com/jniemann66/ReSampler/releases/tag/v2.0.2

      Some nice sounding options:
      --lpf-cutoff 95.2
      --steepLPF
      --lpf-cutoff 92 --lpf-transition 9 (similar to an article that has been here some years ago)
      --lpf-cutoff 97.8

      of course depends on playback chain and personal preference. As I said there is probably no single recommendation, differences are very subtle (if perceivable), and to tell whether one setting works well on a particular scenario/playback chain takes long listening.

      Delete
  6. Just to add one more thought - based on the thread I cited I will probably also try 98 passband, so that I can evaluate whether further increasing number of taps has any effect with normal resampler like SoX or Resampler. Of course the differences may be very small or inaudible - this can happen, because even Rob Watts says that the increasing number of taps has significance maily with the WTA filter and with other filters it may not help (much). Therefore, at the same time I remain "healthy sceptical" to ultrasteep filters 99 and above, however the idea that ringing evaluation is actually based on incorrect signal makes new possibilities to be available for trying.

    ReplyDelete
  7. I have been experimenting and thinking further and it seems to me that - as usual - the number of taps and the length of the filter is only one (albeit important) thing. So we cannot simply say the more taps the better, overall design of the filter matters. It is not sure how SoX or Resampler handle more taps or better say if it is that effective for reconstruction. I asked in the thread here more experienced members of the forum https://www.head-fi.org/threads/watts-up.800264/page-35 and let's see what they answer. In the mean time I can test 97-98 passband.

    ReplyDelete
    Replies
    1. Have fun with those steep filters!

      BTW: Remember to check out the SRC Comparison:
      http://src.infinitewave.ca/

      SoX performs excellently if we're talking about things like ability to suppress aliasing; even compared to many commercial offerings!

      Delete
    2. Thank you! I have been checking SRC Comparison regularly :) Unfortunately Ferocious Resampler is there shown in a graph with single precision setting, which is the default because of higher speed. It should not matter for normal conversions since the noise is -150 dB. But I usually use the --doubleprecision setting which runs 64 bit precision.

      I agree that SoX is a good reference standard, especially for online upsampling, since Resampler now is offline only.

      Delete
  8. Just to tell you that I was really dissatisfied with how Volumio 2 sounded with my minidsp DDRC-24 so I installed picoreplayer in order to try these filters... WOW. The difference is night and day through the USB port, midrange is finally right, it cleaned it up. I'm using the Chord-like settings for now, probably will experiment further along the line. Thanks for this post!

    ReplyDelete
  9. hi any Foobar/SoX combination suggestion?

    ReplyDelete
    Replies
    1. try Resampler-V, it has a superb user interface
      https://sourceforge.net/projects/resamplerv/

      Delete
  10. cheap mont blanc Pen uk, combining elegant style and cutting-edge technology, a variety of styles of cheap mont blanc bonheur Pen, the pointer walks between your exclusive taste style.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. Thanks a lot for sharing your knowledge, I've modified my piCorePlayer settings to higher sampling rates and the result is just wonderful on my SMSL 100 Sanskrit

    ReplyDelete
    Replies
    1. Great to hear Emili. Have fun with the powerful and flexible settings available!

      Delete