Running SoX from Processing/Java on Windows computer

This might be an easy one - but it's driving me nuts at this point. I'm trying to run SoX from Processing which on my mac computer is running smoothly and with no problems. I need to migrate the code to a windows 7 machine but can't get it to work for some reason. Talking to the terminal from processing works fine. I'm in the right folder (sketch data folder where SoX is also intalled) since I can run commands like "dir" etc. and get the right content printed - but as soon as I try to run sox.exe nothing happens (getting an exit value 1). Running sox.exe straight from the cmd terminal works fine. Here is a sample of what I'm trying to do:

void playBackYear (){

soxPlay = "cmd /c sox.exe year.wav -d";
  println (soxPlay);
 try {
    File workingDir = new File(sketchPath("data"));
    Process p=Runtime.getRuntime().exec(soxPlay, null, workingDir);
    p.waitFor(); 
    BufferedReader reader=new BufferedReader(
    new InputStreamReader(p.getInputStream())
      ); 
    String line; 
    while ( (line = reader.readLine ()) != null) 
    { 
      println(line);
    }
   int exitVal = p.waitFor();
   System.out.println("Exited with error code "+exitVal);
  } 

  catch(IOException e1) {
  } 
  catch(InterruptedException e2) {
  } 

}

So the questions is what am I doing wrong here? Any help is appreciated.

Tagged:

Answers

  • I don't know what sox is, are we supposed to google for it?

    Is sox.exe declared in your path? Otherwise, cmd won't find it, unless you give it a full path.

  • edited May 2015

    Hi PhiLho, thanks for you reply. Sorry if I'm unclear. SoX is an audio software running from the command line - like ffmpeg. I believe sox.exe is declared in the path since it is present in the folder I'm calling:

    File workingDir = new File(sketchPath("data"));

    So if understand your question correctly it should be fine. I have tried calling other files in the same folder from processing which works fine - just not the sox.exe file... I have also tried declaring the absolute path, which doesn't work either...

  • edited May 2015

    FYI, File workingDir = new File(sketchPath("data")); can be written File workingDir = dataFile("");

    "I have tried calling other files"
    Do you mean you ran other exe files?

    BTW, I found out http://sox.sourceforge.net/sox.html but there I don't see a -d option, not sure what your command line is supposed to do.

Sign In or Register to comment.