How to use SoX

Discussion in 'Audio Hardware' started by Grant, Jan 27, 2009.

Thread Status:
Not open for further replies.
  1. Grant

    Grant Life is a rock, but the radio rolled me! Thread Starter

    Can anyone offer any guidelines on how to use Windows version of SoX for doing SRC (sample rate conversion)?

    I downloaded this free, command-line audio tool, and can't figure out how to make it do what I want. I want to simply convert a folder of 96k files down to 44.1. There doesn't appear to be anything online about how to use the program, aside from a tutorial on what the terms are, and what command lines to use. The program has no GUI, and says to use Audacity if you do. But, that would be against what I want to use SoX for, as it as a way superior SRC than Audacity ever will.

    Stefan? Barry Diament?
     
  2. Antares

    Antares Forum Resident

    Location:
    Flanders
    Have a look at the batch-example.bat file in the unzipped sox folder, Grant (you can open/edit it with notepad). It explains how to use it (drag&drop or copy&paste your files onto it - or a desktop shortcut to it) and includes the command line parameters to do SRC to 44100 IIRC. If you need other options like dither, you have to change/add the relevant parameters from the syntax and save them. I've only tried it on single clips, but imagine it will work in batch mode for multiple files.
     
  3. Grant

    Grant Life is a rock, but the radio rolled me! Thread Starter

    I read the readme file. The problem is, I can't bring up the application at all. When I click on the executable, all I get is a DOS screen flash and it's gone again.
     
  4. Antares

    Antares Forum Resident

    Location:
    Flanders
    The instructions are in the "batch-example.bat" file itself, not the readme. If all you need to do is resample to 44100, you can use it as is. Just drop your hi-rez files on there, the results can be found in a new sub-folder named "converted".
     
  5. JBStephens

    JBStephens I don't "like", "share", "tweet", or CARE. In Memoriam

    Location:
    South Mountain, NC
    Have you tried start/run/command to get a dox box?
     
  6. If you want high quality 'minimum phase' resampling as recommended by Barry you need to add the -s -M options in the batch file:

    FOR %%A IN (%*) DO sox %%A "converted/%%~nxA" rate -v -s -M 44100

    These are the options that are used in the graphs from http://src.infinitewave.ca

    High Quality: -b 90 -a
    VHQ Linear Phase: -v -s
    VHQ Intermediate Phase: -v -s -I
    VHQ Minimum Phase: -v -s -M


    If there is interest I have a modified version of this batch file in which the resampled files are placed in a subdirectory of the source files and the output filenames are appended with '_44kHz'.
     
  7. Antares

    Antares Forum Resident

    Location:
    Flanders
    Thanks for confirming that, soerin. I remember comparing a clip with the 3 phase settings when I first used SoX and I couldn't make out a clear winner. My (probably conservative) impression was that the default setting was best. Both SSRC_HP and its implementation in EAC3to have given me good results as well (the advantage of the libSsrc.dll in EAC3to being that it accepts 32-bit float files).

    I guess no one's made a GUI for SoX yet because it has so many options. I'm gonna try it out for making a small speed correction to my belt-drive TT needledrops as well. Maybe it will be better than Audacity's speed resampling, which seems to exacerbate TT wow on difficult material.
     
  8. TaterBones

    TaterBones Active Member

    Location:
    The Upstate, SC
    Admittedly, I'm pretty obtuse when it comes to this stuff. I tried it and it worked fine. What would the line above look like if you also wanted to convert from 24 bits to 16 bits?
     
  9. Antares

    Antares Forum Resident

    Location:
    Flanders
    FOR %%A IN (%*) DO sox %%A -b 16 "converted/%%~nxA" rate -v -s -M 44100 dither

    That's with Triangular PDF dither, no noise shaping.
     
  10. TaterBones

    TaterBones Active Member

    Location:
    The Upstate, SC
    Thank you Antares!
     
  11. Stefan

    Stefan Senior Member

    Location:
    Montreal, Canada
    I haven't really tried SoX for SRC, but I do recall trying it for the ability to de-emphasize wave files from early CDs that were written with pre-emphasis. It certainly filtered the EQ properly, but it also seemed to greatly narrow the stereo field, so I stayed away from it. I recall it was quite popular with those doing stereo-to-surround conversions when I dabbled in that a few years back (I created a VST plugin called V.I). At that time SSRC was very highly regarded.

    I'm quite surprised to see how many entries have been added to http://src.infinitewave.ca; it's been awhile since I checked it out. Both SoX and SSRC seem quite impressive in comparison to RX Advanced and iZotope 64-bit.
     
  12. Grant

    Grant Life is a rock, but the radio rolled me! Thread Starter

    But, what would I type in the run box? That's the thing. How do I get it started?
     
  13. Grant

    Grant Life is a rock, but the radio rolled me! Thread Starter

    If I don't want to dither, I just remove the last word in the string?
     
  14. Stefan

    Stefan Senior Member

    Location:
    Montreal, Canada
    I would try:

    Code:
    sox input.wav -b 32 -f output.wav rate -L -s 44100
    
    <substitute the filenames you wish to use>
    This stores the output file as 32-bit floating point with a steep cutoff and linear phase response. I just tested this on a 32/96 file and it sounded quite transparent to me. I did get a message "sox wav: wave header missing FmtExt chunk" but the file still converted.
     
  15. Grant

    Grant Life is a rock, but the radio rolled me! Thread Starter

    Hang with me Steve, I am sitting at my computer. Nothing is open. I want to SRC some files only. I have my files in a folder. What do I do?
     
  16. TaterBones

    TaterBones Active Member

    Location:
    The Upstate, SC
    Grant,

    I dragged a 24/96 FLAC file onto the "batch-example.bat" file that came in the SoX zip file. SoX did its thing and generated a "converted" folder w/a 24/44.1 version of the 24/96 FLAC file.

    I opened "batch-example.bat" w/Notepad & substituted soerin's FOR %%A IN (%*) DO sox %%A "converted/%%~nxA" rate -v -s -M 44100, did a save as & changed .txt to .bat. Dragged a 24/96 FLAC file onto that .bat file & got a high quality 'minimum phase' 24/44.1 version of the 24/96 FLAC file.

    Repeated the process w/Antares' FOR %%A IN (%*) DO sox %%A -b 16 "converted/%%~nxA" rate -v -s -M 44100 dither and got a dithered 16/44.1 version of the 24/96 FLAC file.

    Not sure of the right code line for what you want to do, but basically it's a drag & drop operation (you can do multiple files at once).



    Original line in "batch-example.bat":
    FOR %%A IN (%*) DO sox %%A "converted/%%~nxA" rate -v 44100

    soerin's line:
    FOR %%A IN (%*) DO sox %%A "converted/%%~nxA" rate -v -s -M 44100

    Antares' line:
    FOR %%A IN (%*) DO sox %%A -b 16 "converted/%%~nxA" rate -v -s -M 44100 dither

    I'm only guessing, but maybe:
    FOR %%A IN (%*) DO sox %%A -b 16 "converted/%%~nxA" rate -v -s -M 44100
    will get you a high quality 'minimum phase' 16/44.1 file that isn't dithered.
     
  17. Cymbaline

    Cymbaline Shiny Dog

    Location:
    Buda, TX
    Click Start, then Run, then in the box type cmd. That will open up a DOS prompt, and you can run the program from there.
     
  18. Lazy0ne

    Lazy0ne Forum Resident

    Location:
    Audio Heaven
  19. Antares

    Antares Forum Resident

    Location:
    Flanders
    Removing the dither parameter will still give you a 16-bit output with that line, unless you remove -b 16 as well. Not specifying any -b xx parameter will keep the original file's bit depth.

    Forget about the command prompt by the way, the batch file is where you want to be. All command line parameters are explained in the sox.pdf manual file (or its online html equivalent if you prefer). SRC is listed under the Effects/rate heading, page 23 in the pdf manual.

    FWIW, I tried another another clip with minimum phase setting yesterday (-M parameter) and didn't like the result. Linear phase as Stefan suggested above is the default setting and you can omit the -L parameter.
     
  20. bdiament

    bdiament Producer, Engineer, Soundkeeper

    Location:
    New York
  21. TaterBones

    TaterBones Active Member

    Location:
    The Upstate, SC
    Does that mean that using:
    FOR %%A IN (%*) DO sox %%A -b 16 "converted/%%~nxA" rate -v -s 44100 dither
    will produce a 16bit/44.1kHz VHQ linear phase file that's been dithered?
     
  22. Antares

    Antares Forum Resident

    Location:
    Flanders
    Yes, it will :)
    (you may add -L in there with the rate parameters just to remind you, but it's not required since that's what sox defaults to)
     
  23. Stefan

    Stefan Senior Member

    Location:
    Montreal, Canada
    Good news!

    For those who don't feel like dabbling with command lines or batch files, I just discovered that someone has recently ported the SoX resampling routines to a component for foobar2000. That means loading your files in the app, right-clicking, choosing Convert to..., DSP Processing, then away you go. It seems fast and works well. Below is a pic.

    The hydrogenaudio forum seems really slow today for some reason but stick with it. The component is worth it, and it's free, as is Foobar2000.

    Foobar2000: http://www.foobar2000.org
    Component: http://www.hydrogenaudio.org/forums/index.php?act=attach&type=post&id=4766
    (download this and place it in the Foobar "components" subdirectory.
     

    Attached Files:

  24. Grant

    Grant Life is a rock, but the radio rolled me! Thread Starter

    Steve, you da man!:thumbsup:
     
  25. Antares

    Antares Forum Resident

    Location:
    Flanders
    Thank you, Stefan :righton:! And I see basic dither can be selected under the Other tab as well (which I guess would be Triangular PDF like SoX uses).
     
Thread Status:
Not open for further replies.

Share This Page

molar-endocrine