Solving the intersample DAC clipping problem for about ten euros

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Hi all,

Many audio DACs and DAC chips have spectacular SINAD and dynamic range numbers when measured with sine waves of 0 dBFS or less, but actually run into clipping when driven with music, especially on recordings with relatively low sample rates (such as 44.1 kHz) that are peak normalized to 0 dB (like most recordings are nowadays).

One reason for this is the fact that the interpolation and reconstruction filters can have overshoots on non-sinusoidal waveforms. A more important reason is that when the waveform is not sampled exactly at the peaks, normalizing the largest samples to full scale means that the reconstructed peak must be greater than 0 dBFS. These facts are rarely taken into account by DAC manufacturers. See the Benchmark Media site for a very clear explanation.

A solution is to buy a 2200 euro DAC from Benchmark Media, another is to build one of my hobby DAC designs (less expensive than Benchmark Media, but certainly not cheap), a third is to renormalize all recordings to -3 dBFS or so (inconvenient when the music is on physical media like CDs) and a fourth is to attenuate the signal going into the interpolation filter.

Assuming two's complement data sent over an I2S connection, the attached circuit should be sufficient to attenuate the signal by 1 bit (6.02 dB), thereby creating 6.02 dB of headroom for intersample overshoots. If your DAC has 110 dB dynamic range referred to 0 dBFS, it will be only 104 dB after installing this circuit, but in practice that still means you don't hear any noise at all. Mind you, it is only a paper design so far, I haven't tried this circuit.

The circuit shifts the whole signal one bit to the right and applies sign extention (repeats the MSB). This means that 16 bits data become 17 bits, 24 bits become 25 bits et cetera. When the number of bits gets larger than the DAC or the ratio of bit clock to word clock supports, the LSB will be rounded down bluntly without any dithering. In practice this is no problem for DACs with a large input wordlength, like 24 or 32 bits DACs. For a 16 bits DAC, very soft signals will be degraded by the extra quantization distortion.

Built with 74HC74's and a 74HC4053, the circuit should be able to handle 44.1 kHz and 48 kHz sample rates at 3.3 V supply voltage, and 96 kHz at 5 V. With the indicated 74AHC74's and 74LV4053A, even 384 kHz at 3.3 V should be no problem.

The values of the output resistors depends on the lines between the circuit and the load. When the wires are short, no resistors are needed, otherwise they need to be chosen such that reflections stay limited.

The top right flip-flop is abused as an inverter.

Best regards,
Marcel
 

Attachments

  • I2Sattenuator2B.jpg
    I2Sattenuator2B.jpg
    126.4 KB · Views: 579
Your second paragraph is a good reason why it is a good idea to look for a DAC with voltage headroom, the more the better. Then one can do a digital volume reduction at -6dB or less and still get enough gain out of the DAC.

Marcel, what is the motivation for doing your hardware modification versus using digital volume reduction? You mention CDs, so perhaps your application is intended for hardware based playback like a CD player where there is no provision for digital volume control?
 
Last edited:
Your second paragraph is a good reason why it is a good idea to look for a DAC with voltage headroom, the more the better. Then one can do a digital volume reduction at -6dB or less and still get enough gain out of the DAC.

Marcel, what is the motivation for doing your hardware modification versus using digital volume reduction? You mention CDs, so perhaps your application is intended for hardware based playback like a CD player where there is no provision for digital volume control?

If you already have a digital volume control before any filter, you can use that of course. If you have no digital volume control or if any kind of sample rate conversion or filtering takes place before the digital volume control, then you are in trouble.
 
That's a very clever circuit. In exchange for eliminating an occasional clipped sample, which would probably be inaudible, you reduce the available dynamic range by 6dB, add distortion, and increase BCLK jitter. Well done!

On what do you base your assumption that 3.7 clipped samples per second are inaudible, while a slight increase in a minus one hundred something dB noise floor would be a problem?

By the way, I forgot to add a link to this:

Intersample Overs in CD Recordings - Benchmark Media Systems, Inc.

and to mention that the BCK inversion is optional; it improves hold time at the expense of set-up time, but is not required according to the I2S standard.
 
Last edited:
As an example of digital volume control that won't help against intersample overshoots, the SRC4392 datasheet ( http://www.ti.com/lit/ds/symlink/src4392.pdf ) states explicitly that the SRC4392 asynchronous sample rate converter has an output attenuator:

Page 1: "-Digital output attenuation and mute functions"
Page 34: "The SRC includes output soft muting and digital attenuator functions"
 
Member
Joined 2017
Paid Member
It's interesting. I have IIS interface configured by FPGA to pcm1792. It takes few hours to add "divide by two" and reconfigure. It worked successfully. The attached is schematics. I am out of date person who still uses the schematic entry to design FPGA. But I'm sure it is useful to understand circuit visually.

BTW, I have several pieces of music files which have a 0.5dBFS amplitude at maximum because of "loudness war." There is a good chance to have intersample overs which result in much distortion in FFT. They are little change in time domain but are very audible as FFT says. Most of my music files are from vinyl which has enough headroom. Oversampling filter itself has no problem. But if you play
"loudness war" files, "divide by two" is one solution. NOS with steep analog LPF is another one. I wonder a NOS lover can perceive intersample overs.
 

Attachments

  • divide_by_2.jpg
    divide_by_2.jpg
    153.3 KB · Views: 450
Good point. The intersample overshoot story could indeed explain why some prefer non-oversampling DACs, like you wrote. It could also explain why many prefer high sample rate files without needing to hypothesize that ultrasonics are somehow audible; the intersample overshoot problem is smaller on high sample rate recordings, as explained by Benchmark.
 
Member
Joined 2017
Paid Member
The attached are recent music files ripped from CD. You can easily find several clipped sample points(0dBFS). Their usual maximum level is almost -0.3dBFS(97%) which has a good chance to have intersample overs though it depends on the oversampling process. DAC manufacturer has no responsibility for this because they can't predict what music files are played by a customer. A customer must recognize the probability.

No oversampling filter, which means NOS, is one solution. DSD stream is another one which inherently no need to have an oversampling filter. Some people say DSD has quiet sound like high sample rate files. I'm sure DSD is free from intersample overs but not sure it can have quiet sound because DSD has much quantization noise from 20kHz.
 

Attachments

  • ov2.jpg
    ov2.jpg
    76.8 KB · Views: 425
  • ov1.jpg
    ov1.jpg
    77.2 KB · Views: 413
On what do you base your assumption that 3.7 clipped samples per second are inaudible, while a slight increase in a minus one hundred something dB noise floor would be a problem?

and to mention that the BCK inversion is optional; it improves hold time at the expense of set-up time, but is not required according to the I2S standard.

On what do you base your assumption that intersample clipping always adds exactly 3.7 clipped samples per second and that they are audible in all cases?

You've cut the available dynamic range in half. You've changed a 16-bit DAC into a 15-bit DAC. You've added quantization noise to every sample. The typical CMOS input gate adds 1-15pf to the net it's on. PCB traces, etc. add more. That added capacitance is a low-pass filter that slows the clock signal, increases the propagation delay, and slows rise times. That hardly matters with data, especially at digital audio data rates, but is surely matters with a clock. Increased prop delay means increased skew. Slowed rise time means the signal spends more time in the no-man's-land between zero and one, which increases the uncertainty of exactly when clock edge happens and that is jitter.

If removing intersample noise with this circuit is so important, a very simple circuit change will solve the potential jitter problem. Add a buffer to the BCLK tap. E.g., Si53365.

A better way, if you are using S/PDIF, is a simple mod to the S/PDIF receiver to it right shift the data one or two bits with sign extension. Such a circuit, implemented as a drop-in replacement for a CS8412, was posted on the Audio Note forum a few years back.
 
On what do you base your assumption that intersample clipping always adds exactly 3.7 clipped samples per second and that they are audible in all cases?

I don't assume that. It is just a practical example, see the link I gave earlier:
Intersample Overs in CD Recordings - Benchmark Media Systems, Inc.

I have no idea whether the clipping is audible. I could well imagine it is, though, because I know from practical experience that sound soon gets very ugly when you hard clip it.

Now could you please answer my question?

You've cut the available dynamic range in half. You've changed a 16-bit DAC into a 15-bit DAC. You've added quantization noise to every sample.

The circuit is meant for modern oversampling DACs with an interface of 24 bits or more. The extra quantization noise will then be at -140 dBFS or less. As DAC manufacturers compete on price and dynamic range, most of these DACs have dynamic ranges far in excess of what is needed for normal domestic listening, so I don't consider a 6 dB loss a big deal.

The typical CMOS input gate adds 1-15pf to the net it's on. PCB traces, etc. add more. That added capacitance is a low-pass filter that slows the clock signal, increases the propagation delay, and slows rise times. That hardly matters with data, especially at digital audio data rates, but is surely matters with a clock. Increased prop delay means increased skew. Slowed rise time means the signal spends more time in the no-man's-land between zero and one, which increases the uncertainty of exactly when clock edge happens and that is jitter.

If removing intersample noise with this circuit is so important, a very simple circuit change will solve the potential jitter problem. Add a buffer to the BCLK tap. E.g., Si53365.

Thanks for the suggestion, it is the first constructive contribution you made to this thread. If anyone wants to use a buffer, please check that its delay doesn't introduce hold time issues. If it does, data and LRCK also need to be slightly delayed.

A better way, if you are using S/PDIF, is a simple mod to the S/PDIF receiver to it right shift the data one or two bits with sign extension. Such a circuit, implemented as a drop-in replacement for a CS8412, was posted on the Audio Note forum a few years back.

That's functionally the same as what I propose, so how is it better? In any case, if you are so worried about jitter, don't use S/PDIF.
 
The attached are recent music files ripped from CD. You can easily find several clipped sample points(0dBFS). Their usual maximum level is almost -0.3dBFS(97%) which has a good chance to have intersample overs though it depends on the oversampling process. DAC manufacturer has no responsibility for this because they can't predict what music files are played by a customer. A customer must recognize the probability.

No oversampling filter, which means NOS, is one solution. DSD stream is another one which inherently no need to have an oversampling filter. Some people say DSD has quiet sound like high sample rate files. I'm sure DSD is free from intersample overs but not sure it can have quiet sound because DSD has much quantization noise from 20kHz.

Thanks for the measured data!

I think it would be fairly easy for oversampling DAC chip manufacturers to solve the issue. All they have to do is add a controllable input attenuator and a filter clipping indicating bit. They could then still measure the DR and SINAD values at maximum volume, in order not to get worse datasheet values than the competition. The set maker will then have to do practical tests to find a sensible setting, or even make it controllable for the end user.

The worst-case overshoot of a filter is the sum of the absolute values of the coefficients divided by the sum of the coefficients. For the interpolation chain of my valve DAC that boils down to something between 10 dB and 11 dB. Hence, an input attenuator with a control range of the order of 12 dB would suffice.
 
Now could you please answer my question?

I know it is not audible because, as a programmer, I can put any hypothetical digital audio question to a real world test. I can create any kind and quantity of intersample clipping I choose and listen to the effect. Why don't you do that instead of speculating and fixing problems that don't need fixing.

If the samples are coming from a PC, the proper way to deal with intersample clipping is to use replay gain. As part of its analysis, replay gain upsamples to discover the true analog peak and calculates the gain adjustment accordingly.
 
I know it is not audible because, as a programmer, I can put any hypothetical digital audio question to a real world test. I can create any kind and quantity of intersample clipping I choose and listen to the effect. Why don't you do that instead of speculating and fixing problems that don't need fixing.

Because I don't believe that my ears are a reference for the rest of the world and mainly because I find it extremely inelegant to drive a system with a very large dynamic range into hard clipping for no sensible reason. When you want to record something on a 50 dB dynamic range cassette recorder, allowing occasional soft clipping may make sense, but with hard clipping 100+ dB digital systems? Get real!

In any case, no-one has to build my circuit. Anyone who likes to listen to hard clipped music because they worry more about whether the noise floor is at -104 dB or at -110 dB than about gross distortion, can just go ahead.

If the samples are coming from a PC, the proper way to deal with intersample clipping is to use replay gain. As part of its analysis, replay gain upsamples to discover the true analog peak and calculates the gain adjustment accordingly.

Yep, that's a good approach if the signal comes from a PC.
 
Member
Joined 2017
Paid Member
I did software simulation from 44.1kHz to 88.2kHz. The target is recent "loudness war " files which I posted before. This is my first try which means no special selection. But I found three intersample overs in five minutes files!

My software, which probably uses 32-bit floating point, can calculate precise value even if overflow occurs. One intersample overs is about 100.106. This is a little bit higher than 100 but has a disastrous result.
Most digital filter usually doesn't have overflow protection. More than 100 means from max positive value to max negative value(from 0x7fffff to 0x800000).

My digital filter doesn't have overflow protection(limiter) but has 0.5dB headroom. In this case, no overflow occurs. 0.5dB headroom is usually sufficient from my experience. But "loudness war" files have a chance to break my fire wall and make overflow.
 

Attachments

  • ovs2.jpg
    ovs2.jpg
    358.3 KB · Views: 258
  • ovs1.jpg
    ovs1.jpg
    403.3 KB · Views: 214
  • ovs3.jpg
    ovs3.jpg
    70.5 KB · Views: 229
Member
Joined 2017
Paid Member
It's reasonable they can find +3.1dBFS in 5000 CDs because even my first try is +0.1dBFS. .;)

I'm sure intersample overs is not a particular thing. My interest is whether digital filter in a DAC chip has overflow limiter or not. As long as more than 0dBFs signal results in clipped signal(with overflow limiter), It matters little at least from my standard. I'm not sure it is audible or not If without the limiter.
 
Member
Joined 2017
Paid Member
From your link to Benchmark Media Systems, a usual commercial DAC has the limiter. But it doesn't make sense to me. The existence of the limiter means they know a chance of intersample overs. If so, why do they take some protection method? :eek: There is some method which doesn't cost much, IMHO.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.