这就是我想要的:
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");
如果我删除此行,一切正常,只有歌曲不会记录到文件中。
请让我知道是否有人可以提供帮助。