|
From: kevin p. <kp...@me...> - 2010-03-28 14:42:31
|
Thanks for taking the time to reply.
On Mar 27, 2010, at 8:26 PM, Andreas Mock wrote:
> -----Ursprüngliche Nachricht-----
>
> I don't really know where in the question the sox specific part is.
there isn't one.
The confusion is that the sox command line can be very complex with global options/arguments and in file, format options, and outfile and the effect/effect options as the manual points out:
% sox [global-options] infile [format-options] outfile effect [effect-options]
What i find confusing is how to feed all this info to sox via the subprocess module in Python. In the old days this would not be an issue since you would use the os module and just quote the entire command line exactly as you wanted it as if you were typing in the shell:
import os
os.system('sox -V3 -D -S in-01.aif -b16 out-01.aif rate -s -v 44100')
I am not sure what that would look like using the new subprocess module since i have arguments and the effects at the end. I am calling sox with the -V3 -D -S flags, specifying my input file using a format option to change the bit depth specifying an output file name and then using the excellent "very high quality" option sample rate conversion that is available as an "effect". My command line in the shell would look like this:
sox -V3 -D -S in-01.aif -b16 out-01.aif rate -s -v 44100
In this case i am using the sample rate conversion with the very high quality option at the end because I don't think you can not use if you do your conversion like so: sox -V3 -D in-01.aif -b 16 -r 44100 out-01.aif
So, since i am unfamiliar with / confused by subprocess I am not sure how to feed that command line
sox -V3 -D -S in-01.aif -b16 out-01.aif rate -s -v 44100
to subprocess with everything in the right order. There are some nice shell scripts on line showing how to call sox in a bash script there are no python examples and I would think that seeing a python example or two would help me grok it. Since someone may have already figured this out (not a stretch that there are ruby, perl and python users here and i saw on the wiki site that an early contributor to sox was none other than Guido van Rossum, author of python) I thought that i would ask.
-kp
> But the easiest way to call sox would be the following. If you call sox on
> the command line with
> sox arg1 arg2 arg3 arg4
> you get the same in pythn with:
>
> import subprocess
> retcode = subprocess.call(["sox", "arg1", "arg2", "arg3", "arg4"])
>
> That's it.
Then how do you specify flags and effects? sox has more than just arguments to specify.
|