Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: DSD-2-PCM -- proof of concept (Read 151124 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

DSD-2-PCM -- proof of concept

The ZIP contains 4 files:
- dsd2pcm.jar (the converter written in Java, outputs raw 24/88 PCM, intel byte order)
- info.txt (contains some infos)
- test2822k.dsd (14 seconds, mono DSD, 5 megs)
- test44k.mp3 (conversion result)

have fun,
Sebi

Edit-2011: For the latest C/C++ source code see https://code.google.com/p/dsd2pcm/ It is released under the new BSD license. The attatchment to this post is still the first Java release.


DSD-2-PCM -- proof of concept

Reply #1
Now you need to develop a DVD-ROM driver for reading SACD's and find a way to crack the copy protection schemes, and we're all set! You don't have a choice anymore.

DSD-2-PCM -- proof of concept

Reply #2
Quote
Now you need to develop a DVD-ROM driver for reading SACD's and find a way to crack the copy protection schemes, and we're all set! You don't have a choice anymore.

[a href="index.php?act=findpost&pid=332839"][{POST_SNAPBACK}][/a]


Intercepting the raw DSD stream between an SACD player's decoder and its DAC would probably be easier. (I've no experience on this subject.)

Sebi

DSD-2-PCM -- proof of concept

Reply #3
Oh, I noticed a small bug: The dsd file size must be divisible by 4. This is due to the 2nd stage wanting to "convert" 4 samples to one (4:1 decimator) -- the first stage turns each byte into a float sample (8:1 decimation).

Cheers,
Sebi

DSD-2-PCM -- proof of concept

Reply #4
So is it theoretically possible to convert the PCM output back into a DSD stream so that it matches the original DSD stream? In other words is a DSD->PCM->DSD conversion theoretically lossless?


DSD-2-PCM -- proof of concept

Reply #6
Thanks for the link.  But right now, I'm only concerned with the theory at the moment.  There are many people who claim that DSD is superior to PCM (they say it sounds better).  But on the vast majority of converter chips that give you a PCM signal, the conversion is a 1-bit delta-sigma stream that is converted to PCM.  DSD is just that 1-bit stream before the conversion.

In discussions I've had on this topic, I say that there isn't any difference between DSD and PCM if the conversion to PCM (in other words the delta-sigma stream conversion to pcm) is done with care.  What I don't know is if theoretically and mathematically, is the conversion actually lossless.  So is it theoretically possible (not just good enough for audio) to go from DSD to PCM and then back to DSD without losing any information?  If so, it seems that the DSD/PCM discussions are moot, and it all boils down to how good the actual implementation is.

And is there a better forum to post this in?  I just posted here due to the topic of DSD->PCM conversion.

DSD-2-PCM -- proof of concept

Reply #7
In discussions I've had on this topic, I say that there isn't any difference between DSD and PCM if the conversion to PCM (in other words the delta-sigma stream conversion to pcm) is done with care.
DSD and PCM exist in various formats so you'd have to be a bit more specific. "DSD" is usually 64Fs DSD but there are also 128Fs converters. When DSD is converted to PCM for editing/mixing purposes 24bit 352.8 kHz seems to be a popular choice (Pyramix workstation e.g.). Still, some recording engineers claim (no proof) that there is an audible difference (example). Another option is 8 bit 2.8 MHz PCM (Sonoma and Sadie workstation). My guess is that when the conversion involves sample rate and/or wordlength reduction, it can't be considered lossless. Most DSD users I know don't think the quality "loss" is something to worry about.
I gladly leave the final answer to the mathematical experts on this forum.

DSD-2-PCM -- proof of concept

Reply #8
I'm mildly curious how this method compares and contrasts to Sony's own SBM Direct conversion system for DSD, bit and sample rate levels aside--in terms of perceived sound quality. In my experience SBM Direct-encoded CDs are among the least fatiguing and irritating redbook cds that I have heard, especially with players that are prone to jitter. But if this system preserves more of the audio information of the original DSD recording then that benefit may be offset, assuming an appropriate D-to-A converter is used for playback of the converted recording.

DSD-2-PCM -- proof of concept

Reply #9
Is there any updated info about this program? I tried it, and it worked. Seems useful.

It would be interesting if it could support stereo, and support .DFF, which afaik is pretty much the same as .DSD, perhaps interchangeable. There's test DFF files at http://www.2l.no/hires/index.html.

Or even more useful, DSF files. with Sony DSD Direct software you can convert stereo PCM to DSF, but there's no program (I know of) to convert back to PCM.

DSD-2-PCM -- proof of concept

Reply #10
I am bringing this back form years of being dead.  I am working on hardware now to rip a SACD, I am capturing the raw unencrypted 6 mono DSD data streams that is sent to the DACs in my denon SACD player.  I have some test data captured that I want to run through the DSD to PCM software but I am unable to read the sample DSD file provide with the program after it is converted to PCM.  Once I get the test file confirmed I can move on to testing my captured data.

I really hope SebastianG is still around.  Does anyone know what format the outputted PCM file from the program is in 16-bit, or 32-bit?  If 32 bit what IEEE float (0.24, 16.8, 24.0).  Is there an offset? Is the byte order little-endian or big endian?  I used your program to convert the sample test2822k.dsd to a pcm and am trying to open it an Audacity and cooledit pro with no luck.  I will keep messing with the options and hopefully stumble upon the right setting.

Thanks!
Luke

DSD-2-PCM -- proof of concept

Reply #11
I think it's in the first post.
outputs raw 24/88 PCM, intel byte order)

In theory, there is no difference between theory and practice. In practice there is.

DSD-2-PCM -- proof of concept

Reply #12
I think it's in the first post.
outputs raw 24/88 PCM, intel byte order)


Correct. The info.txt file says it all.
Input: raw mono DSD where the bytes' bits are processed from LSB to MSB. The file size must be a multiple of 4.
Output: raw 24bit PCM at 88.2 kHz in little endian format.

The decimation is done in two stages:
1. 8:1 (from 44100*64 to 44100*8 Hz)
2. 4:1 (from 44100*8 to 44100*2 Hz)

If you leave out the 2nd stage you basically have what's known as DXD (PCM at 352kHz sampling frequency) which seems to be popular as an intermediate/processing format.

If you test it and the result sounds too noisy chances are that the bit order of your file and the expected bit order doesn't match. If you know a little about hacking code it should be easy to change it. I already have a table in there that for reversing the bits in a byte, for example.

The implementation of the first stage is a little tricky. Instead of 8 MACs (multiply-and-accumulate) for 8 bits in a byte I just use one table lookup. The bitreversal is needed anyway to exploit the FIR filter's impulse response's symmetry and reduce the size of the tables. If someone wants to code something similar in C I can recommend this approach.

Cheers,
SG

DSD-2-PCM -- proof of concept

Reply #13
SebastianG,

Awesome job on the program, my problem was that I was setting 16 or 32 bit depth, not 24, Duh!  I got it to work now with signed 24-bit, little-endian (intel).

I ripped 28 seconds (legal to post) of the Norah Jones - Come away with me - 04 - Feelin' The Same Way which I will attach.  The output 88200Hz PCM has a hiss and static on it as you mentioned in your post.  Is there a command line switch to output at the first stage 352kHz

I am much more of a hardware person then software and when I do software I do low level C not java so I may not be much use on the code front but I would love to take a look for fun.  I will try an figure out how to extract the jar, look at the code, and see if I can tinker with it.

DSD-2-PCM -- proof of concept

Reply #14
I am not an expert but it would be cool to compare to other DSD to PCM converters out there (if possible). There's a DSD plugin for WMP which concerts stereo DSDIFF/DSF to 16-bit 44.1kHz.

As I understand it there's many options you can have when converting DSD to PCM and several different approaches, some good, some not as good.

DSD-2-PCM -- proof of concept

Reply #15
What would be a higher quality approach than 1. converting to 32 bit samples 2. low passing 3. downsampling?

Of course, the choice of a specific low pass filter implies the usual trade-offs (delay, ringing, aliasing, ...). But your actual choice for DSD2PCM probably wouldn't look different than the one you would pick for a regular PCM2PCM decimation, for example 96 kHz -> 48 kHz, to the same target sample rate. Or not?

DSD-2-PCM -- proof of concept

Reply #16
The output 88200Hz PCM has a hiss and static on it as you mentioned in your post. Is there a command line switch to output at the first stage 352kHz

No. That would not even help because the bit order affects the first stage. You could try to add a switch to enable/disable the "pre stage 1 bitreversal".

I will try an figure out how to extract the jar, look at the code, and see if I can tinker with it.

Just unzip it. .jar files are really .zip files with some added meta informations.

rpp3po is right. There's not a lot you can do differently in a mathematical sense than to pick other low pass filters. (Of course, the implementation might differ.) I even documented the properties of the two low pass filters. The paranoid user should be pleased with the 170 dB (IIRC) stopband rejection of the first stage. The lowpass filter's roll off starts at something around 25 kHz (IIRC). That's IMHO high enough because there's already an awful lot of noise just above it. (The DSD propaganda tells you that DSD has a "great dynamic range". That only applies to frequencies below 20kHz which is not surprizing).

Cheers,
SG

DSD-2-PCM -- proof of concept

Reply #17
With the huge caveat that I made no attempt to do this properly or systematically in any way...

Interesting that if you perform the conversion badly (so that all the ultrasonic noise aliases back down into the audible band!) you hear noise that's anything-but-constant!

I know that exactly what you get is an artefact of whatever method you use to "wrongly" downsample - but even so it's interesting that this ultrasonic noise seems to vary so much - both in response to the music, and in some less predictable way.

If this was dither, it would be deemed to be very broken.


I know it's inaudible in normal playback, but if ultrasonic noise has any effect on replay equipment (assuming much of it reaches it - depends on the player) then having it vary is a bad thing - it's another potential cause of distortion which a supposedly "hi res" format can do without.

Cheers,
David.

DSD-2-PCM -- proof of concept

Reply #18
The noise is indeed a problem with the DSD format and, format-wise, something only improved by DSD128 (pushes it up twice as high) and furthermore with DXD (even less noise).

When converting to PCM, my opinion would be that one should have the option to be able to tweak such filter settings as they see fit. If ones objective would be to perform the most accurate "capture" (for lack of a better word) of what's from the original DSD signal (within the frequency range of your PCM output), you should be able to capture the whole thing, noise and all, if you wanted. Even if just for analysis and debugging.

DSD-2-PCM -- proof of concept

Reply #19
The problem with the "most accurate capture" is that DSD players do 'know' that terrible amounts of noise are there and their analog low-pass probably reaches far enough down to compensate somewhat. PCM doesn't have this problem, a good 96 kHz DAC will roughly output at least 40 kHz of perfect analog bandwidth. This would be a capture of the full digital DSD signal, but probably not an accurate capture of the equivalent DSD low passed 'experience'.

The noise is indeed a problem with the DSD format and, format-wise, something only improved by DSD128 (pushes it up twice as high) and furthermore with DXD (even less noise).


Yes, solve the problem by wasting space for insanely high bitrates, to rescue this purely marketing motivated technology, instead of using proper PCM. DSD has not a single advantage over PCM other than DA converter costs. Good DSD DAC can be built pretty cheaply, kind of strange when you're targeting the higher end. But excellent PCM DACs are also available at commodity prices nowadays. Just accept it, the format is dead.

DSD-2-PCM -- proof of concept

Reply #20
The problem with the "most accurate capture" is that DSD players do 'know' that terrible amounts of noise are there and their analog low-pass probably reaches far enough down to compensate somewhat. PCM doesn't have this problem, a good 96 kHz DAC will roughly output at least 40 kHz of perfect analog bandwidth. This would be a capture of the full digital DSD signal, but probably not an accurate capture of the equivalent DSD low passed 'experience'.

No, that's right. But to someone who wants as full a picture (mathemaatically) of the original DSD signal should have access to everything if they want. And then filter it out later if they want.

Quote
The noise is indeed a problem with the DSD format and, format-wise, something only improved by DSD128 (pushes it up twice as high) and furthermore with DXD (even less noise).
Yes, solve the problem by wasting space for insanely high bitrates, to rescue this purely marketing motivated technology, instead of using proper PCM.

Well, I have no comment on that here , but if you were to stay within the DSD "family", those are the "solutions" to the noise problem (although DXD is in its own new category, or you might say it's within the PCM "family" - it is PCM-*based* but with a relaxed anti-alias filter giving it properties/elements of the DSD encoding scheme).

Quote
DSD has not a single advantage over PCM other than DA converter costs. Good DSD DAC can be built pretty cheaply, kind of strange when you're targeting the higher end. But excellent PCM DACs are also available at commodity prices nowadays. Just accept it, the format is dead.

I have no comment about the value of DSD other than that I value it for reasons such as this: we have quite a lot of music mastered and released in the format, and some of it on non-hybrid discs. I happen to value this unique high quality catalog of music (and even on non-hybrid discs, there is the multichannel mix not available on the redbook layer) and thus am interested in converting this music to PCM in the purest way possible.

DSD-2-PCM -- proof of concept

Reply #21
DSD has not a single advantage over PCM other than DA converter costs. Good DSD DAC can be built pretty cheaply, kind of strange when you're targeting the higher end. But excellent PCM DACs are also available at commodity prices nowadays. Just accept it, the format is dead.


I don't even think the converter costs thing is true anymore. 


No, that's right. But to someone who wants as full a picture (mathemaatically) of the original DSD signal should have access to everything if they want. And then filter it out later if they want.


Well they've got the source code and are free to comment out or replace any of the filters they like.

DSD-2-PCM -- proof of concept

Reply #22
I happen to value this unique high quality catalog of music (and even on non-hybrid discs, there is the multichannel mix not available on the redbook layer) and thus am interested in converting this music to PCM in the purest way possible.
I'd suggest keeping the originals as un-converted DSD and just decode to PCM on the fly using a foobar2000 component or something. I'm not sure that one exists currently, but having a library of lossless DSD material is probably preferable to the same material in PCM-decoded form. One less source of loss...

DSD-2-PCM -- proof of concept

Reply #23
Raw DSD means saving about 3 GB per 70 minute stereo album. Kind of a waste when you can save 48kHz files, that should perfectly* preserve the 0-22 kHz band, and only need about 475 MB (FLAC). That's over 2.5 GB wasted, not for discarded but inaudible recorded information but plain quantization distortion, added by an inferior form of digitalization. Why save 2.5 GB of garbage per album? Has there ever been just one solid positive blind test for DSD?

* talk about differences of -110db or lower

DSD-2-PCM -- proof of concept

Reply #24
The problem with the "most accurate capture" is that DSD players do 'know' that terrible amounts of noise are there and their analog low-pass probably reaches far enough down to compensate somewhat. PCM doesn't have this problem, a good 96 kHz DAC will roughly output at least 40 kHz of perfect analog bandwidth. This would be a capture of the full digital DSD signal, but probably not an accurate capture of the equivalent DSD low passed 'experience'.

My Denon player has a setting labled "SACD Filter" which can be set to 50kHz or 100kHz.  I do not know what it is set to because I just got the player used a few days ago and it doesn't have a remote so I do not have access to the menu.  I have ordered a remote and once it comes I will go through and turn off any audio post processing options I can.  It the option is set to 50kHz, changing it to 100kHz may help with some of the noise I am getting.

I am very new to the SACD format but I am interested in picking up a second hand SACD player that outputs DSD over HDMI and trying to grab the DSD signals before they get encrypted and sent over HDMI, it may offer a less altered signal.


I'd suggest keeping the originals as un-converted DSD and just decode to PCM on the fly using a foobar2000 component or something. I'm not sure that one exists currently, but having a library of lossless DSD material is probably preferable to the same material in PCM-decoded form. One less source of loss...

My plan exactly, I will keep the originals for archival purposes and make a copy that is converted it to a lossless PCM format like FLAC if a good conversion becomes available.

Raw DSD means saving about 3 GB per 70 minute stereo album. Kind of a waste when you can save 48kHz files, that should perfectly* preserve the 0-22 kHz band, and only need about 475 MB (FLAC). That's over 2.5 GB wasted, not for discarded but inaudible recorded information but plain quantization distortion, added by an inferior form of digitalization. Why save 2.5 GB of garbage per album? Has there ever been just one solid positive blind test for DSD?

* talk about differences of -110db or lower

A couple things here...
48kHz files do not preserve 0-22kHz band perfectly,  the brick wall effect means that the high pass filters have to cut into much lower frequencies for seamless playback.

Storage is cheap nowadays and will keep getting cheaper, I keep all my music on a NAS server.  You can buy a 1.5TB drives for less then $100 each which is about 500 SACD albums depending how many tracks they have one them and over then next few years it will cost even less to store.

There is one important feature of SACDs that CD's do not offer, multi channel audio.  Many albums do not have any other multichannel format like DVD-A, blu-ray so SACD is the only option.

Also the storage could be greatly reduced is a loss less container format was made to store the raw DSD channels.