PDA

View Full Version : SoX File Conversion Utility



MartinT
17-08-2012, 22:22
I couldn't find any reference to SoX here on AoS, so I thought I'd start a new thread. SoX is a powerful music file conversion program - the power of it is really quite mind boggling. It's a command line tool, but don't let that put you off.

http://sox.sourceforge.net/Main/HomePage

There are binaries for Windows and MacOS and I'm sure the Linux guys could compile the source files without too much bother. It is easily run in a batch file for converting whole albums of files at once.

I've been experimenting with upsampling files from CD 16/44 to 24/96 as both WAV and FLAC files. It can do all sorts of clever things like gain adjustment to ensure that it doesn't run out of headroom when file converting, or converting, say, WAV to FLAC format.

It takes a while to get the command line parameters just right, here's an example single line batch command that does file upsampling to 24/96 with automatic gain compensation to avoid clipping and full verbose mode to tell you what it's doing:

FOR %%A IN (%*) DO "C:\Program Files (x86)\sox-14-4-0\sox.exe" -V3 -S -G %%A -b24 -r96k "Converted/%%~nxA"

I'm running W7-64, but it's easily adjusted for other purposes. Make a Windows shortcut from it and you can even drop a whole load of files onto it for automatic conversion - the Converted folder should be put wherever the shortcut is.

I'd love to see example lines of how other people are using it.

Stratmangler
17-08-2012, 23:31
Sox is a built in part of LMS if you're using Windoze versions of LMS.
I imagine it's the same with the Mac spec version.

I have a Linux server of lowly processing capability, so it doesn't do Sox - that's why I swapped out a perfectly serviceable SB3 for a Touch - the Touch does much more natively than the SB3.

MartinT
17-08-2012, 23:41
Sure, but pre-processing files with SoX on a PC should at least alleviate the processing requirements of the Touch, shouldn't it?

Stratmangler
17-08-2012, 23:56
Why pre-process if you're running server on a machine up to the task of on the fly processing?
LMS will do what it needs to do, provided that the hosting machine is up to the task.

synsei
18-08-2012, 03:59
Please excuse my ignorance, most of this is well beyond my understanding but why convert a 16bit file into 24bit? Surely it's not going to make any difference to the audio quality of the outputted file as there is a finite amount of information which can be extracted from the original 16bit file? Apologies if this makes no sense, I know what I mean I'm just finding it hard to put it into words :scratch:

bobbasrah
18-08-2012, 06:14
Please excuse my ignorance, most of this is well beyond my understanding but why convert a 16bit file into 24bit? Surely it's not going to make any difference to the audio quality of the outputted file as there is a finite amount of information which can be extracted from the original 16bit file? Apologies if this makes no sense, I know what I mean I'm just finding it hard to put it into words :scratch:

A number of folks are reporting more enjoyable audio when it is converted Dave, even though the base data is no different. Whether the DAC is optimised for 24bit seems to play the major role here, and the filtering is IIRC different, but some say the result is smoother and more enjoyable.:D

Personally I leave things original, as have found the mastering of the 24 or 16bit can be quite significantly different with albums I have in both formats. :scratch:

The additional storage required for padding out the 16bit file to 24bit can be quite significant also.;)

WAD62
18-08-2012, 08:11
Like Chris I don't use it with my Squeezebox devices as my server is only 1.2Ghz, and I'm running 4 clients, also I'd rather keep the FTP volumes to a minimum.

I do use it (well FFSoX) as an input plugin for winamp on my PCs/Laptops, but only to transcode from FLAC to 16/44.1, as this gives proper gapless with ASIO (gets round a bug in the ASIO plugin).

In the past I've tried upsampling to 24/96, and it can appear to be a little smoother at the top end with some DACs, but probably at the expense of dynamics. After acquiring my M-Dac and more recently an rPAC I've found I prefer keeping things at 16/44.1...it's for this reason I've also stopped using replaygain, and crossfade, as they resample to 24 bit too :)

MartinT
18-08-2012, 08:28
Please excuse my ignorance, most of this is well beyond my understanding but why convert a 16bit file into 24bit? Surely it's not going to make any difference to the audio quality of the outputted file as there is a finite amount of information which can be extracted from the original 16bit file?

It's a good question. You're right in that there cannot be any more information in the upsampled file; however, it changes the behaviour of the DAC. What happens is that the data is resampled from 44,100 slices per second to 96,000. Now it doesn't take much maths to realise that that is not a simple doubling to 88,200 but involves some rather complex interpolation. The increase of data word length from 16-bit to 24-bit helps so that it can more precisely define the 'intermediate' points in hgher precision.

You end up with a much larger file defining a smoother waveform without the addition of anything that wasn't there originally. The reason for doing it is that the DAC 'brickwall' filter is pushed much higher up the spectrum, from 22.05kHz (Information Law says there is nothing above half the sampling frequency except garbage) to, in this case, 48kHz. Many people report that they can hear the phasing effects of such a filter so close to the music in 16/44 playback and that things sound better when upsampled before reaching the DAC. Your mileage may vary :)

Tim
18-08-2012, 08:34
Very good explanation there Martin - many thanks for making things clearer as I was also wondering about this.

MartinT
18-08-2012, 08:43
Why pre-process if you're running server on a machine up to the task of on the fly processing?
LMS will do what it needs to do, provided that the hosting machine is up to the task.

It's a good question, Chris. I'm not even sure I've set LMS to do any upsampling and will have to look at my settings more closely.

Stratmangler
18-08-2012, 11:59
It's a good question, Chris. I'm not even sure I've set LMS to do any upsampling and will have to look at my settings more closely.

When I ran LMS on a Win 7 machine, which is not that long ago, I also had a SB3 running on the network.
The SB3 does not natively handle as many formats as the Touch can, but I never had any issues playing any of my files on the SB3 - the Windoze version of LMS just did the necessary transcoding and sent it to the SB3.

A switch of server to a more basic type of machine (Zyxel NSA310) and the transcoding stopped.

The Zyxel is a great file server, but there's no serious processing grunt there to transcode things, so the manufacturers took that part of LMS out.

To get around the problem I replaced the SB3 with another Touch, rather than go back to a Windoze PC based solution, the reason being that the Zyxel costs peanuts to run.

Now prior to the Triode EDO applet becoming available I could not play 24/192 files from the server running my Zyxel NAS.

I could play 24/192 files off a Windoze based server - transcoding just occurred whenever it was necessary.

What the Triode EDO applet has done for me is to allow me to play 24/192 off a much less power hungry serving machine on one of the Touch players (the one in the main rig connected to a M2Tech Evo DAC).
The other one doesn't, because it's using the analog outs into a chip amp.

What's all of the above got to do with Sox?
Sox just runs on Windoze based installations.

Stratmangler
18-08-2012, 12:10
Please excuse my ignorance, most of this is well beyond my understanding but why convert a 16bit file into 24bit? Surely it's not going to make any difference to the audio quality of the outputted file as there is a finite amount of information which can be extracted from the original 16bit file? Apologies if this makes no sense, I know what I mean I'm just finding it hard to put it into words :scratch:

The increase in bit rate is a simple addition of four redundant zeros into each sample, and requires next to nil processing.
They're put there give useable range to the digital volume control in the Squeezebox players, and minimizes data loss in doing so.

So using the digital volume control does degrade the signal.

A simple test is to play a file ripped from a HDCD into a DAC with a HDCD activation light.
At full volume the light will be on. The rip is bit perfect.
Turn the volume down and it goes off. The rip is still bit perfect, but the light goes off because the additional information hasn't got through because the digital volume control has degraded the file.

MartinT
18-08-2012, 12:35
Which raises the question: does anyone know if SoX recognises HDCD and can make use of the additional resolution when upsampling? I have a few CDs I'de love to hear in all their glory as my Ayre doesn't recognise HDCD (which I think requires a Pacific chipset).

synsei
18-08-2012, 12:47
It's a good question. You're right in that there cannot be any more information in the upsampled file; however, it changes the behaviour of the DAC. What happens is that the data is resampled from 44,100 slices per second to 96,000. Now it doesn't take much maths to realise that that is not a simple doubling to 88,200 but involves some rather complex interpolation. The increase of data word length from 16-bit to 24-bit helps so that it can more precisely define the 'intermediate' points in hgher precision.

You end up with a much larger file defining a smoother waveform without the addition of anything that wasn't there originally. The reason for doing it is that the DAC 'brickwall' filter is pushed much higher up the spectrum, from 22.05kHz (Information Law says there is nothing above half the sampling frequency except garbage) to, in this case, 48kHz. Many people report that they can hear the phasing effects of such a filter so close to the music in 16/44 playback and that things sound better when upsampled before reaching the DAC. Your mileage may vary :)

Thank you for your very concise explanation Martin, I knew there had to be more to it hence why I asked the question. I guess SoX is yet another thing I'll need to learn to master :eyebrows: There's only so much room in my head ya know :ner: :lol:

Stratmangler
18-08-2012, 12:50
Which raises the question: does anyone know if SoX recognises HDCD and can make use of the additional resolution when upsampling? I have a few CDs I'de love to hear in all their glory as my Ayre doesn't recognise HDCD (which I think requires a Pacific chipset).

You could use dbPoweramp to rip the CDs to FLAC.
dbPoweramp can recognise HDCD and extract the additional information.
The files come out as 24/44.1

MartinT
18-08-2012, 12:52
Thanks, Chris.

Stratmangler
18-08-2012, 12:56
Thanks, Chris.


You're welcome.

dbPoweramp can be trialled for free, and it's fully featured for the duration of the trial period.
You'll need to install the additional DSPs and codecs.