3

这就是我想要的:
1. 播放歌曲时的实时音高变换。
2. 音高变化也应记录到文件中。

代码 :

    double rate = 1.0;
    RateTransposer rateTransposer;
    AudioDispatcher dispatcher;
    WaveformSimilarityBasedOverlapAdd wsola;

    dispatcher = AudioDispatcherFactory.fromPipe(mAudiopath, 44100, 5000, 2500);
    rateTransposer = new RateTransposer(rate);
    wsola = new WaveformSimilarityBasedOverlapAdd(WaveformSimilarityBasedOverlapAdd.Parameters.musicDefaults(rate, 44100));
    WaveformWriter writer = new WaveformWriter((TarsosDSPAudioFormat) dispatcher.getFormat(), BASE_PATH + "Recorded" + File.separator + "PITCHED_" + mVideoFileName + ".mp3");

    wsola.setDispatcher(dispatcher);
    dispatcher.addAudioProcessor(wsola);
    dispatcher.addAudioProcessor(rateTransposer);
    dispatcher.addAudioProcessor(new AndroidAudioPlayer(dispatcher.getFormat()));
    dispatcher.setZeroPadFirstBuffer(true);
    dispatcher.setZeroPadLastBuffer(true);
    dispatcher.addAudioProcessor(writer);

但在这里我面临以下错误:

Error:(362, 41) error: cannot access AudioFormat
class file for javax.sound.sampled.AudioFormat not found

用于线

   WaveformWriter writer = new WaveformWriter((TarsosDSPAudioFormat) dispatcher.getFormat(), BASE_PATH + "Recorded" + File.separator + "PITCHED_" + mVideoFileName + ".mp3");

如果我删除此行,一切正常,只有歌曲不会记录到文件中。
请让我知道是否有人可以提供帮助。

4

1 回答 1

4

使用不依赖 JVM 的 WriterProcessor 类解决了这个问题。

参考:https ://github.com/JorenSix/TarsosDSP/issues/64

于 2016-05-23T09:44:11.437 回答