public String fadeAudio(String path,String type,double fadeInLength,double stopTime,double fadeOutLength) throws IOException {
  final List<String> curves=Arrays.asList(new String[]{"q","h","t","l","p"});
  if (!curves.contains(type)) {
    throw new RuntimeException("fadeAudio: passed invalid type: " + type);
  }
  File file=new File(path);
  String outFile=file.getCanonicalPath() + "_faded.wav";
  ArrayList<String> cmd=new ArrayList<String>();
  cmd.add(soxBin);
  cmd.add(path);
  cmd.add(outFile);
  cmd.add("fade");
  cmd.add(type);
  cmd.add(fadeInLength + "");
  if (stopTime != -1)   cmd.add(stopTime + "");
  if (fadeOutLength != -1)   cmd.add(fadeOutLength + "");
  try {
    int rc=execSox(cmd,callback);
    if (rc != 0) {
      outFile=null;
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
catch (  InterruptedException e) {
    e.printStackTrace();
  }
  return outFile;
}

public String fadeAudio ( String path , String type , double fadeInLength , double stopTime , double fadeOutLength ) throws IOException { final List < String > curves = Arrays . asList ( new String [ ] { "q" , "h" , "t" , "l" , "p" } ) ; if ( ! curves . contains ( type ) ) { throw new RuntimeException ( "fadeAudio: passed invalid type: " + type ) ; } File file = new File ( path ) ; String outFile = file . getCanonicalPath ( ) + "_faded.wav" ; ArrayList < String > cmd = new ArrayList < String > ( ) ; cmd . add ( soxBin ) ; cmd . add ( path ) ; cmd . add ( outFile ) ; cmd . add ( "fade" ) ; cmd . add ( type ) ; cmd . add ( fadeInLength + "" ) ; if ( stopTime != - 1 ) cmd . add ( stopTime + "" ) ; if ( fadeOutLength != - 1 ) cmd . add ( fadeOutLength + "" ) ; try { int rc = execSox ( cmd , callback ) ; if ( rc != 0 ) { outFile = null ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } return outFile ; }
fade audio file sox < path > outfile fade < type > < fadeinlength > < stoptime > < fadeoutlength >
