Converting PCM to DSD on the fly -- the nuts and bolts

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Say you want to convert PCM to DSD on the fly (as in the case of the PS Audio Directstream DAC)...what are the nuts and bolts of how this is done in software (or firmware)?
Note that one is going from PCM to PDM -- two very different digital coding formats.

Specifically (even inside a single FPGA device), does one ever enter the analog domain?

So:

PCM ---> d/a ---> a/d (DSD PDM) --->out to LP filter.

(for the sake of simplicity, disregard oversampling)
 
The simplest approach including oversampling is:

insert zero samples, low-pass filter, put into a high-order sigma-delta modulator (which is a negative feedback loop around a coarse quantizer).

Everything is completely digital.

This Pascal program does something similar, although the interpolation filter is too simple, the oversampling rate too high, the sigma-delta incorporates a PWM-like circuit that shouldn't be there and it operates on files rather than in real time on streams:

https://www.diyaudio.com/forums/dig...-sigma-delta-dac-operation-3.html#post5189375
 
Last edited:
Everything is completely digital.
I'm not I sure with that. You're going from PCM to PDM.
Here's an excerpt from Principles of Digital Audio [Pohlmann, 2005]:
poda_7-35.jpg

"FIG. 35 DSD coding uses a sigma-delta coding technique. A. A sigma-delta modulator uses negative feedback to subtract a compensation signal from the input. B. The output signal from a sigma-delta modulator is a pulse-density waveform."

On the other hand, with heavy-math processing, Each of the "lollypop" pulses could be transcoded to PDM. But still, IMO, the output of PCM has to look "analog".
poda_6e_4-12b.jpg
 
Everything is discrete in time and momentary value, which is the definition of a digital signal that I've been thaught.

It starts with a PCM signal with sample rate fs, after interpolation filtering with interpolation factor N it is a PCM signal with sample rate N fs, and assuming the sample rate of the sigma-delta is also N fs, it is then converted to a bit series with rate N fs. Use finite-wordlength representations for all intermediate results and everything is represented as a finite number per unit time of numbers with finite precision.

In that sense it is digital. In fact I wouldn't know how to program anything analog (time- and momentary-value continuous) in a Pascal program.

It also doesn't need to be continuous-time in the sense that an asynchronous sample rate converter needs a continuous-time stage. When the sigma-delta sample rate is equal to the sample rate after interpolation, it doesn't matter that the interpolated signal is undefined or zero in between samples, because the accumulators in the sigma-delta don't need any values in between samples anyway.
 
Last edited:
No, the Pascal program works on files. It just illustrates the algorithms involved, I don't know how to make it work on streams. It should be possible, though. One required change is that the integrator states which are now stored in arrays would have to be stored in normal variables. Using arrays is a waste of memory, but was very convenient for debugging.

Originally I wrote the sigma-delta procedure to do some checks before converting it to synthesizable Verilog code to program into an FPGA board. Pascal is much more convenient than the quite quirky Verilog.

The Verilog version can be found here:

https://linearaudio.net/sites/linearaudio.net/files/ThevalveDAC_PCB_FPGA_files for web posting.zip

https://linearaudio.net/sites/linearaudio.net/files/additionaldatavalveDACversion2p1.zip

It runs on the biggest Spartan 6 device that the free Xilinx software supports, but that's mainly because I went a bit overboard with the filters, as shown in the attachment. The sigma-delta itself doesn't require much processing power.

It is part of a DAC that I built. Whatever comes in is converted to a 27 Mbit/s stream that goes into the actual DAC.
 

Attachments

  • Figure16.png
    Figure16.png
    81.6 KB · Views: 785
Last edited:
I think the issue with this conversion process is rounding of the result. It is also some how similar to ASRC as PCM and DSD have different standard sampling rates. Of course the theory is that such negative effect is inaudible.

When the DSD sample rate is an exact multiple of the PCM sample rate, 64 or 128 times for example, you don't get any aliasing. You only need the low-pass filter to get rid of the images that were already there in the PCM signal. With ASRC you do get aliasing, so you need much better filtering.

Rounding of the result, a.k.a. as requantization, is indeed an issue. You can't dither it properly because a one-bit signal has too few quantization levels for proper dithering. In a loop, this can result in distortion and idle tone issues.

(In fact that's why I use a sigma-delta with an embedded pulse-width modulator in my DAC: the quantizer then has more levels and can be dithered normally. A disadvantage is less effective noise shaping for a given bit rate.)
 
No, the Pascal program works on files. It just illustrates the algorithms involved, I don't know how to make it work on streams. It should be possible, though. One required change is that the integrator states which are now stored in arrays would have to be stored in normal variables. Using arrays is a waste of memory, but was very convenient for debugging.
As I noted in the OP, PS Audio's $7k Directstream DAC has been able to transcode "live" since the product was introduced (2013??). One can search YouTube for discussions with Ted Smith on how he approached the project.
Directstream has gotten decent reviews but it doesn't seem have out-competed other high-$ dacs.

As far as converting PCM to DSD for files only, I think it's possible in Foobar via some plugin???
Also, the following third-party software claims to be able do the conv. via freeware:
How To Convert PCM to DSD For Free | A Sound Upgrade

As far as PS Audio's claim that converting to DSD is the magic bullet, I don't see how!
Maybe PCM-to-DSD (on-the-fly) it as simple as "buffering" -- like the "magic" benefits of SRC (upsampling) or re-clocking I2S.
 
Looking at this link:

DirectStream DAC | PS Audio

I get the impression that they use an FPGA board to convert whatever comes in into a single-bit sigma-delta modulate. That's exactly what the Verilog code I linked to in post #7 does when you set it to its chaotic single-bit mode. The Verilog version does work in real time and on-the-fly, unlike my Pascal program.

My signal path is longer than they would like, though. The approach to filtering and synchronizing the signal source and the DAC is different from theirs.
 
Last edited:
As far as converting PCM to DSD for files only, I think it's possible in Foobar via some plugin???
Also, the following third-party software claims to be able do the conv. via freeware:
How To Convert PCM to DSD For Free | A Sound Upgrade

As far as PS Audio's claim that converting to DSD is the magic bullet, I don't see how!

I have heard some people using software e.g. Audirvana to transcode pcm to dsd live (streaming from Tidal). They seem to like the sound. I am going to try this when I get my dsd dac. I think the dac must be native dsd to realize the benefits, if any.
 
I have two questions…

Suppose you have a PDM / DSD1 / DSD64 signal, which 64 times oversampled (64 x 44100 = 2,822,400 Hz). So you have 64 1 bit samples per 44100 Hz, when PCM give you one sample per 44100 Hz. 64 1 bit samples give you 65 possible density values (from 0, all of to 65, all on). 64 values you can code in 6 bits, 128 values in 7 bits (mathematically, you can code 65 values in 6.022367813 bits). So a DSD signal is equivalent with a 6 bit (or more exact 6.022367813 bit) 44100 Hz signal!

The other way around. Suppose you have a 16 bit PCM signal. That gives you 65.536 possible values. To represent that without information loss, you need 65.536 times oversampling, that is 2,890,137,600 Hz or 2.890,137,600 GHz! So you need DSD65536 to get the equivalent of a Red Book CD.

A modern DAC uses a digital multibit delta-sigma modulator to convert a PCM signal to a signal with less bits at a higher sampling rate without loss of information. There are 256 times oversampling DAC’s, so they create their own "multibit DSD streams".

This way you can convert a 16 bit PCM signal into a "10 bit DSD64 stream", into a "8 bit DSD256 stream" or, with 512 times oversampling, into a "7 bit DSD512 stream".

So, my first question is, why on earth, would one like to store music in DSD format?

The second question is, why would one convert PCM into DSD, when a modern DAC uses multibit delta-sigma modulation for oversampling?
 
According to me, your whole reasoning is flawed. It would be correct for a first-order sigma-delta and a reconstruction filter that weighs uniformly over 64 samples, but not for a high-order sigma-delta with high-order reconstruction filter. Nonetheless, storing signals in DSD format indeed has many disadvantages.

We had a similar discussion in this thread: Clarification of Sigma Delta DAC operation wanted The thread starter hypothesized that an N times oversampled M-bits sigma-delta doesn't respond to signals smaller than (2^-M)/N times full scale, and I wrote Pascal programs to check that hypothesis.
 
Hi Marcel,

First of all, thanks for your response...

According to me, your whole reasoning is flawed. It would be correct for a first-order sigma-delta and a reconstruction filter that weighs uniformly over 64 samples, but not for a high-order sigma-delta with high-order reconstruction filter. Nonetheless, storing signals in DSD format indeed has many disadvantages.

We had a similar discussion in this thread: Clarification of Sigma Delta DAC operation wanted The thread starter hypothesized that an N times oversampled M-bits sigma-delta doesn't respond to signals smaller than (2^-M)/N times full scale, and I wrote Pascal programs to check that hypothesis.

OK. But I supose that a high-order interpolation fillter cannot account for an extra 10 bits of resolution?

And what were the conclusion of your tests?
 
Hi Jerry,

If I remember well, a DSD64 signal passed through a brick-wall filter at 20 kHz has a signal to noise ratio of about 120 dB, so around 20 bits. So in this example, perfect filtering gives you 14 bits more than your line of reasoning.

People who like DSD usually prefer smooth filters, though. As a smooth filter doesn't suppress the shaped noise above 20 kHz completely, basically they rely on their ears to do the remaining reconstruction filtering.

The real limitation of noise shaping/sigma-delta modulation was calculated by Gerzon and Craven and published in AES preprint 2822 (Optimal noise shaping and dither of digital signals, 87th convention, October 1989). In a nutshell, noise shaping suppresses quantization noise in a part of the frequency band from 0 Hz to half the sample rate and aggravates it in the rest of this band. When you plot the so-called noise transfer function on a linear frequency scale and dB vertical scale, the area below the 0 dB line (area where the quantization noise is reduced) can never be greater than the area above the 0 dB line (area where the quantization noise is aggravated).

The conclusion of my test was that the thread starter of the other thread was wrong. The sigma-delta definitely responded to smaller signals than he had expected. In fact it behaved very similar to a linear filter with some small amount of added noise. (I should add that it was a dithered quasi-multibit sigma-delta, a plain old undithered single-bit sigma-delta can have funny signal-dependent idle tones.)
 
Last edited:
Hi Marcel,

Thanks!

Brick-wall filter? But, how is that possible in the analogue domain? Sounds very theoretical...

But, all together, I have the feeling you and I come to the same conclusion: that feeding PCM into an 64 times oversampling SDM DAC (resulting in 10 bits at the same sample rate as DSD64) is superior to feeding a DSD64 signal into a DSD (1 bit) DAC. Or am I wrong?
 
Brick-wall is theoretical, but elliptical filters can be made quite steep if needed. A cascade of an elliptical filter and an all-pass group delay equalizer can even be steep and have a reasonable phase response.

No-one ever uses those for a sigma-delta DAC, though. A sigma-delta DAC normally gets more than enough filtering to be sure that no amplifiers will go anywhere near slew rate limiting and no tweeters will go up in smoke, but the out-of-band noise after filtering can easily be -60 dB with respect to full scale for a converter with 120 dB SINAD specification. You then set the bandwidth of the audio analyser such that it doesn't measure the out-of-band noise and hope that the ears of the users will also filter off the remaining out-of-band noise (and that their cats and dogs don't mind hearing a bit of high-pitched hiss).

I don't agree with your last paragraph, particularly not with the remark about 10 bits, but I do agree with you that DSD is a somewhat unhandy format for various reasons. Almost any form of digital signal processing (like adjusting the volumes of different recordings) requires conversion to PCM, many DACs are not single bit to begin with, and single-bit sigma-delta modulators can not be dithered according to dither theory.

What I do like about it, is that it enables you to make very simple DAC circuits, like in these threads: The Best DAC is no DAC and Signalyst DSC1
 
Member
Joined 2017
Paid Member
You can regard DSD(1bit DSM) as one kind of SMPS. SMPS has only two states(1bit), on and off. But you can have arbitrary voltage. The magic is NFB. NFB loop controls on and off to maintain a fixed voltage. If your SMPS has sine wave reference voltage, the output is probably sinewave, though it has some distortion. DSM has specific NFB loop with noise-shaping to keep the low output distortion in the audio band. Bit resolution isn't fatal in DSM topology because of NFB. Multi-bit DSM is superior to 1bit in stability, residual noise, and distortion but extremely high relative accuracy for amplitude is the disadvantage. I started my "career" about DSM with multi-bit one. But now I would say 1bit DSM is more promising than multi-bit.:)
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.