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 to FLAC (Read 82163 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: SACD to FLAC

Reply #25
What version are you running?
https://sourceforge.net/projects/sox/files/sox/14.4.2/sox-14.4.2-win32.zip

okay so from reading another thread:
https://www.computeraudiophile.com/forums/topic/38313-converting-dsd-to-pcm/

Do I have to install the DSD patches? I'm running windows and trying to figure out what files from the following site to download and where to install/place them:
A while back Mans Rullgard added support to SoX for DSD resampling. It applies the SoX resampling to 1bit DSD directly. https://github.com/mansr/sox



A cursory glance at that computeraudiophile thread shows that someone found this link from which the file sox-dsd-win32-MSVC.zip can be downloaded. I downloaded a DSD64 (which I believe is the kind of encoding SACD's use; correct me if I am mistaken) file from here and managed to convert it to FLAC with the included SoX.exe executable included in the ZIP file (extract all of the compressed file first).

I used the following batch file in Windows 10 with the executable in question:

Code: [Select]
for %%a in ("YourInputFolderHere\*.dsf") do sox -V3 -S -D "%%a" -b 16 "YourOutputFolderHere\%%~na.flac" rate -v 44100
pause

I had to include the "-D" parameter to stop SoX from dithering; I'm not sure why it was automatically doing this. Maybe it's better? I'm not too sure.

Anyway, this is if you want to encode it in standard CDDA quality (16-bit stereo, 44.1kHz). You can change the bit depth and sampling frequency to whatever you want the FLAC output to be.
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

 

Re: SACD to FLAC

Reply #26
You need the SoX version of the Mans R. code as compiled exe only. The sox-dsd-win32-MSVC.zip from over there should do it https://audiodigitale.eu/repo/sox/

LOL! Just when i typed that blurry_light answered.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: SACD to FLAC

Reply #27
I had to include the "-D" parameter to stop SoX from dithering; I'm not sure why it was automatically doing this. Maybe it's better? I'm not too sure.
SoX does dither when going to 16bit because it is common practise and not because it is bad. If you ask mathematical skilled people they even recommend 24bit to be dithered when coming from the 32bit integer SoX routines.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: SACD to FLAC

Reply #28
I had to include the "-D" parameter to stop SoX from dithering; I'm not sure why it was automatically doing this. Maybe it's better? I'm not too sure.
SoX does dither when going to 16bit because it is common practise and not because it is bad. If you ask mathematical skilled people they even recommend 24bit to be dithered when coming from the 32bit integer SoX routines.

Yes -- that's when going from 32-bit PCM to 24-bit PCM. But this is PDM to PCM; is dither still justified here? I'm admittedly not familiar with the ins and outs of PDM so maybe SoX's default behavior is acceptable.

EDIT: I think I see what you mean; so because SoX uses a 32-bit internal routine (regardless of the *actual* source being PDM, it uses 32-bit PCM internally), and you request 16-bit, this is why it dithers?
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: SACD to FLAC

Reply #29
Thank you both...I have been playing around with that "other" file but wasn't sure if it was "official" or trusted. Was literally just about to write how I got it working.

Thanks for the responses.

After playing a bit, a couple more questions of advice. When doing what I'll call a standard convert:
sox 01.dsf -b 16 01.wav rate -v -s 44100

I get output files that when looked at in Audacity the peaks never go above or below 0.5 (see attached "normal").
I've read that PDM to PCM converting always loses volume and therefore it could be added back in.
Do you think it's worth trying to boost them a little bit - in theory could anything be gained other than having to turn the volume knob a little less?

I tried using both gain and volume adjustments but any positive number yields clipping. When looking at the output files in audacity...the gained and clipped files look identical to the not gained ones and doesn't show any clipping. When looking at the command prompt side of (attached "gain6") it looks like the input file was gained...not the output. I guess I'm wondering how to gain the output file.
sox 01.dsf -b 16 01.wav gain 6 rate -v -s 44100
or
sox 01.dsf -b 16 01.wav vol 6dB -v -s 44100

The only thing I could do that wouldn't clip was use --norm
sox --norm=-1 01.dsf -b 16 01.wav vol 1dB -v -s 44100

Am I getting the gain coding wrong?

Re: SACD to FLAC

Reply #30
Wow, I'm dumb. Simply changing it from
sox 01.dsf -b 16 01.wav gain 6 rate -v -s 44100
to
sox 01.dsf -b 16 01.wav rate -v -s 44100 gain 6
I believe did it.

Thanks again for the help

Re: SACD to FLAC

Reply #31
Last question: Is there a way to get sox to create a log file so I can check for errors later in case I accidentally hit a key and close the batch script...for example when waking the computer from a screen saver if I walk away after a big batch.

I tried adding > log.txt but that yielded and empty text file and I couldn't find any options in the Sox command line help section.

Re: SACD to FLAC

Reply #32
Last question: Is there a way to get sox to create a log file so I can check for errors later in case I accidentally hit a key and close the batch script...for example when waking the computer from a screen saver if I walk away after a big batch.

I tried adding > log.txt but that yielded and empty text file and I couldn't find any options in the Sox command line help section.

Try adding ">> output.txt", with two > symbols, at the end of the main loop of the script.

So, for example (here we let SoX dither, as explained before)

Code: [Select]
for %%a in ("YourInputFolderHere\*.dsf") do sox -V3 -S "%%a" -b 16 "YourOutputFolderHere\%%~na.flac" rate -v 44100 >> output.txt
pause
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: SACD to FLAC

Reply #33
No dice but thanks for idea. I can't remember if command prompt has a mode to write everything to a text file. I know for Lame, FLAC and robocopy for example, the .exe file itself has a "logging" option.

I noticed that if you just run it silent, then errors are quite obvious - so I'll do that I guess.

Re: SACD to FLAC

Reply #34
No dice but thanks for idea. I can't remember if command prompt has a mode to write everything to a text file. I know for Lame, FLAC and robocopy for example, the .exe file itself has a "logging" option.

I noticed that if you just run it silent, then errors are quite obvious - so I'll do that I guess.

Hm, I just tried it and it doesn't seem to work. However, if you remove the "pause" at the end and have it write both standard output and standard error from the command prompt or PowerShell, you can have a log file.

The batch file would be

Code: [Select]
for %%a in ("YourInputFolderHere\*.dsf") do sox -V3 -S "%%a" -b 16 "YourOutputFolderHere\%%~na.flac" rate -v 44100

And in the command prompt or PowerShell, you'd invoke it as

Code: [Select]
PS DirectoryHere> BatchFile.bat > log.txt 2>&1

Now log.txt will have all the output that was generated (but there's no console output in real time; this is why the "pause" part was removed, so when you get back the command prompt, you know it's finished).
Lossless: flac --best --verify
Lossy: opusenc --bitrate 160

Re: SACD to FLAC

Reply #35
Thanks... I'll try that Saturday when I get back from my mini vacation to the White Mountains. Cheers!


Re: SACD to FLAC

Reply #37
DSD support in SoX is great. I think this means that we can finally abandon all worries about possibly doing something "not right" with DSD -> PCM conversion.
a fan of AutoEq + Meier Crossfeed

Re: SACD to FLAC

Reply #38
You can also convert to WavPack and maintain the DSD format, and the WavPack libraries also support DSD -> PCM conversion by default in apps that don't request the DSD format on decode. Probably not what you were concerned about, though.

Re: SACD to FLAC

Reply #39
You can also use ffmpeg.


Re: SACD to FLAC

Reply #41
"best quality" goal is ill-defined. When resampling is involved, one can always trade even more CPU resources for even more precision, but it will become pointless at some point, and where does this point stand is subjective. 
If the goal is to keep it audibly indistinguishable from the source, then you don't even need to use FLAC, a lossy format would suffice as well.

Perhaps it's worth adding a specific goal, for example, S/N ratio of resampling of ≥140 dB in <20kHz range.

That said, for all practical purposes, converting DSD to FLAC in foobar2000 while resampling with SoX resampler to 44100Hz should produce completely fine results, as long as there's no clipping. All other settings can be left as defaults.
Make sure to check "don't reset DSP between tracks…" if converting from a tracks view, otherwise resampling could be not gapless.

How  to do it??

I want to convert a super audio cd to flac 16 bits, 44 khz.

What should I to do?

Thanks!!!!

Re: SACD to FLAC

Reply #42
If you already have DSD files, then foobar2000 with the foo_input_sacd component installed will be a relatively easy way to convert to PCM. Note that working with a  stereo source is a little less complicated than a multichannel x.1 source:  for multichannel you have to decide how LFE will be treated (it may or may not need +/-10dB  -- it's complicated). 

Also, in both cases, you have the option to increase the PCM output volume up to +6 dB (because DSD-->PCM can result in a PCM file as much as 6dB 'quieter' than a native PCM mastering) .  If you do so, make sure you don't cause the resulting file to be clipped.  Alternately, just convert at +0 dB (no increase) and use replaygain with the files...or just turn it up the old fashioned way!

If you need to rip SACDs to files, that's an entirely separate process and involves using specific models of SACD hardware, plus special ripping software. 

https://audiophilestyle.com/forums/topic/28569-sacd-ripping-using-an-oppo-or-pioneer-yes-its-true/





Re: SACD to FLAC

Reply #45
Hi.

I'm trying convert a SACD.iso into FLAC using foobar2000.

The SACD.iso is playing fine. , but I'm always getting this message when I try to convert:



What am I missing to convert lossless ?

Please Help !
Tommy


Re: SACD to FLAC

Reply #47
Thanks for your reply.
So does this mean that the output from DFF to FLAC will be lossless even though the warning says it won't ?
I just want to be sure.
This warning shows up only for DFF to FLAC or DFF to WAV, but not for DFF to MP3 where it should come up which is a little confusing.

Another thing is that the output file is much larger than the input file and I thought it should be smaller.

Input DFF: 19 MB
Output FLAC: 30 MB coverted with foobar2000
Output FLAC: 50 MB coverted with dBpoweramp

Thanks again,
Tommy

Re: SACD to FLAC

Reply #48
Please disregard what I wrote about the output file size.
Sorry about that, I've must have done something wrong.
Please just confirm that the converted output file is really lossless disregarding the warning message.
Still, the output from dbpoweramp is larger than from foobar2000 for about 100%.
The SACD ISO (3.16 GB) converted to FLAC tracks with foobar2000 is (835 MB).
Converted with dbpoweramp the output is (1.64 GB).
I used compression level 5 in both programs.
Is there any way to check if the conversations are really lossless ?
Tommy

Re: SACD to FLAC

Reply #49
In SACD, audio is encoded using Pulse-density modulation (PDM), and WAV or FLAC use Pulse-code modulation (PCM) encoding.

PDM -> PCM conversion is irreversible and technically not lossless.

(On the other hand, if you convert SACD to FLAC, the resulting file will not have artifacts from lossy compression)