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: SACD DSD lossless to FLAC (Read 18378 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

SACD DSD lossless to FLAC

Hello

SACD DSD is pulse density modulation, CD PCM is pulse code modulation.
Can there really be a lossless conversion from DSD to PCM?

Yes it can, and anyone can verify it.
I have tested it with DSD64.

Software:
foobar2000 1.4.4
foo_input_sacd-1.4.3
FLAC 1.3.3 x64
Musepack SV8 1.30.0

Settings:
SACD Converter DSD2PCM Mode: Direct (32fp, 30kHz lowpass)
"DoP for Converter" - Off

Converting DSD source to FLAC creates 24/44.1 files - around 4,3 times smaller than DSD source file.

FLAC compression -8
Musepack -standard (I use it because i like it, it doesn't matter which codec is used)

Foobar2000 displays Audio MD5 for FLAC files but not for SACD ISO or DSD files.
So there is now way to compare it.

But

Converting DSD Source -> FLAC -> Musepack -> FLAC

and

Converting DSD Source -> Musepack -> FLAC

Give us opportunity to check the Audio MD5 in final FLAC files.
And to my surprise final FLAC's all have the same Audio MD5 checksum.

So it means that converting DSD Source to FLAC is 100% lossless conversion.


Paweł

Re: SACD DSD lossless to FLAC

Reply #1
Um, I might be wrong, but doesn't "SACD Converter DSD2PCM" convert DSD to PCM?
That process is lossy in the way that it can't be used in reverse to get the same input file. Especially with lowpass filter.
As far as I am aware, DSD to PCM is lossy, but! you can use commandline wavpack to compress DSD files into wv files without conversion into PCM.
Error 404; signature server not available.

Re: SACD DSD lossless to FLAC

Reply #2
And to my surprise final FLAC's all have the same Audio MD5 checksum.

So it means that converting DSD Source to FLAC is 100% lossless conversion.
I fail to see how comparing the MD5s of different FLAC files proves that the conversion to FLAC was lossless. Perhaps you can try to explain it again using a different wording?
Music: sounds arranged such that they construct feelings.

Re: SACD DSD lossless to FLAC

Reply #3
ktf

1 DSD source file converted:

First conversion
Converting DSD Source -> FLAC -> Musepack -> FLAC

Second conversion
Converting DSD Source -> Musepack -> FLAC

Both output FLAC files have same MD5 cheksum.



itisljar


Replaygain has exactly the same values for DSD source and FLAC encoded directly from DSD source.
I understand that DSD2PCM convert and it stands to reason that I check md5 of that output as source not DSD.
But exactly same values with replaygain say that this is very "exact" conversion.
Making 16 bit flac output gives differences from 0.000002 to 0.000012 peak values, 24 bit flac's are exactly the same.
I have tested also DSD256 now with same results.
If this is not lossless than it must be very very close.
I need pcm files since I use WASAPi output and have a headphone crossfeed in f2k dsp chain.
Can't use it with dsd, thus having pcm from dsd with same quality is what I need.
What I'm really looking for is empirical way to compare source to encoded flac.
If anyone has a better way to do it I would love to test it and see how close it gests.

Thank you.


Re: SACD DSD lossless to FLAC

Reply #4
There are free applications (see below) available to convert single-rate DSF>DFF, DFF>24/88 PCM, then PCM>DFF.  If lossless, wouldn't the MD5 be the same for the two DFF files?  They were not for me.

TASCAM Hi-Res Editor: https://tascam.com/us/product/hi-res_editor/download
PCM-DSD Converter: https://pcmdsd.com/Software/PCM-DSD_Converter_en.html
Free DSD64 (DSF) Sample Files: http://www.2l.no/hires/

Re: SACD DSD lossless to FLAC

Reply #5
ktf

1 DSD source file converted:

First conversion
Converting DSD Source -> FLAC -> Musepack -> FLAC

Second conversion
Converting DSD Source -> Musepack -> FLAC

Both output FLAC files have same MD5 cheksum.

itisljar

Replaygain has exactly the same values for DSD source and FLAC encoded directly from DSD source.
...
You compare the same things.
foobar does the same thing on both conversations plus the lossless flac step afaik.
First conversion
Converting DSD Source -> PCM -> FLAC -> Musepack -> FLAC

Second conversion
Converting DSD Source -> PCM -> Musepack -> FLAC

Also my guess is foobars Replaygain doesn't scan the DSD but a PCM conversation of it so it has to be the same as the flac.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: SACD DSD lossless to FLAC

Reply #6
ktf

1 DSD source file converted:

First conversion
Converting DSD Source -> FLAC -> Musepack -> FLAC

Second conversion
Converting DSD Source -> Musepack -> FLAC

Both output FLAC files have same MD5 cheksum.

itisljar

Replaygain has exactly the same values for DSD source and FLAC encoded directly from DSD source.
...
You compare the same things.
foobar does the same thing on both conversations plus the lossless flac step afaik.
First conversion
Converting DSD Source -> PCM -> FLAC -> Musepack -> FLAC

Second conversion
Converting DSD Source -> PCM -> Musepack -> FLAC

Also my guess is foobars Replaygain doesn't scan the DSD but a PCM conversation of it so it has to be the same as the flac.


You are probably right.

Re: SACD DSD lossless to FLAC

Reply #7
There are free applications (see below) available to convert single-rate DSF>DFF, DFF>24/88 PCM, then PCM>DFF.  If lossless, wouldn't the MD5 be the same for the two DFF files?  They were not for me.

TASCAM Hi-Res Editor: https://tascam.com/us/product/hi-res_editor/download
PCM-DSD Converter: https://pcmdsd.com/Software/PCM-DSD_Converter_en.html
Free DSD64 (DSF) Sample Files: http://www.2l.no/hires/

Thank you, will check them out.

Re: SACD DSD lossless to FLAC

Reply #8
The conversion is not lossless, and your test is flawed the moment you use fb2k on something that cannot be contained in 32-bit floating-point - that is what fb2k uses internally. That is, anything played back by foobar2000 - or converted by foobar2000 - is first projected down to what can be fit in a 32-bit floating-point PCM file, whether that processing is lossy or lossless. When converting from DSD-in-wavpack (see below), it warns you about the lossiness.

Using flac further converts to 24-bit integer, so there is a simple way to decide that the conversion to FLAC is lossy: compare the FLAC to a 32-bit floating-point .wav, and compare.

Now the 32-bit floating-point is not in itself lossless. But it can contain everything a 24-bit integer can, so had the 24-bit been lossless, they would have been identical.


WavPack has a mode to compress "undecoded" DSD losslessly, but you cannot do that by way of fb2k (because fb2k will decode it first and then pass it on, creating something bit-identical to a 32-bit floating-point PCM which isn't lossless).
The command-line to compress it:
wavpack.exe filename.dsd
returns a file filename.wv . Or instead give options:
wavpack.exe -mh --import-id3 filename.dsd
The latter transfers id3v2.3 tags from the DSD (not yet v2.4); the "h" improves compression; the "m" writes an audio md5 which you can read off in foobar2000. It will not match the FLAC md5.

But the FLAC md5 is the decoded PCM - which the DSD md5 is not (simply because that would be an md5 of a lossy conversion!)
And you cannot use foo_bitcompare, because that will not compare the DSD with the 32-bit floating-point file; it will first convert the DSD to the 32-bit floating-point and compare that to another 32-bit floating-point with the same audio.


There is no reason to use FLAC either. Some sizes:
30.9 MB for 2L-056_03_stereo_DSD64.dsf from the above 2L testbench
14.7 MB for the .wv compressed with -h
115 MB for a .wav (floating-point) as converted by fb2k from the .wv; it warns you that it isn't lossless!
61.7 MB for a .wv created from the previous file.



Re: SACD DSD lossless to FLAC

Reply #9
... wait. There is something here that just doesn't hold up. fb2k reports DSDs as if they were 24 bit and converts them as such as well. No difference to fb2k-generated 32-bit float - but the difference to ffmpeg-generated 32-bit float than can be explained by ...

What is going on?

Re: SACD DSD lossless to FLAC

Reply #10
No difference to fb2k-generated 32-bit float - but the difference to ffmpeg-generated 32-bit float than can be explained by ...
Different DSD-to-PCM converters, obviously.

Re: SACD DSD lossless to FLAC

Reply #11
You can't even convert 32-bit WAV/AIFF to FLAC, how can you convert DSD to it?

Re: SACD DSD lossless to FLAC

Reply #12
DSD can only be converted to FLAC if you convert it to PCM first, which is a lossy process. If you want to compress DSD losslessly, the only options are the incredibly slow reference codec, DST, and the way speedier WavPack.

Re: SACD DSD lossless to FLAC

Reply #13
... wait. There is something here that just doesn't hold up. fb2k reports DSDs as if they were 24 bit and converts them as such as well. No difference to fb2k-generated 32-bit float - but the difference to ffmpeg-generated 32-bit float than can be explained by ...

What is going on?

To be honest I hate DSD but since the cd versions have lower dynamic range masters then what they put on sacd.
It's hard not go for them, but they are pain in the... to use them even for end user.

Being stubborn I have found very useful tool "sacd-0.10.7"
It uses "Weiss Saracon" to convert dsd to pcm.
It does so in 2pass after first pass it calculates gain with "r128gain" and applies calculated gain to final output.
It's minimalistic, easy and simple to use.
Supposedly Saracon is one of the best converters.

Re: SACD DSD lossless to FLAC

Reply #14
Supposedly Saracon is one of the best converters.

Maybe… but the difference between those converters is probably miles beyond our threshold of hearing so I wouldn't really care about it. You probably have to rely on metrics to make any difference. Archimago did one comparison several years ago:

http://archimago.blogspot.com/2015/04/analysis-dsd-decoders-2015-windows-mac.html

(this test is a bit outdated: foobar2000's wasn't tested with the more popular and advanced foo_input_sacd; but Weiss Saracon's converter was included: it wasn't already the best converter at this time. In the meantime EZ CD Audio Converter also add its own converter with two quality modes — could be worth to check it).

Audiofools with a lot of money to spend may only trust HQ Player (which costs up to 3,561.20 USD… only for resampling  ;D ) and insanely slow algorithms. It was also tested by Archimago:
http://archimago.blogspot.com/2019/02/measurements-look-at-hqplayer-325.html

Re: SACD DSD lossless to FLAC

Reply #15
For completenes i use SoX for DSD decoding. Since it uses SoX resampling treating DSD as 1bit fed to it i can use all options i got used together with SoX. I guess used together with the ultra value and its even higher stoppband it theorertical outperforms the other solutions.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: SACD DSD lossless to FLAC

Reply #16
To be honest I hate DSD but since the cd versions have lower dynamic range masters then what they put on sacd.
SACD in a nutshell: its only reason to be (from consumer's point of view), is those few better masters they made only to sell it. Wonder if that remastering happened more than a few times to fool consumers into thinking that the format itself sounds better.

So in *checks notes* 2004 (when SACD was halfway dead already) there came about the "DXD" format that was 352.8 kHz/24 bits. If you go to http://www.2l.no/hires/ you will see that most of those files are originally DXD.
Which begs the question really: in converting DSD to 352.8/24 FLAC, how much is lost of anything that was in the original 352.8/24 PCM?
I.e. considering the lossy roundtrip PCM->DSD->PCM and comparing to the original PCM: does the second conversion discard information that isn't already wrong? Sure there is a chance of another roundoff error, but there shouldn't be more. Yet the foo_bitcompare results are more on par with MP3'ing a CD ...
(Compare to precisely that: Make an MP3 from CDDA, and decode the MP3 to PCM; if you first decode to 32-bit float and then to 16-bits integer, the second conversion is lossy, but what does it discard? There shouldn't have been anything in bits 17 ff, should it? Assume for simplicity that peak volume is meticulously kept so that no clipping is introduced ...)

Studio processing to end-user format is anyway not supposed to be a lossless operation.

Re: SACD DSD lossless to FLAC

Reply #17
To be honest I hate DSD but since the cd versions have lower dynamic range masters then what they put on sacd.
SACD in a nutshell: its only reason to be (from consumer's point of view), is those few better masters they made only to sell it. Wonder if that remastering happened more than a few times to fool consumers into thinking that the format itself sounds better.


Don't even get me started :)
I think that they convert files around in masters without really caring about how much is lost.

guruboolez, thank you for the links, you have made my day :)
Yes, those programs make overkill quality files.
I look at it like "do it once, and forget".
Studio quality 16/44.1 audio.

Yes, there is a lot of nonsense when it comes to audiofools, worst is that marketing slogan has more power than technical data to some.
But it's a good way of making money.

Re: SACD DSD lossless to FLAC

Reply #18
Supposedly Saracon is one of the best converters.

Maybe… but the difference between those converters is probably miles beyond our threshold of hearing so I wouldn't really care about it. You probably have to rely on metrics to make any difference. Archimago did one comparison several years ago:

http://archimago.blogspot.com/2015/04/analysis-dsd-decoders-2015-windows-mac.html

(this test is a bit outdated: foobar2000's wasn't tested with the more popular and advanced foo_input_sacd; but Weiss Saracon's converter was included: it wasn't already the best converter at this time. In the meantime EZ CD Audio Converter also add its own converter with two quality modes — could be worth to check it).

Audiofools with a lot of money to spend may only trust HQ Player (which costs up to 3,561.20 USD… only for resampling  ;D ) and insanely slow algorithms. It was also tested by Archimago:
http://archimago.blogspot.com/2019/02/measurements-look-at-hqplayer-325.html

Archimago's latest tests showed that ESS's flagship ES9038 chips always degrade DSD input, any upsampling effort with external software is useless. Read the links sequentially for details:
https://archimago.blogspot.com/2021/10/measurements-look-at-dsd-and-using-sox.html
https://archimago.blogspot.com/2021/10/measurments-dsd-testing-with-sox-dsd.html
https://archimago.blogspot.com/2021/10/revisiting-teac-ud-501-dac-2013-thdn.html
For completenes i use SoX for DSD decoding. Since it uses SoX resampling treating DSD as 1bit fed to it i can use all options i got used together with SoX. I guess used together with the ultra value and its even higher stoppband it theorertical outperforms the other solutions.
Something like this:
https://www.audiosciencereview.com/forum/index.php?threads/digital-filter-game.23795/post-810355
More like flexibility rather than extremely slow settings.


Re: SACD DSD lossless to FLAC

Reply #20
Something like this:
https://www.audiosciencereview.com/forum/index.php?threads/digital-filter-game.23795/post-810355
More like flexibility rather than extremely slow settings.
Nice! I only have DSD64 and indeed keeping to much bandwith makes no sense. 88.2kHz sampling and the 74% bandwidth is already plenty.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: SACD DSD lossless to FLAC

Reply #21
Compare to precisely that: Make an MP3 from CDDA, and decode the MP3 to PCM; if you first decode to 32-bit float and then to 16-bits integer, the second conversion is lossy, but what does it discard? There shouldn't have been anything in bits 17 ff, should it?
I don't know the details of mp3 inner workings but I'd say it should. I assume that in the encoded form mp3 is a bunch of parameters, that during decoding are used to reconstruct a PCM which should be perceptually similar to the input. If there was an additional constraint, that the values of the parameters are such that the decoded PCM falls within 16 bit bounds, the whole thing would be more complex and probably less efficient, size-wise.

Re: SACD DSD lossless to FLAC

Reply #22
I don't know the details of mp3 inner workings but I'd say it should.
I was unclear. There is nothing in the original source below 16 bits. Sure an MP3 will have noise below that if it makes for better compression at given quality, or better quality at same file size.

Question is: Given that the MP3 comes from CDDA,
* Decoding the MP3 to [big number] bits is surely transparent.
* Now reduce further to 16 bits. Would there be any value in what you discard?

To any answer based on "16 is more than enough": Let's repeat the question then with an N-bit original signal for some suitable N<16. Like 12? I am not sure what the answer would be, I'm too lazy to do all the testing (and it would be better done by younger ears I think).

Re: SACD DSD lossless to FLAC

Reply #23
I was unclear. There is nothing in the original source below 16 bits. Sure an MP3 will have noise below that if it makes for better compression at given quality, or better quality at same file size.

Question is: Given that the MP3 comes from CDDA,
* Decoding the MP3 to [big number] bits is surely transparent.
* Now reduce further to 16 bits. Would there be any value in what you discard?

To any answer based on "16 is more than enough": Let's repeat the question then with an N-bit original signal for some suitable N<16. Like 12? I am not sure what the answer would be, I'm too lazy to do all the testing (and it would be better done by younger ears I think).
Since it is a DSD and flac thread I think it can be explained in this way:

Everyone knows that DSD only has 1-bit but it can have more than 20 effective bits below 22kHz. It is achieved by averaging a lot of 1-bit samples to approximate the desired amplitude value. All complexities are in the encoding process -- deciding how to arrange a bunch of 1-bit samples to achieve the desired result.

How relevant is it to your question? Encoding a 16/44 file to MP3, and decode to 16/44 vs a higher bit-depth?

I attached the original 16/44 file and the mp3 file, and here are the results of different decoding settings, all were done with foobar2000. foobar2000 only provides a strongly shaped dither, so I also used Case's Smart dither in the illustration. The original file contains a -120dB 3kHz tone. Among the decoded files, the undithered 16-bit file showed obvious amplitude error.
X

Zoomed screenshot to show the 3kHz tone's amplitude.
X

The results can be interpreted in this way: if the decoded 16-bit file is dithered from a higher bit-depth, the averaged effective bit-depth in the 16-bit decoded file can be preserved in a better way.

Re: SACD DSD lossless to FLAC

Reply #24
Hi, let me put some pictures too.
Source from Saracon Signal Generator 1kHz test tone (included in archive).
Encoded to WAV with Saracon, foobar2000 (dither in converter when used), EZ_CD_Audio_Converter.
Click on the picture to see the software and options used.




A picture is worth a thousand words.