在 Android 上使用 TarsosDSP 进行实时变调
RealTime Pitch Shifting using TarsosDSP on Android
这是我想要的:
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");
如果我删除此行,一切正常,只是歌曲未录制到文件中。
如果有人可以提供帮助,请告诉我。
此问题已使用不依赖于 JVM 的 WriterProcessor class 解决。
参考:https://github.com/JorenSix/TarsosDSP/issues/64
这是我想要的:
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");
如果我删除此行,一切正常,只是歌曲未录制到文件中。
如果有人可以提供帮助,请告诉我。
此问题已使用不依赖于 JVM 的 WriterProcessor class 解决。