代码:使用SoundTouch生成带特殊音效的音频文件

SoundTouch安装方法见:http://blog.csdn.net/qq354960984/article/details/53201448


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 使用SoundTouch工具生成带特殊音效的音频文件
 *
 * 结果文件下载地址:http://pan.baidu.com/s/1gf9LdmF
 *
 * @author Brook
 *
 */
public class SoundEffectDemo {

    public static void main(String[] args) throws Exception {
        // 机器人
        execCommand("soundstretch4Lame original.mp3 Robot-Highest.mp3 -pitch=11");
        execCommand("soundstretch4Lame original.mp3 Robot-Higher.mp3 -pitch=9");
        execCommand("soundstretch4Lame original.mp3 Robot-High.mp3 -pitch=5");
        execCommand("soundstretch4Lame original.mp3 Robot-Low.mp3 -pitch=-5");
        execCommand("soundstretch4Lame original.mp3 Robot-Lower.mp3 -pitch=-9");
        execCommand("soundstretch4Lame original.mp3 Robot-Lowest.mp3 -pitch=-11");

        // 回声
        execCommand("soundstretch4Lame original.mp3 Echo_-10.mp3 -tempo=-10");
        execCommand("soundstretch4Lame original.mp3 Echo_-30.mp3 -tempo=-30");
        execCommand("soundstretch4Lame original.mp3 Echo_-50.mp3 -tempo=-50");

        // 加速
        execCommand("soundstretch4Lame original.mp3 Speed_-10.mp3 -rate=-10");
        execCommand("soundstretch4Lame original.mp3 Speed_-30.mp3 -rate=-30");
        execCommand("soundstretch4Lame original.mp3 Speed_-50.mp3 -rate=-50");

        // 减速
        execCommand("soundstretch4Lame original.mp3 Speed_10.mp3 -rate=10");
        execCommand("soundstretch4Lame original.mp3 Speed_30.mp3 -rate=30");
        execCommand("soundstretch4Lame original.mp3 Speed_50.mp3 -rate=50");
    }

    /**
     * 执行命令
     * 
     * @param command
     *            命令
     * @return
     */
    public static void execCommand(String command) throws Exception {
        System.out.println("*************start execute command**************");

        BufferedReader br = null;
        Process proc = null;
        try {
            // 创建子进程并执行命令
            proc = Runtime.getRuntime().exec(command);

            // 获取错误流,并打印输出
            br = new BufferedReader(new InputStreamReader(proc.getErrorStream()));
            String line = null;
            while ((line = br.readLine()) != null) {
                System.out.println("line: " + line);
            }
            System.out.println("*************execute end**************");
        } catch (Exception t) {
            t.printStackTrace();
            System.out.println("*************execute end**************");
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                }
            }

            if (proc != null) {
                proc.destroy();
            }
        }
    }
}

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值