Filter brewing for the Soekris R2R

Disabled Account
Joined 2005
OK, I am a noob at DACs and have been reading to try to understand. If I understand correctly, the DAM has no filter when fed 352.8 or 384 kHz input. Reading the John Swenson posts about upsampling externally using SoX, it seems like the interpolation filter used by SoX would have quieter alias' than upsampling of zeros added in the Dam as described by Soren. I'm not sure how rephase works.

I was wondering if any of you filter kings have compared a high res sample (192 or greater) with the NOS using 44.1 that you have been experimenting with? The hi-rez sample should sound cleaner, in theory, than the NOS, even if it was upsampled using a program like SoX.

My current concept is that the DAM Dac is an excellent choice when used with externally upsampled music, but I haven't gotten far enough to try any hardware.

Thanks in advance for you comments and experience.

Can you provide a link to where John Swenson discusses this... there are literally hundreds of posts across the many forums where John posts.

The default sox upsampling algorithm uses the same principle as the method DAM uses. Maybe John is doing something different.

upsample [factor]
Upsample the signal by an integer factor: factor−1 zero-value samples are inserted between each pair of input samples.
As a result, the original spectrum is replicated into the new frequency space (aliasing) and attenuated.
This attenuation can be compensated for by adding vol factor after any further processing.
The upsample effect is typically used in combination with filtering effects.
 
Last edited:
Disabled Account
Joined 2005
Ok... I've been investigating SoX and it looks like it's basically doing zero insertion upsampling, then applying tweaked FIR filters and dithering to the upsampled audio. This is basically same as what the DAM1021 is doing, but the SoX method only allows you to tweak without actually seeing what you are doing. That is probably over-simplifying.

Anyway I realised you can apply the FIR coefficients from rePhase to audio files using SoX which I'm sure SoX users already knew... Given the upsampling is roughly the same, it's a nice way of visualising what is happening to audio files in the DAM1021.

One of the things I hadn't realised is that with the filter bypass you cannot apply gain to the file without it clipping. It's a bit bizarre because the file sounds quiet, but when you look at the spectrum you can see why. The image below shows a short section of the intro to So What upsampled x8 with SoX with no other processing.

attachment.php


As can be seen the file contains two channels each with base image and seven mirrored images. The total energy at any point is the same as the un-upsampled file - the level meters are identical BUT the level when played back is signficantly lower. If you increase the gain at all SoX reports 1000's of clipped samples. The NOS config I posted had gain set to x8.

So I now understand why the NOS filter sounds harsh :)

This means that the NOS filter files need to be altered so there is no gain applied to any filter that has a bypass setting. The trade off is that level will be low and the DAC will clip if you set the gain any higher than V+00.

Next screenshot is "AirListen" filter coefficients applied to the x8 upsampled sound file.

attachment.php


You can see the audio mirroring around 22.05kHz with some sub-2kHz audio showing up between 42-44kHz. There is no mirrored audio above 44.1kHz.

I've tested a couple of filters against a 0dbFS sine test tone to see if retaining the mirrored image always causes clipping. This doesn't appear to be the case. The AirListen filter didn't cause clipping, but an apodizing filter I was trying out - which has no content above 22.05kHz - did cause clipped samples. I'm not 100% sure of the cause of this, it may be the filter is peaking where the roll-off begins.

More to come, but there are already some clues which will help build better filters.

cheers
Paul
 

Attachments

  • SoWhatAirList.png
    SoWhatAirList.png
    489.9 KB · Views: 1,196
Last edited:
Let me preface the following by stating I am just starting to come up to speed on the ins and outs of dsp, but after reading this thread on offline upsampling,

Offline Upsampling - Page 13

It would seem that for those using audio files stored on their computer and feeding the Soekris dac with i2s, you could upsample your files from 44 to whatever you wanted up to the limits of the dac input (many are using software to convert to DSD and if the Soekris dac eventually supports that, it could be really nice...), either offline, or on the fly, with software such as HQ Player or a number of others. If you send these to the dac, my understanding is you wouldn't need any output filter in the dac as it would just be doing the da conversion. There are many options for filters in these upsampling software packages, some perhaps too cpu intensive for optimum use in the dac so you might be able to do a better job in the computer and let the dac just do the lighter lifting....No need to mess with designing and uploading filters, etc...

Any comments? Am I completely off base with this?
 
Last edited:
Disabled Account
Joined 2005
Let me preface the following by stating I am just starting to come up to speed on the ins and outs of dsp, but after reading this thread on offline upsampling,

Offline Upsampling - Page 13

It would seem that for those using audio files stored on their computer and feeding the Soekris dac with i2s, you could upsample your files from 44 to whatever you wanted up to the limits of the dac input (many are using software to convert to DSD and if the Soekris dac eventually supports that, it could be really nice...), either offline, or on the fly, with software such as HQ Player or a number of others. If you send these to the dac, my understanding is you wouldn't need any output filter in the dac as it would just be doing the da conversion. There are many options for filters in these upsampling software packages, some perhaps too cpu intensive for optimum use in the dac so you might be able to do a better job in the computer and let the dac just do the lighter lifting....No need to mess with designing and uploading filters, etc...

Any comments? Am I completely off base with this?

There are probably advantages to offline resampling, but that is 100% off-topic to the subject of the thread which is to discuss and document creation of internal filters for the DAM1021. You might want to start a new thread as I'm sure there will be interest.
 
Am I completely off base with this?

No, except for use cases which doesn't involve a computer or a non-upsampling player on a computer, which I'd guess to be quite common: Spotify, VLC, YouTube, Apple TV, any other network media player, or just my plain non-upsampling media player app on computer for my local files which I find to be much easier to use than available upsampling players (on Mac).

By the way, do you know if there is a way to configure HQPlayerDesktop for power of 2 upsampling as default?

(May seem to be off topic but I use HQPlayer to compare filters kindly shared by Paul with us).
 
Disabled Account
Joined 2005
No, except for use cases which doesn't involve a computer or a non-upsampling player on a computer, which I'd guess to be quite common: Spotify, VLC, YouTube, Apple TV, any other network media player, or just my plain non-upsampling media player app on computer for my local files which I find to be much easier to use than available upsampling players (on Mac).

By the way, do you know if there is a way to configure HQPlayerDesktop for power of 2 upsampling as default?

Please cease the thread hijack.

It does not just seem off topic, it is.
 
Last edited:
My point is that for many users, it may be easier (no need to upload any filters) and better (lots of expertly designed filters, more computing power means more detailed filters, etc.) to use the premade filters available in these computer based players and simply pass the prefiltered material to the dam for da thus eliminating the need to reinvent the wheel and then end up with suboptimal performance due to processing power limitations in the dac and/or mediocre filters.

Of course this wouldn't be of help to those who do not input audio files from a computer. I only mention this here so that those who do are aware of this excellent option.

I didn't intend my comments to derail the thread, only to make others aware of this potential option....
 
Disabled Account
Joined 2005
The plot thickens...

Returning to the topic at hand.

Just had the idea to try Soren's default filter coefficients to see how it behaved on the 0dBFS sine test file.

Code:
sox  0_16.wav -r 352.8k 0_16_Sok441.wav upsample 8 fir Soekris441FIR.txt vol 8
sox WARN vol: vol clipped 54830 samples; decrease volume?
sox WARN dither: dither clipped 49403 samples; decrease volume?

The command sequence changes the sampling rate of the file to 352.8k with the "-r" switch, up samples the input file x8, applies the FIR filter described in Soekris441FIR.txt (a rePhase .txt output file) and adjusts the amplitude by 8dB to correct for the amplitude loss of the upsampling process. This is about as close to the process Søren has described for the DAM1021 as I think we can get using SoX.

What leaps out is the large number of clipped sample being reported. If also occurs in the DAM1021 it would go a long way to explaining why the default filters - and some of the user generated filters sound "shouty" or harsh.


Attached is an image comparing the impulse peaks of the Stock 44.1 filter, the AirListen1 filter and the Apodizing filter I'd made. The Soekris441 and Apodize441 both result in clipped samples when used with SoX. Soekris441 results in 54830 clipped samples at the volume adjust stage, while Apodize441 results in 30 clipped samples.

Søren has commented that there is some kind of compensation for the filters to prevent over saturation but I'm not sure if will prevent clipping. I guess this is something we need to find out.
 

Attachments

  • IMG000.png
    IMG000.png
    25.6 KB · Views: 262
Disabled Account
Joined 2005
My point is that for many users, it may be easier (no need to upload any filters) and better (lots of expertly designed filters, more computing power means more detailed filters, etc.) to use the premade filters available in these computer based players and simply pass the prefiltered material to the dam for da thus eliminating the need to reinvent the wheel and then end up with suboptimal performance due to processing power limitations in the dac and/or mediocre filters.

Of course this wouldn't be of help to those who do not input audio files from a computer. I only mention this here so that those who do are aware of this excellent option.

I didn't intend my comments to derail the thread, only to make others aware of this potential option....

No disrespect, but do you have any clue what the initials D I Y in the name of the forum means?
 
No disrespect, but you bought this dac, right?

Clearly there are different levels and facets of DIY. Some may prefer not to design their own filters or might not have the ability. Some may prefer what appears for many to be a better solution.

Surely there is room in the dac implementation for plenty of DIY outside of the filters....though I applaud the efforts of those who are exploring that part of the dac.
 
No disrespect, but do you have any clue what the initials D I Y in the name of the forum means?

Do you have any clue about the diyaudio standards? Trying to police this thread in this manner will be tiring for you. Good luck.

Staying on topic:

1. What is AirFilter1?

2. How zero insertion upsampling limit our options about filters (necessary window size to achieve enough smoothing and allowable roll-off steepness, if this is relevant at all)?
 
Returning to the topic at hand.

Just had the idea to try Soren's default filter coefficients to see how it behaved on the 0dBFS sine test file.

Code:
sox  0_16.wav -r 352.8k 0_16_Sok441.wav upsample 8 fir Soekris441FIR.txt vol 8
sox WARN vol: vol clipped 54830 samples; decrease volume?
sox WARN dither: dither clipped 49403 samples; decrease volume?

The command sequence changes the sampling rate of the file to 352.8k with the "-r" switch, up samples the input file x8, applies the FIR filter described in Soekris441FIR.txt (a rePhase .txt output file) and adjusts the amplitude by 8dB to correct for the amplitude loss of the upsampling process. This is about as close to the process Søren has described for the DAM1021 as I think we can get using SoX.

What leaps out is the large number of clipped sample being reported. If also occurs in the DAM1021 it would go a long way to explaining why the default filters - and some of the user generated filters sound "shouty" or harsh.


Attached is an image comparing the impulse peaks of the Stock 44.1 filter, the AirListen1 filter and the Apodizing filter I'd made. The Soekris441 and Apodize441 both result in clipped samples when used with SoX. Soekris441 results in 54830 clipped samples at the volume adjust stage, while Apodize441 results in 30 clipped samples.

Søren has commented that there is some kind of compensation for the filters to prevent over saturation but I'm not sure if will prevent clipping. I guess this is something we need to find out.
That is an interesting observation, i use this dac as a loopback dac always a few db down from 0db full scale and i never heard the problems the other guys heard. It sounds pretty similar used that way, no matter what filter i use, subtle differences, of course, but no shouting or so.
But since all modern masters are approaching full scale all the time, there might be problems with clipping. By the way, thanks for the hard work and research.
 
That is an interesting observation.....But since all modern masters are approaching full scale all the time, there might be problems with clipping. By the way, thanks for the hard work and research.

I agree, this is a very interesting place to investigate. Thanks spzzzzkt (It's Paul, right?)

As for your earlier question, here is the link to John Swenson's posts. There are more links in Soren's "Reference DAC Module.." thread at post 1478, page 148.

Upsampling Impressions

I'm surprised by your comment that SoX uses zero insertion because John discussed how it "interpolated" between data points and made the steps smaller in post 11 of the thread above. Or maybe I am not understanding it correctly.

One other thought. Mr. Swenson talks about the windowed sinc filter as being "better" than complicated cascade filters. I'm still reading about the details of SoX, but I did find a "sinc" command with lots of options. Perhaps "Rephase" has it too. It might be an interesting filter to try if there is room in the FPGA.

Naturally, that should come after the clipping issue is resolved.

Thanks again for all your hard work. I'm learning a lot.

Jac
 
Upsampling Impressions

I'm surprised by your comment that SoX uses zero insertion because John discussed how it "interpolated" between data points and made the steps smaller in post 11 of the thread above.

Post #51 is also interesting.

For the wordy explanation, lets take the output of a basic DAC chip, without any digital or analog filtering you get a stairstep. Upsampling without the filter is just subdividing each of those stairsteps into smaller pieces, but keeping the same values. Lets say you have a sample at .5V level, 8X upsampling gives you 8 shorter samples all at the same .5V, you haven't changed anything.

This doesn't sound like zero insertion upsampling, but like carrying over the value of last sample until next one throughout inserted samples. The result should be like NOS at the original sample rate in effect. You don't get the benefits of upsampling with increased resolution by interpolation, but you shouldn't be introducing any imaging/alisasing effects in addition to that of the source neither.

What you want is the upsampler to make a "guess" at filling in the intermediate values between the .5V sample and the next sample. The filter defines exactly how that is done. The human hearing system seems to be quite sensitive to exactly what that filter does, slight differences in that filter can make significant differences in what we hear.

Indeed, and I wonder if dam1031 architecture could help the filter by doing better than zero insertion (by repeating the the last known sample amplitude) and ease the burden on the filter for performing necessary smoothing/interpolation. This interpolation is an effect of low pass nature of the filter. So I think if the filter has to do less low passing, we would have a slower roll off, which I find better than steep roll off for realism.

Of course the best would be actually interpolating the samples on the hardware, but it may be too much to ask from the FPGA.

By the way, Paul, I'm listening to your 1021LPSRO441 for the last few days and finding it quite good. I could live with it. But the more I learn, the more I wonder about the means we could improve the sound quality by less intrusive filters (i.e., letting Soren the difficult job on the architecture :) )
 
Indeed, and I wonder if dam1031 architecture could help the filter by doing better than zero insertion (by repeating the the last known sample amplitude) and ease the burden on the filter for performing necessary smoothing/interpolation.

I'm still a beginner here, but it seems like this should be possible. I would think that Soren needed to add the zeros in the upsampling process. The question of holding the value would seem to take more, but not too much more programing.

Of course the best would be actually interpolating the samples on the hardware, but it may be too much to ask from the FPGA.

From what John Swenson said about windowed sinc filters and interpolation, I wonder if this is possible in SoX? That said, he also implied that these things take a lot of space, so it may not be possible in the FPGA.

I will try to read deeper into the SoX documentation and try to understand.

Jac
 
Disabled Account
Joined 2005
Have a read of the information for the SoX "upsample" effect.

SoX

The key thing is "factor−1 zero-value samples are inserted between each pair of input samples"

It is entirely possible SoX uses other algorithms for resampling, but without reading the code I wouldn't know, and I'm not sufficiently curious about SoX to do so.

John's comments about cascaded filters is one that is commonly levelled at commercial chips. One example is the old SM5847 filter which was very well regarded for a long time - the signal passes through 4 separate FIR filters working in the audio band plus de-empahasis if needed. The DAM1021 has one main filter plus a second FIR filter which is used to clean up HF junk above 220kHz.

The cascaded filters are believed to cause signal degradation and the optimum solution is to have all filtering done in a single FIR filter.

rePhase uses a different but equally validmethod to generate the filters. Basically you specify the curve you want to achieve, then FFT analysis is used to determine the required filter co-efficents.

cheers
Paul
 

TNT

Member
Joined 2003
Paid Member
You don't get the benefits of upsampling with increased resolution by interpolation....

One can rest assure that this is not true. Interpolation has nothing to do with resolution whatsoever. Inserting a sample between two neighbors could at best change nothing in the derived, ideal, output but most probably introduce an estimation error which doesn't degrade "resolution" but introduces an error = distorsion. The little "wrinkles", probable distorsion as per above, introduced to the audible envelope by interpolation at upsampling cant be heard anyway. Upsampling is about reducing filter requirements by reshaping the energy of the alias spectrum and not for "envelop forming".

My experience is that a real high resolving system tends to sound soft as an initial impression, not "sharp".

//
 
Other patterns than inserting zeros for upsampling can always also be obtained form a zero-inseted version via a filter.
So you do nothing wrong by inserting zeros and it is easy to handle theoretically. If you start with some fancy upsampling algorithm both might no longer be true.
 
So you do nothing wrong by inserting zeros and it is easy to handle theoretically. If you start with some fancy upsampling algorithm both might no longer be true.

OK, good point.

Checked SoX source code and it does zero insertion upsampling, nothing fancy. So the results are comparable to that of dam1021.

TNT, you are right about interpolation & resolution. By "interpolation" in that sentence I meant the method described in the paragraph, which is actually not interpolation. Bad choice of term.