Here is what I want :
1. Real time pitch shift while playing song.
2. Pitch shift should also be recorded to a file.
code :
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);
But here I am facing following error :
Error:(362, 41) error: cannot access AudioFormat
class file for javax.sound.sampled.AudioFormat not found
for line
WaveformWriter writer = new WaveformWriter((TarsosDSPAudioFormat) dispatcher.getFormat(), BASE_PATH + "Recorded" + File.separator + "PITCHED_" + mVideoFileName + ".mp3");
If I remove this line everything works fine only song is not recorded to file.
Please let me know if someone could help.
This issue was resolved using WriterProcessor class which has no dependency on JVM.