1

在使用 SoxController 类时遇到问题。. 任何人都可以给我 SoxController Class 中的 triaudio 函数的示例。. .

4

1 回答 1

0

让我们试试这个,我认为它对你来说是完美的,因为我已经测试过了。它运作良好

/**
 * Trim File Wave
 */
public class TrimFileWave extends AsyncTask<String, Void, Void> {
    private ProgressDialogUtil progressDialogUtil;
    private Context            context;

    public TrimFileWave(Context context) {
        this.context = context;
        progressDialogUtil = new ProgressDialogUtil(context, R.string.progressing);
    }

    @Override
    protected void onPreExecute() {
        progressDialogUtil.show();
    }

    @Override
    protected Void doInBackground(String... params) {
        startTrimFile();
        return null;
    }

    @Override
    protected void onPostExecute(Void unused) {
        progressDialogUtil.dismiss();
    }

    private void startTrimFile() {
        File fileAppRoot = new File(context.getApplicationInfo().dataDir);
        try {
            SoxController sxCon = new SoxController(context, fileAppRoot, new ShellUtils.ShellCallback() {
                @Override
                public void shellOut(String shellLine) {
                    DebugUtil.log(new Exception(), shellLine);
                }

                @Override
                public void processComplete(int exitValue) {
                    DebugUtil.log(new Exception(), exitValue);
                }
            });
            double length = sxCon.getLength(MyApplication.FILE_NAME_RECORDED_WAVE);
            DebugUtil.log(new Exception(), "[length]" + length);
            // sxCon.trimAudio(MyApplication.FILE_MERGE_WAVE, 0, length);
            // Type {"q", "h", "t", "l", "p"}
            sxCon.fadeAudio(MyApplication.FILE_MERGE_WAVE, "t", 0, length, 1);
        }
        catch (Exception e) {
            DebugUtil.logInfo(new Exception(), e.toString());
        }
    }

}
于 2014-11-10T19:37:49.317 回答