Skip to main content
Topic: SACD to FLAC (Read 4437 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.

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.


 
SimplePortal 1.0.0 RC1 © 2008-2018