JorenSix / TarsosDSP

A Real-Time Audio Processing Framework in Java
http://0110.be/tag/TarsosDSP
GNU General Public License v3.0
1.97k stars 472 forks source link

Dispatcher takes time when started from the middle of on audio file #195

Open reallyouttaworld opened 4 years ago

reallyouttaworld commented 4 years ago

Hi, thanks @JorenSix for building this amazing library. I have been using it for quite some time now.

It works great for me except this one thing that I don't know how to fix. When I try to playback an audio file from somewhere in the middle of the song, then it takes some time to start playing from there.

If I try to play it from the beginning then it starts instantly though.

Here is the sample code that I have been using:

        FileInputStream fileInputStream = new FileInputStream(newFile);
        dispatcher = new AudioDispatcher(new UniversalAudioInputStream(fileInputStream, tarsosDSPAudioFormat), bufferSize, overlap);

        dispatcher.addAudioProcessor(new AndroidAudioPlayer(tarsosDSPAudioFormat, 6202, AudioManager.STREAM_MUSIC));
        dispatcher.addAudioProcessor(pitchProcessor);

        dispatcher.skip(skip - 0.10);