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: Why can I convert dsd in a single shot, but not flac? (Read 5292 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Why can I convert dsd in a single shot, but not flac?

So I downloaded some dsd files (https://www.nativedsd.com/product/rs0705-frederic/
Chopin on harp sounds amazing! If you like Chopin, listen to the full-length samples on
that pape).  I had been using ffmpeg to convert from flac to wavpack in one command, but
given how much better wavpack 5.0 handles dsd, I gave that a shot.

The command "wavpack -hhx3my *.dsf" converted them in one shot. I didn't have to convert
them to wav first with ffmpeg. 

Why do I have to decompress flac files to wavpack them, but not dsd files?

The original dsd files sound identical to the wv files, and it also sounds like wavpack
is preserving the binaural surround.  Is it?

Thank you.
Music lover and recovering high end audiophile

Re: Why can I convert dsd in a single shot, but not flac?

Reply #1
DSD is already uncompressed. DSD is a trade name for PDM, which is a completely different way of representing audio from PCM, which is what WAV files usually contain. You must decompress FLAC to PCM before you can compress it again. Both FLAC and WavPack are lossless, so yes, WavPack is preserving the binaural sound in the DSD files. The whole point of lossless compression is to preserve the original data without making any changes. FLAC only supports PCM, so it can't compress DSD audio at all.

Re: Why can I convert dsd in a single shot, but not flac?

Reply #2
Thank you @Alereon.   That makes sense.

When I did 'wvtag -i *.dsf *.wv', wvtag complained about the dsd files, but the wavpack files were populated with the dsd file's headers.  Doing 'wvtag -i *.flac *.wv' just gives me errors. 

Does that also have to do with them being PCM files?
Music lover and recovering high end audiophile

Re: Why can I convert dsd in a single shot, but not flac?

Reply #3
FLAC and WavPack are competing lossless compression standards. You can't use wvtag on FLAC files. You have to decompress the FLAC files back to PCM (using WAV as the container) and then compress the raw PCM again using WavPack. Unless WavPack is making the files significantly smaller than FLAC or you just want all your audio in one format, there is no benefit to transcoding from FLAC to WavPack (or vice versa).

Re: Why can I convert dsd in a single shot, but not flac?

Reply #4
General talk first:

All the lossless codecs support
* encoding LPCM from some uncompressed stream or file format
* decoding their own format
That is nearly all: The exception is that WavPack supports uncompressed PWM in two DSD file formats and from headerless raw stream.  (And then some experimental builds have done this or that, I skip the details.)

As far as I understand, even those which recompress their own format, decode first and re-encode: if you want to convert from [codec x] to [same codec x, different settings] you have to decompress first. If you want to convert from codec x to codec y, you also have to do that.
Both FLAC and WavPack offer libraries that other converters can call, to do that conversion - rather than building their own decoder for the competing format. If author of codec y wanted to facilitate decoding from codec x, that would be the way to do it. And ...
* Monkey's Audio has a GUI that allows for decoding of FLAC and WavPack. How it works? By including official FLAC and WavPack tools (their licenses permit that!)
* Refalac can do the same. Indeed, refalac's decode command can split a FLAC/WavPack/TAK with cuesheet into individual .wav files - but then it uses the official FLAC/WavPack libraries (that you as user have to provide!).
* The semi-official FLAC/WavPack front-end was two examples of a ton of front-ends that a HA user created from some more general encoding front-end. There was also a multi-encoder that could handle this - the front-end would then call the official tools.

Re: Why can I convert dsd in a single shot, but not flac?

Reply #5
When I did 'wvtag -i *.dsf *.wv',
You could have transferred upon encoding with the --import-id3 option (sometimes you would have to use the --allow-huge-tags too). But in either case it has to be ID3v2.3. Otherwise ... use Mp3tag.
Worth mentioning is that DSD, FLAC and WavPack use three distinct tag formats. (ID3, Vorbis comments and APEv2.) So if you want an application that can copy tags between the files, it would have to be able to read all tag formats. Mp3tag does. The WavPack executables read and write APEv2 (as that is what WavPack uses) and also ID3v2.3, but not ID3v2.4. FLAC can read some foreign tags too, but - as far as I know - not APEv2


Unless WavPack is making the files significantly smaller than FLAC or you just want all your audio in one format, there is no benefit to transcoding from FLAC to WavPack (or vice versa).
There are some reasons to choose this over that. WavPack has a hybrid lossless/lossy format where one can copy WavPack files without correction files for portable use. I don't use it (FLAC is my codec of choice in fact). Some features are slightly different too. For example, FLAC has tags at the beginning (will index faster, good for streaming where the application doesn't have access to the entire file); WavPack has tags at the end (will not need full file re-write even if you add a big picture).

And they don't support exactly the same inputs either. WavPack supports floating-point files, and is the only end-user codec that will compress DSD - but it does not support AIFF files (FLAC does).

Re: Why can I convert dsd in a single shot, but not flac?

Reply #6
There are some reasons to choose this over that.
Sure, but since he's going from FLAC to WavPack, we can conclude that he isn't using any of the WavPack-specific features like PWM and floating-point input, since his existing FLAC files can't possibly contain such audio formats. ;)

Re: Why can I convert dsd in a single shot, but not flac?

Reply #7
Oh, one thing or two:

I had been using ffmpeg to convert from flac to wavpack in one command, but
given how much better wavpack 5.0 handles dsd, I gave that a shot.
[...]
The command "wavpack -hhx3my *.dsf" converted them in one shot. I didn't have to convert
them to wav first with ffmpeg. 

You might have done something lossy here. Not likely that anyone will hear the differences, but ...

** The download is available in FLAC or one of three DSD formats. Assuming you downloaded DSD (presumably as .dsf as you indicated):
* DSF files contain uncompressed pulse width modulated
* If you converted your .dsf to PCM, then that is lossy. Apparently, most applications that support such conversion will output to some high-rez PCM format, which will make the file much bigger. This is not due to decompression, but due to the formats not being the same - and the conversion to PCM being done in high resolution.
* If you FLAC'ed the PCM files and then converted them to WavPack, then that could be done losslessly. As long as the bit depth was 16 or 24 bits, ffmpeg will do it losslessly.
* If you ffmpeg'd the DSD files to WavPack, that is not lossless, and ffmpeg will not warn you.
(ffmpeg is not designed to be a tool for lossless manipulation, it just happens to do this or that losslessly - "this or that" includes manipulation of 16-bit or 24-bit FLAC/WavPack files with the appropriate sample rates, but once you start fiddling with 8 or 32, expect the unexpected.)

** If you downloaded the FLAC files:
Then they are not DSD/PWM at all.

The website says that the recording was made as DSD256. If true, that means it was recorded with a pulse width modulating ADC.
Also, as far as I know there is no mixing software that operates on PWM, so if it has been mixed - apart from cutting down to length - it has been converted to PCM. In which case the DSDs sold are not as "native" as they want you to believe, they have been converted first to PCM (lossy, but transparent) and from PCM (ditto, as long as they avoid the possible clicks in track transistions, wouldn't happen to PCM).

There are vendors that sell DSDs that are PCM sourced. Look at the free downloads from http://www.2l.no/hires/ - in the rightmost column you see the original format. "DXD" has nothing to do with DSD, it is a fancy name for 352.8 kHz / 24 bit PCM. Converting these to DSD before selling them, makes only sense to satisfy a demand that isn't rational.


Oh, and the command:
"wavpack -hhx3my *.dsf"
* The "y" merely auto-answers "yes" to all overwrites. Don't use it if you don't mean it!
* Consider a "v" for verify as well. Since the "m" makes it take the time to compute an MD5 checksum, then it doesn't take much extra time to verify that the file was written.
* Consider also --import-id3 and possibly --allow-huge-tags. (But, if there are ID3v2.4, you would anyway have to use e.g. Mp3tag to copy tags.) And with WavPack 5.5.0 you can rename the exe for drag and drop use. Like this: https://hydrogenaud.io/index.php/topic,122626.msg1012159.html#msg1012159
* If you use -hhx3 on your usual WavPack encoding, then leave it like this. But for DSD, there are only the normal and high modes, so -hh is identical to -h; and, there are no -x, so the x3 is silently ignored.
(But you probably shouldn't use x3 in your usual WavPack encoding - it doesn't seem to be the best speed/size trade-off neither for CDDA nor for high-resolution PCM. I did some testing on that (not on classical music though!); Although -x4 is sloow, you get better savings per second increasing -x3 to -x4 than you got by increasing -x2 to -x3; and for high resolution, also better than going -x1 to -x2. This presuming you don't use -f.)

Re: Why can I convert dsd in a single shot, but not flac?

Reply #8
DSD domain digital editing beyond very basic stuff like trim, invert, reverse, delay, channel splitting and so on requires more than 1 bit. Even with native sample rate processing (e.g. 2.8224MHz), a digital filter is still required to remove high frequency noise beyond fs/64 or so, to avoid high frequency noise in the original DSD file overloading the modulator when the signal is re-encoded to DSD again. "Noise" in the original file is being treated as "signal" and cannot be reused for noise shaping.

DSD can be processed in analog domain and re-digitized to DSD again, to justify the "no PCM processing" claim, but it is common sense that with analog, nothing can be lossless, even in a straight wire DAC -> ADC chain with no processing. On the other hand, copying DSD files or converting them to and from WavPack is mathematically lossless.